diff options
Diffstat (limited to 'subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/tuple/FlatTuple1.java')
-rw-r--r-- | subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/tuple/FlatTuple1.java | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/tuple/FlatTuple1.java b/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/tuple/FlatTuple1.java new file mode 100644 index 00000000..b3b1c312 --- /dev/null +++ b/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/tuple/FlatTuple1.java | |||
@@ -0,0 +1,44 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2010-2017, Gabor Bergmann, IncQueryLabs Ltd. | ||
3 | * This program and the accompanying materials are made available under the | ||
4 | * terms of the Eclipse Public License v. 2.0 which is available at | ||
5 | * http://www.eclipse.org/legal/epl-v20.html. | ||
6 | * | ||
7 | * SPDX-License-Identifier: EPL-2.0 | ||
8 | *******************************************************************************/ | ||
9 | package tools.refinery.viatra.runtime.matchers.tuple; | ||
10 | |||
11 | import java.util.Objects; | ||
12 | |||
13 | /** | ||
14 | * Flat tuple with statically known arity of 1. | ||
15 | * | ||
16 | * @author Gabor Bergmann | ||
17 | * @since 1.7 | ||
18 | * | ||
19 | */ | ||
20 | public final class FlatTuple1 extends BaseFlatTuple { | ||
21 | private final Object element0; | ||
22 | |||
23 | protected FlatTuple1(Object element0) { | ||
24 | this.element0 = element0; | ||
25 | calcHash(); | ||
26 | } | ||
27 | |||
28 | @Override | ||
29 | public int getSize() { | ||
30 | return 1; | ||
31 | } | ||
32 | |||
33 | @Override | ||
34 | public Object get(int index) { | ||
35 | if (index == 0) return element0; | ||
36 | else throw raiseIndexingError(index); | ||
37 | } | ||
38 | |||
39 | @Override | ||
40 | protected boolean internalEquals(ITuple other) { | ||
41 | return 1 == other.getSize() && | ||
42 | Objects.equals(element0, other.get(0)); | ||
43 | } | ||
44 | } | ||