blob: d9ba21b3139d8d67238983c4d0191422d09b3354 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
/*******************************************************************************
* Copyright (c) 2013, 2016 Willink Transformations and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* E.D.Willink - Initial API and implementation
*******************************************************************************/
package org.eclipse.qvtd.runtime.evaluation;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNull;
/**
* The abstract implementation of a SlotState provides the mandatory shared functionality for maintaining
* the state of an object slot.
*/
public abstract class AbstractSlotState implements SlotState
{
public abstract static class Incremental extends AbstractSlotState implements SlotState.Incremental
{
public static final @NonNull List<Invocation.@NonNull Incremental> EMPTY_INVOCATIONS_LIST = Collections.emptyList();
private Set<Invocation.@NonNull Incremental> sources = null;
private Set<Invocation.@NonNull Incremental> targets = null;
@Override
public void addSourceInternal(Invocation.@NonNull Incremental invocation) {
if (sources == null) {
sources = new HashSet<Invocation.@NonNull Incremental>();
}
sources.add(invocation);
}
@Override
public void addTargetInternal(Invocation.@NonNull Incremental invocation) {
if (targets == null) {
targets = new HashSet<Invocation.@NonNull Incremental>();
}
targets.add(invocation);
}
@Override
public @NonNull Iterable<Invocation.@NonNull Incremental> getSources() {
return sources != null ? sources : EMPTY_INVOCATIONS_LIST;
}
@Override
public @NonNull Iterable<Invocation.@NonNull Incremental> getTargets() {
return targets != null ? targets : EMPTY_INVOCATIONS_LIST;
}
}
@Override
public <R> R accept(@NonNull ExecutionVisitor<R> visitor) {
return visitor.visitSlotState(this);
}
}
|