1
2
3
4
5
6
7 package org.mod4j.dsl.datacontract.mm.DataContractDsl.impl;
8
9 import org.eclipse.emf.common.notify.Notification;
10
11 import org.eclipse.emf.ecore.EClass;
12 import org.eclipse.emf.ecore.InternalEObject;
13
14 import org.eclipse.emf.ecore.impl.ENotificationImpl;
15
16 import org.mod4j.dsl.datacontract.mm.DataContractDsl.DataContractDslPackage;
17 import org.mod4j.dsl.datacontract.mm.DataContractDsl.DtoEnumerationProperty;
18 import org.mod4j.dsl.datacontract.mm.DataContractDsl.EnumerationDto;
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 public class DtoEnumerationPropertyImpl extends DtoDataPropertyImpl implements DtoEnumerationProperty {
35
36
37
38
39
40
41
42
43 protected EnumerationDto type;
44
45
46
47
48
49
50
51
52
53 protected static final String DEFAULT_VALUE_AS_STRING_EDEFAULT = null;
54
55
56
57
58
59
60
61
62 protected String defaultValueAsString = DEFAULT_VALUE_AS_STRING_EDEFAULT;
63
64
65
66
67
68
69 protected DtoEnumerationPropertyImpl() {
70 super();
71 }
72
73
74
75
76
77
78 @Override
79 protected EClass eStaticClass() {
80 return DataContractDslPackage.Literals.DTO_ENUMERATION_PROPERTY;
81 }
82
83
84
85
86
87
88 public EnumerationDto getType() {
89 if (type != null && type.eIsProxy()) {
90 InternalEObject oldType = (InternalEObject)type;
91 type = (EnumerationDto)eResolveProxy(oldType);
92 if (type != oldType) {
93 if (eNotificationRequired())
94 eNotify(new ENotificationImpl(this, Notification.RESOLVE, DataContractDslPackage.DTO_ENUMERATION_PROPERTY__TYPE, oldType, type));
95 }
96 }
97 return type;
98 }
99
100
101
102
103
104
105 public EnumerationDto basicGetType() {
106 return type;
107 }
108
109
110
111
112
113
114 public void setType(EnumerationDto newType) {
115 EnumerationDto oldType = type;
116 type = newType;
117 if (eNotificationRequired())
118 eNotify(new ENotificationImpl(this, Notification.SET, DataContractDslPackage.DTO_ENUMERATION_PROPERTY__TYPE, oldType, type));
119 }
120
121
122
123
124
125
126 public String getDefaultValueAsString() {
127 return defaultValueAsString;
128 }
129
130
131
132
133
134
135 public void setDefaultValueAsString(String newDefaultValueAsString) {
136 String oldDefaultValueAsString = defaultValueAsString;
137 defaultValueAsString = newDefaultValueAsString;
138 if (eNotificationRequired())
139 eNotify(new ENotificationImpl(this, Notification.SET, DataContractDslPackage.DTO_ENUMERATION_PROPERTY__DEFAULT_VALUE_AS_STRING, oldDefaultValueAsString, defaultValueAsString));
140 }
141
142
143
144
145
146
147 @Override
148 public Object eGet(int featureID, boolean resolve, boolean coreType) {
149 switch (featureID) {
150 case DataContractDslPackage.DTO_ENUMERATION_PROPERTY__TYPE:
151 if (resolve) return getType();
152 return basicGetType();
153 case DataContractDslPackage.DTO_ENUMERATION_PROPERTY__DEFAULT_VALUE_AS_STRING:
154 return getDefaultValueAsString();
155 }
156 return super.eGet(featureID, resolve, coreType);
157 }
158
159
160
161
162
163
164 @Override
165 public void eSet(int featureID, Object newValue) {
166 switch (featureID) {
167 case DataContractDslPackage.DTO_ENUMERATION_PROPERTY__TYPE:
168 setType((EnumerationDto)newValue);
169 return;
170 case DataContractDslPackage.DTO_ENUMERATION_PROPERTY__DEFAULT_VALUE_AS_STRING:
171 setDefaultValueAsString((String)newValue);
172 return;
173 }
174 super.eSet(featureID, newValue);
175 }
176
177
178
179
180
181
182 @Override
183 public void eUnset(int featureID) {
184 switch (featureID) {
185 case DataContractDslPackage.DTO_ENUMERATION_PROPERTY__TYPE:
186 setType((EnumerationDto)null);
187 return;
188 case DataContractDslPackage.DTO_ENUMERATION_PROPERTY__DEFAULT_VALUE_AS_STRING:
189 setDefaultValueAsString(DEFAULT_VALUE_AS_STRING_EDEFAULT);
190 return;
191 }
192 super.eUnset(featureID);
193 }
194
195
196
197
198
199
200 @Override
201 public boolean eIsSet(int featureID) {
202 switch (featureID) {
203 case DataContractDslPackage.DTO_ENUMERATION_PROPERTY__TYPE:
204 return type != null;
205 case DataContractDslPackage.DTO_ENUMERATION_PROPERTY__DEFAULT_VALUE_AS_STRING:
206 return DEFAULT_VALUE_AS_STRING_EDEFAULT == null ? defaultValueAsString != null : !DEFAULT_VALUE_AS_STRING_EDEFAULT.equals(defaultValueAsString);
207 }
208 return super.eIsSet(featureID);
209 }
210
211
212
213
214
215
216 @Override
217 public String toString() {
218 if (eIsProxy()) return super.toString();
219
220 StringBuffer result = new StringBuffer(super.toString());
221 result.append(" (defaultValueAsString: ");
222 result.append(defaultValueAsString);
223 result.append(')');
224 return result.toString();
225 }
226
227 }