edu.stanford.protege.webprotege.sharing.SharingSetting Maven / Gradle / Ivy
package edu.stanford.protege.webprotege.sharing;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import java.io.Serializable;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Author: Matthew Horridge
* Stanford University
* Bio-Medical Informatics Research Group
* Date: 27/02/2012
*
* Represents a SharingSetting for a particular UserId.
*
*/
public class SharingSetting implements Comparable, Serializable {
private PersonId personId;
private SharingPermission sharingPermission;
private SharingSetting() {
}
/**
* Constructs a UserSharingSetting which specifies the SharingSetting for a particular person. The person may, or
* may not be a registered WebProtege user.
* @param personId The PersonId which the SharingSetting pertains to. Must not be null
.
* @param sharingPermission The SharingPermission which pertains the the UserId. Must not be null
.
* @throws NullPointerException if the userId parameter is null
or the sharingPermission parameter
* is null
.
*/
@JsonCreator
public SharingSetting(@JsonProperty("personId") PersonId personId,
@JsonProperty("sharingPermission") SharingPermission sharingPermission) {
this.personId = checkNotNull(personId);
this.sharingPermission = checkNotNull(sharingPermission);
}
/**
* Gets the PersonId for this SharingSetting.
* @return The PersonId. Not null
.
*/
public PersonId getPersonId() {
return personId;
}
/**
* Gets the SharingSetting for this particular UserSharingSetting.
* @return The SharingSetting. Not null
.
*/
public SharingPermission getSharingPermission() {
return sharingPermission;
}
public int compareTo(SharingSetting o) {
return personId.compareTo(o.personId);
}
@Override
public String toString() {
return MoreObjects.toStringHelper("UserSharingSetting")
.addValue(personId)
.addValue(sharingPermission)
.toString();
}
@Override
public int hashCode() {
return Objects.hashCode(personId, sharingPermission);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof SharingSetting)) {
return false;
}
SharingSetting other = (SharingSetting) obj;
return this.personId.equals(other.personId) && this.sharingPermission.equals(other.sharingPermission);
}
}