diff options
Diffstat (limited to 'Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/statecoding/StatecodingNode.java')
-rw-r--r-- | Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/statecoding/StatecodingNode.java | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/statecoding/StatecodingNode.java b/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/statecoding/StatecodingNode.java new file mode 100644 index 00000000..91fc28cf --- /dev/null +++ b/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/statecoding/StatecodingNode.java | |||
@@ -0,0 +1,100 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2010-2015, Andras Szabolcs Nagy and Daniel Varro | ||
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 org.eclipse.viatra.dse.statecoding; | ||
10 | |||
11 | import java.util.ArrayList; | ||
12 | import java.util.Comparator; | ||
13 | import java.util.List; | ||
14 | import java.util.Set; | ||
15 | import java.util.TreeSet; | ||
16 | |||
17 | import org.eclipse.emf.ecore.EAttribute; | ||
18 | import org.eclipse.emf.ecore.EClass; | ||
19 | import org.eclipse.emf.ecore.EReference; | ||
20 | |||
21 | public class StatecodingNode { | ||
22 | |||
23 | private StatecodingDependencyGraph graph; | ||
24 | |||
25 | private final EClass clazz; | ||
26 | private Set<EAttribute> attributes = new TreeSet<EAttribute>(Comparator.comparing(EAttribute::getName)); | ||
27 | private List<StatecodingDependency> dependencies = new ArrayList<StatecodingDependency>(); | ||
28 | private boolean stateCodeIsId = false; | ||
29 | private StatecodingNodeType statecodingNodeType = StatecodingNodeType.CREATE_AND_DELETE; | ||
30 | |||
31 | public StatecodingNode(EClass clazz) { | ||
32 | this.clazz = clazz; | ||
33 | } | ||
34 | |||
35 | public StatecodingNode withAttribute(EAttribute attribute) { | ||
36 | attributes.add(attribute); | ||
37 | return this; | ||
38 | } | ||
39 | |||
40 | public StatecodingNode withType(StatecodingNodeType type) { | ||
41 | statecodingNodeType = type; | ||
42 | return this; | ||
43 | } | ||
44 | |||
45 | public StatecodingNode withUniqueness() { | ||
46 | stateCodeIsId = true; | ||
47 | return this; | ||
48 | } | ||
49 | |||
50 | public StatecodingNode withDependency(EReference reference, StatecodingNode node) { | ||
51 | dependencies.add(new StatecodingDependency(reference, node)); | ||
52 | return this; | ||
53 | } | ||
54 | |||
55 | public StatecodingNode withInverseDependency(EReference reference, StatecodingNode node) { | ||
56 | dependencies.add(new StatecodingDependency(reference, node, false, StatecodingDependencyType.INVERSE)); | ||
57 | return this; | ||
58 | } | ||
59 | |||
60 | public void addDependency(StatecodingDependency statecodingDependency) { | ||
61 | dependencies.add(statecodingDependency); | ||
62 | } | ||
63 | |||
64 | public EClass getClazz() { | ||
65 | return clazz; | ||
66 | } | ||
67 | |||
68 | public boolean isStateCodeIsId() { | ||
69 | return stateCodeIsId; | ||
70 | } | ||
71 | |||
72 | public void setStateCodeIsId(boolean stateCodeIsId) { | ||
73 | this.stateCodeIsId = stateCodeIsId; | ||
74 | } | ||
75 | |||
76 | public StatecodingNodeType getStatecodingNodeType() { | ||
77 | return statecodingNodeType; | ||
78 | } | ||
79 | |||
80 | public void setStatecodingNodeType(StatecodingNodeType statecodingNodeType) { | ||
81 | this.statecodingNodeType = statecodingNodeType; | ||
82 | } | ||
83 | |||
84 | public Set<EAttribute> getAttributes() { | ||
85 | return attributes; | ||
86 | } | ||
87 | |||
88 | public List<StatecodingDependency> getStatecodingDependencies() { | ||
89 | return dependencies; | ||
90 | } | ||
91 | |||
92 | public StatecodingDependencyGraph getGraph() { | ||
93 | return graph; | ||
94 | } | ||
95 | |||
96 | public void setGraph(StatecodingDependencyGraph graph) { | ||
97 | this.graph = graph; | ||
98 | } | ||
99 | |||
100 | } | ||