1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.qedeq.kernel.bo.logic.model;
17
18 import org.qedeq.base.utility.Enumerator;
19 import org.qedeq.kernel.bo.logic.common.SubjectVariable;
20
21
22
23
24
25
26 public class SubjectVariableAllocation {
27
28
29 private final SubjectVariable variable;
30
31
32 private final Enumerator value;
33
34
35 private boolean fixed;
36
37
38
39
40
41
42 public SubjectVariableAllocation(final SubjectVariable variable) {
43 this.variable = variable;
44 this.value = new Enumerator();
45 this.fixed = false;
46 }
47
48
49
50
51
52
53
54 public SubjectVariableAllocation(final SubjectVariable variable, final int value) {
55 this.variable = variable;
56 this.value = new Enumerator(value);
57 this.fixed = true;
58 }
59
60
61
62
63
64
65 public SubjectVariable getVariable() {
66 return variable;
67 }
68
69
70
71
72
73
74 public boolean isFixed() {
75 return fixed;
76 }
77
78
79
80
81
82
83 public int getValue() {
84 return value.getNumber();
85 }
86
87
88
89
90 public void increaseNumber() {
91 if (fixed) {
92 throw new IllegalStateException("variable could not iterate: " + toString());
93 }
94 value.increaseNumber();
95 }
96
97
98
99
100 public void resetNumber() {
101 if (fixed) {
102 throw new IllegalStateException("variable could not iterate: " + toString());
103 }
104 value.reset();
105 }
106
107 public String toString() {
108 return variable.toString() + "=" + value.getNumber();
109 }
110
111 }