diff options
Diffstat (limited to 'subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/tuple/VolatileModifiableMaskedTuple.java')
-rw-r--r-- | subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/tuple/VolatileModifiableMaskedTuple.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/tuple/VolatileModifiableMaskedTuple.java b/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/tuple/VolatileModifiableMaskedTuple.java new file mode 100644 index 00000000..92306c6e --- /dev/null +++ b/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/tuple/VolatileModifiableMaskedTuple.java | |||
@@ -0,0 +1,47 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2010-2017, Zoltan Ujhelyi, IncQuery Labs 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 tools.refinery.viatra.runtime.matchers.util.Preconditions; | ||
12 | |||
13 | /** | ||
14 | * A masked tuple implementation that allows modifying the backing tuple. | ||
15 | * @author Zoltan Ujhelyi | ||
16 | * @since 1.7 | ||
17 | * | ||
18 | */ | ||
19 | public class VolatileModifiableMaskedTuple extends VolatileMaskedTuple implements IModifiableTuple { | ||
20 | |||
21 | private IModifiableTuple modifiableTuple; | ||
22 | |||
23 | public VolatileModifiableMaskedTuple(IModifiableTuple source, TupleMask mask) { | ||
24 | super(source, mask); | ||
25 | modifiableTuple = source; | ||
26 | } | ||
27 | |||
28 | public VolatileModifiableMaskedTuple(TupleMask mask) { | ||
29 | this(null, mask); | ||
30 | } | ||
31 | |||
32 | @Override | ||
33 | public void updateTuple(ITuple newSource) { | ||
34 | Preconditions.checkArgument(newSource instanceof IModifiableTuple, "Provided tuple does not support updates"); | ||
35 | this.updateTuple((IModifiableTuple)newSource); | ||
36 | } | ||
37 | |||
38 | public void updateTuple(IModifiableTuple newSource) { | ||
39 | super.updateTuple(newSource); | ||
40 | modifiableTuple = newSource; | ||
41 | } | ||
42 | |||
43 | @Override | ||
44 | public void set(int index, Object value) { | ||
45 | mask.set(modifiableTuple, index, value); | ||
46 | } | ||
47 | } | ||