diff --git a/src/main/java/org/gcube/informationsystem/types/impl/properties/LinkedEntityImpl.java b/src/main/java/org/gcube/informationsystem/types/impl/properties/LinkedEntityImpl.java index dc50bc5..dbecdc3 100644 --- a/src/main/java/org/gcube/informationsystem/types/impl/properties/LinkedEntityImpl.java +++ b/src/main/java/org/gcube/informationsystem/types/impl/properties/LinkedEntityImpl.java @@ -117,6 +117,11 @@ public final class LinkedEntityImpl extends PropertyElementImpl implements Linke Objects.equals(description, other.description); } + protected int compareIntegers(Integer thisInt, Integer otherInt) { + Integer thisInteger = thisInt == null ? Integer.MAX_VALUE : thisInt; + Integer otherInteger = otherInt == null ? Integer.MAX_VALUE : otherInt; + return thisInteger.compareTo(otherInteger); + } @Override public int compareTo(LinkedEntity other) { @@ -148,12 +153,12 @@ public final class LinkedEntityImpl extends PropertyElementImpl implements Linke return ret; } - ret = max.compareTo(o.max); + ret = compareIntegers(max, o.max); if(ret != 0) { return ret; } - ret = min.compareTo(o.min); + ret = compareIntegers(min, o.min); if(ret != 0) { return ret; } diff --git a/src/main/java/org/gcube/informationsystem/types/impl/properties/PropertyDefinitionImpl.java b/src/main/java/org/gcube/informationsystem/types/impl/properties/PropertyDefinitionImpl.java index 05be260..15e6e5c 100644 --- a/src/main/java/org/gcube/informationsystem/types/impl/properties/PropertyDefinitionImpl.java +++ b/src/main/java/org/gcube/informationsystem/types/impl/properties/PropertyDefinitionImpl.java @@ -206,6 +206,12 @@ public final class PropertyDefinitionImpl implements PropertyDefinition { Objects.equals(propertyTypeName.toString(), other.propertyTypeName.toString()); } + protected int compareIntegers(Integer thisInt, Integer otherInt) { + Integer thisInteger = thisInt == null ? Integer.MAX_VALUE : thisInt; + Integer otherInteger = otherInt == null ? Integer.MAX_VALUE : otherInt; + return thisInteger.compareTo(otherInteger); + } + @Override public int compareTo(PropertyDefinition other) { if (this == other) { @@ -246,12 +252,12 @@ public final class PropertyDefinitionImpl implements PropertyDefinition { return ret; } - ret = max.compareTo(o.max); + ret = compareIntegers(max, o.max); if(ret != 0) { return ret; } - ret = min.compareTo(o.min); + ret = compareIntegers(min, o.min); if(ret != 0) { return ret; }