diff options
Diffstat (limited to 'subprojects/store')
3 files changed, 37 insertions, 0 deletions
diff --git a/subprojects/store/src/main/java/tools/refinery/store/representation/cardinality/FiniteUpperCardinality.java b/subprojects/store/src/main/java/tools/refinery/store/representation/cardinality/FiniteUpperCardinality.java index 088e3925..b63a8637 100644 --- a/subprojects/store/src/main/java/tools/refinery/store/representation/cardinality/FiniteUpperCardinality.java +++ b/subprojects/store/src/main/java/tools/refinery/store/representation/cardinality/FiniteUpperCardinality.java | |||
@@ -67,4 +67,17 @@ public record FiniteUpperCardinality(int finiteUpperBound) implements UpperCardi | |||
67 | } | 67 | } |
68 | throw new IllegalArgumentException("Unknown UpperCardinality: " + other); | 68 | throw new IllegalArgumentException("Unknown UpperCardinality: " + other); |
69 | } | 69 | } |
70 | |||
71 | @Override | ||
72 | public boolean equals(Object o) { | ||
73 | if (this == o) return true; | ||
74 | if (o == null || getClass() != o.getClass()) return false; | ||
75 | FiniteUpperCardinality that = (FiniteUpperCardinality) o; | ||
76 | return finiteUpperBound == that.finiteUpperBound; | ||
77 | } | ||
78 | |||
79 | @Override | ||
80 | public int hashCode() { | ||
81 | return finiteUpperBound; | ||
82 | } | ||
70 | } | 83 | } |
diff --git a/subprojects/store/src/main/java/tools/refinery/store/representation/cardinality/NonEmptyCardinalityInterval.java b/subprojects/store/src/main/java/tools/refinery/store/representation/cardinality/NonEmptyCardinalityInterval.java index bfaeea25..6bd66df7 100644 --- a/subprojects/store/src/main/java/tools/refinery/store/representation/cardinality/NonEmptyCardinalityInterval.java +++ b/subprojects/store/src/main/java/tools/refinery/store/representation/cardinality/NonEmptyCardinalityInterval.java | |||
@@ -5,6 +5,7 @@ | |||
5 | */ | 5 | */ |
6 | package tools.refinery.store.representation.cardinality; | 6 | package tools.refinery.store.representation.cardinality; |
7 | 7 | ||
8 | import java.util.Objects; | ||
8 | import java.util.function.BinaryOperator; | 9 | import java.util.function.BinaryOperator; |
9 | import java.util.function.IntBinaryOperator; | 10 | import java.util.function.IntBinaryOperator; |
10 | 11 | ||
@@ -89,4 +90,17 @@ public record NonEmptyCardinalityInterval(int lowerBound, UpperCardinality upper | |||
89 | } | 90 | } |
90 | return "[%d..%s]".formatted(lowerBound, upperBound); | 91 | return "[%d..%s]".formatted(lowerBound, upperBound); |
91 | } | 92 | } |
93 | |||
94 | @Override | ||
95 | public boolean equals(Object o) { | ||
96 | if (this == o) return true; | ||
97 | if (o == null || getClass() != o.getClass()) return false; | ||
98 | NonEmptyCardinalityInterval that = (NonEmptyCardinalityInterval) o; | ||
99 | return lowerBound == that.lowerBound && Objects.equals(upperBound, that.upperBound); | ||
100 | } | ||
101 | |||
102 | @Override | ||
103 | public int hashCode() { | ||
104 | return lowerBound * 31 + upperBound.hashCode(); | ||
105 | } | ||
92 | } | 106 | } |
diff --git a/subprojects/store/src/main/java/tools/refinery/store/representation/cardinality/UnboundedUpperCardinality.java b/subprojects/store/src/main/java/tools/refinery/store/representation/cardinality/UnboundedUpperCardinality.java index e3a334cd..03c701ae 100644 --- a/subprojects/store/src/main/java/tools/refinery/store/representation/cardinality/UnboundedUpperCardinality.java +++ b/subprojects/store/src/main/java/tools/refinery/store/representation/cardinality/UnboundedUpperCardinality.java | |||
@@ -53,4 +53,14 @@ public final class UnboundedUpperCardinality implements UpperCardinality { | |||
53 | public String toString() { | 53 | public String toString() { |
54 | return "*"; | 54 | return "*"; |
55 | } | 55 | } |
56 | |||
57 | @Override | ||
58 | public boolean equals(Object obj) { | ||
59 | return this == obj || (obj != null && getClass() == obj.getClass()); | ||
60 | } | ||
61 | |||
62 | @Override | ||
63 | public int hashCode() { | ||
64 | return -1; | ||
65 | } | ||
56 | } | 66 | } |