Fixed compareTo

This commit is contained in:
Luca Frosini 2023-01-24 17:21:09 +01:00
parent 71ad29c9ce
commit b36310c650
2 changed files with 15 additions and 4 deletions

View File

@ -117,6 +117,11 @@ public final class LinkedEntityImpl extends PropertyElementImpl implements Linke
Objects.equals(description, other.description); 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 @Override
public int compareTo(LinkedEntity other) { public int compareTo(LinkedEntity other) {
@ -148,12 +153,12 @@ public final class LinkedEntityImpl extends PropertyElementImpl implements Linke
return ret; return ret;
} }
ret = max.compareTo(o.max); ret = compareIntegers(max, o.max);
if(ret != 0) { if(ret != 0) {
return ret; return ret;
} }
ret = min.compareTo(o.min); ret = compareIntegers(min, o.min);
if(ret != 0) { if(ret != 0) {
return ret; return ret;
} }

View File

@ -206,6 +206,12 @@ public final class PropertyDefinitionImpl implements PropertyDefinition {
Objects.equals(propertyTypeName.toString(), other.propertyTypeName.toString()); 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 @Override
public int compareTo(PropertyDefinition other) { public int compareTo(PropertyDefinition other) {
if (this == other) { if (this == other) {
@ -246,12 +252,12 @@ public final class PropertyDefinitionImpl implements PropertyDefinition {
return ret; return ret;
} }
ret = max.compareTo(o.max); ret = compareIntegers(max, o.max);
if(ret != 0) { if(ret != 0) {
return ret; return ret;
} }
ret = min.compareTo(o.min); ret = compareIntegers(min, o.min);
if(ret != 0) { if(ret != 0) {
return ret; return ret;
} }