diff options
Diffstat (limited to 'subprojects/store')
-rw-r--r-- | subprojects/store/src/main/java/tools/refinery/store/tuple/TupleLike.java | 10 | ||||
-rw-r--r-- | subprojects/store/src/main/java/tools/refinery/store/tuple/TupleN.java | 4 |
2 files changed, 11 insertions, 3 deletions
diff --git a/subprojects/store/src/main/java/tools/refinery/store/tuple/TupleLike.java b/subprojects/store/src/main/java/tools/refinery/store/tuple/TupleLike.java index 470ca298..953ea9f8 100644 --- a/subprojects/store/src/main/java/tools/refinery/store/tuple/TupleLike.java +++ b/subprojects/store/src/main/java/tools/refinery/store/tuple/TupleLike.java | |||
@@ -1,5 +1,8 @@ | |||
1 | package tools.refinery.store.tuple; | 1 | package tools.refinery.store.tuple; |
2 | 2 | ||
3 | import java.util.stream.Collectors; | ||
4 | import java.util.stream.IntStream; | ||
5 | |||
3 | public interface TupleLike { | 6 | public interface TupleLike { |
4 | int getSize(); | 7 | int getSize(); |
5 | 8 | ||
@@ -22,4 +25,11 @@ public interface TupleLike { | |||
22 | default -> Tuple.of(toArray()); | 25 | default -> Tuple.of(toArray()); |
23 | }; | 26 | }; |
24 | } | 27 | } |
28 | |||
29 | static String toString(TupleLike tuple) { | ||
30 | var valuesString = IntStream.range(0, tuple.getSize()) | ||
31 | .mapToObj(i -> Integer.toString(tuple.get(i))) | ||
32 | .collect(Collectors.joining(", ")); | ||
33 | return "[" + valuesString + "]"; | ||
34 | } | ||
25 | } | 35 | } |
diff --git a/subprojects/store/src/main/java/tools/refinery/store/tuple/TupleN.java b/subprojects/store/src/main/java/tools/refinery/store/tuple/TupleN.java index 15fd063b..c3aed847 100644 --- a/subprojects/store/src/main/java/tools/refinery/store/tuple/TupleN.java +++ b/subprojects/store/src/main/java/tools/refinery/store/tuple/TupleN.java | |||
@@ -1,7 +1,6 @@ | |||
1 | package tools.refinery.store.tuple; | 1 | package tools.refinery.store.tuple; |
2 | 2 | ||
3 | import java.util.Arrays; | 3 | import java.util.Arrays; |
4 | import java.util.stream.Collectors; | ||
5 | 4 | ||
6 | public record TupleN(int[] values) implements Tuple { | 5 | public record TupleN(int[] values) implements Tuple { |
7 | static final int CUSTOM_TUPLE_SIZE = 2; | 6 | static final int CUSTOM_TUPLE_SIZE = 2; |
@@ -29,8 +28,7 @@ public record TupleN(int[] values) implements Tuple { | |||
29 | 28 | ||
30 | @Override | 29 | @Override |
31 | public String toString() { | 30 | public String toString() { |
32 | var valuesString = Arrays.stream(values).mapToObj(Integer::toString).collect(Collectors.joining(", ")); | 31 | return TupleLike.toString(this); |
33 | return "[" + valuesString + "]"; | ||
34 | } | 32 | } |
35 | 33 | ||
36 | @Override | 34 | @Override |