LinkedEntity is now comparable

This commit is contained in:
Luca Frosini 2023-01-20 17:49:19 +01:00
parent c0c36bdf9c
commit de1bb75c56
2 changed files with 45 additions and 1 deletions

View File

@ -117,4 +117,48 @@ public final class LinkedEntityImpl extends PropertyElementImpl implements Linke
Objects.equals(description, other.description);
}
@Override
public int compareTo(LinkedEntity other) {
if (this == other) {
return 0;
}
if (other == null) {
return -1;
}
if (getClass() != other.getClass()) {
return -1;
}
LinkedEntityImpl o = (LinkedEntityImpl) other;
int ret = 0;
ret = source.compareTo(o.source);
if(ret != 0) {
return ret;
}
ret = relation.compareTo(o.relation);
if(ret != 0) {
return ret;
}
ret = target.compareTo(o.target);
if(ret != 0) {
return ret;
}
ret = max.compareTo(o.max);
if(ret != 0) {
return ret;
}
ret = min.compareTo(o.min);
if(ret != 0) {
return ret;
}
return description.compareTo(o.description);
}
}

View File

@ -18,7 +18,7 @@ import org.gcube.informationsystem.utils.Version;
@JsonDeserialize(as=LinkedEntityImpl.class)
@TypeMetadata(name = LinkedEntity.NAME, description = " A convenient type to define a Resource in terms of: mandatory/recommended ConsistsOf->Facets; suggested IsRelatedTo->Resource.", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
public interface LinkedEntity extends PropertyElement {
public interface LinkedEntity extends PropertyElement, Comparable<LinkedEntity> {
public static final String NAME = "LinkedEntity"; // LinkedEntity.class.getSimpleName();