All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.stanford.protege.webprotege.entity.CommentedEntityData Maven / Gradle / Ivy

The newest version!
package edu.stanford.protege.webprotege.entity;



import edu.stanford.protege.webprotege.common.UserId;

import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

import static com.google.common.base.Preconditions.checkNotNull;

/**
 * Matthew Horridge
 * Stanford Center for Biomedical Informatics Research
 * 8 Mar 2017
 */
public class CommentedEntityData implements  Comparable {

    public static final transient Comparator byEntity = Comparator.naturalOrder();

    public static final transient Comparator byLastModified =
            Comparator.comparing(CommentedEntityData::getLastModified, Comparator.reverseOrder())
                      .thenComparing(Comparator.naturalOrder());


    private OWLEntityData entityData;

    private int totalThreadCount;

    private int openThreadCount;

    private int totalCommentCount;

    private long lastModified;

    private UserId lastModifiedBy;

    private List partipants;

    private static final transient Comparator comparator =
            Comparator.comparing((CommentedEntityData c) -> c.getOpenThreadCount() > 0)
                      .reversed()
                      .thenComparing(c -> c.getEntityData().getBrowserText().toLowerCase());


    private CommentedEntityData() {
    }

    public CommentedEntityData(@Nonnull OWLEntityData entityData,
                               int totalThreadCount,
                               int openThreadCount,
                               int totalCommentCount,
                               long lastModified,
                               @Nonnull UserId lastModifiedBy,
                               @Nonnull List participants) {
        this.entityData = checkNotNull(entityData);
        this.totalThreadCount = totalThreadCount;
        this.openThreadCount = openThreadCount;
        this.totalCommentCount = totalCommentCount;
        this.lastModified = lastModified;
        this.lastModifiedBy = checkNotNull(lastModifiedBy);
        this.partipants = new ArrayList<>(participants);
    }

    @Nonnull
    public OWLEntityData getEntityData() {
        return entityData;
    }

    public int getTotalThreadCount() {
        return totalThreadCount;
    }

    public int getOpenThreadCount() {
        return openThreadCount;
    }

    public int getTotalCommentCount() {
        return totalCommentCount;
    }

    public long getLastModified() {
        return lastModified;
    }

    @Nonnull
    public UserId getLastModifiedBy() {
        return lastModifiedBy;
    }

    public List getPartipants() {
        return new ArrayList<>(partipants);
    }

    @Override
    public int compareTo(@Nonnull CommentedEntityData o) {
        return comparator.compare(this, o);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy