// Path: src/main/java/org/nextrtc/examples/videochat_with_rest/domain/history/Call.java
// public class Call {
//     private List<String> otherRtcIds;
//     private Date started;
//     private long duration;
//     private boolean inProgress;
//     private List<String> otherNames;
// 
//     public Call(List<String> members, boolean inProgress, Date begin, long duration) {
//         this.otherRtcIds = members;
//         this.started = begin;
//         this.duration = TimeUnit.SECONDS.convert(duration, TimeUnit.MILLISECONDS);
//         this.inProgress = inProgress;
//     }
// 
//     public List<String> getOtherRtcIds() {
//         return otherRtcIds;
//     }
// 
//     public Date getStarted() {
//         return started;
//     }
// 
//     public Long getDuration() {
//         return duration;
//     }
// 
//     public boolean isInProgress() {
//         return inProgress;
//     }
// 
//     public List<String> getOtherNames() {
//         return otherNames;
//     }
// 
//     public void setOtherNames(List<String> otherNames) {
//         this.otherNames = otherNames;
//     }
// }


import org.joda.time.DateTime;
import org.joda.time.Interval;
import org.nextrtc.examples.videochat_with_rest.domain.history.Call;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import static java.util.stream.Collectors.toList;
import static org.joda.time.DateTime.now;
    public Member(String memberId, User user) {
        this.rtcId = memberId;
        this.user = user;
        this.connected = now().toDate();
    }

    public void disconnectWithReason(Optional<String> reason) {
        disconnected = now().toDate();
        reason.ifPresent(this::setLeftReason);
    }

    @Override
    public String toString() {
        return String.format("(%s, %s)[%s - %s]", id, rtcId, connected, disconnected);
    }

    public void leaves(Conversation conversation) {
        if (connection.isFor(conversation)) {
            connection.close();
        }
    }

    private void setLeftReason(String leftReason) {
        this.leftReason = leftReason;
    }

    public int startedBefore(Member p) {
        return connected.compareTo(p.connected);
    }

// Path: src/main/java/org/nextrtc/examples/videochat_with_rest/domain/history/Call.java
// public class Call {
//     private List<String> otherRtcIds;
//     private Date started;
//     private long duration;
//     private boolean inProgress;
//     private List<String> otherNames;
// 
//     public Call(List<String> members, boolean inProgress, Date begin, long duration) {
//         this.otherRtcIds = members;
//         this.started = begin;
//         this.duration = TimeUnit.SECONDS.convert(duration, TimeUnit.MILLISECONDS);
//         this.inProgress = inProgress;
//     }
// 
//     public List<String> getOtherRtcIds() {
//         return otherRtcIds;
//     }
// 
//     public Date getStarted() {
//         return started;
//     }
// 
//     public Long getDuration() {
//         return duration;
//     }
// 
//     public boolean isInProgress() {
//         return inProgress;
//     }
// 
//     public List<String> getOtherNames() {
//         return otherNames;
//     }
// 
//     public void setOtherNames(List<String> otherNames) {
//         this.otherNames = otherNames;
//     }
// }


// Path: src/main/java/org/nextrtc/examples/videochat_with_rest/domain/Member.java
import org.joda.time.DateTime;
import org.joda.time.Interval;
import org.nextrtc.examples.videochat_with_rest.domain.history.Call;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import static java.util.stream.Collectors.toList;
import static org.joda.time.DateTime.now;

    public Member(String memberId, User user) {
        this.rtcId = memberId;
        this.user = user;
        this.connected = now().toDate();
    }

    public void disconnectWithReason(Optional<String> reason) {
        disconnected = now().toDate();
        reason.ifPresent(this::setLeftReason);
    }

    @Override
    public String toString() {
        return String.format("(%s, %s)[%s - %s]", id, rtcId, connected, disconnected);
    }

    public void leaves(Conversation conversation) {
        if (connection.isFor(conversation)) {
            connection.close();
        }
    }

    private void setLeftReason(String leftReason) {
        this.leftReason = leftReason;
    }

    public int startedBefore(Member p) {
        return connected.compareTo(p.connected);
    }

    public Call toCall() {