|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 package com.nokia.s60tools.imaker.internal.iqrf.impl; |
|
18 |
|
19 |
|
20 import org.eclipse.emf.common.notify.Notification; |
|
21 import org.eclipse.emf.ecore.EClass; |
|
22 import org.eclipse.emf.ecore.InternalEObject; |
|
23 import org.eclipse.emf.ecore.impl.ENotificationImpl; |
|
24 import org.eclipse.emf.ecore.impl.EObjectImpl; |
|
25 |
|
26 import com.nokia.s60tools.imaker.internal.iqrf.ConfigurationElement; |
|
27 import com.nokia.s60tools.imaker.internal.iqrf.IQRFPackage; |
|
28 import com.nokia.s60tools.imaker.internal.iqrf.Setting; |
|
29 import com.nokia.s60tools.imaker.internal.iqrf.util.IQRFUtil; |
|
30 |
|
31 /** |
|
32 * <!-- begin-user-doc --> |
|
33 * An implementation of the model object '<em><b>Setting</b></em>'. |
|
34 * <!-- end-user-doc --> |
|
35 * <p> |
|
36 * The following features are implemented: |
|
37 * <ul> |
|
38 * <li>{@link com.nokia.s60tools.imaker.internal.iqrf.impl.SettingImpl#getName <em>Name</em>}</li> |
|
39 * <li>{@link com.nokia.s60tools.imaker.internal.iqrf.impl.SettingImpl#getValue <em>Value</em>}</li> |
|
40 * <li>{@link com.nokia.s60tools.imaker.internal.iqrf.impl.SettingImpl#getRef <em>Ref</em>}</li> |
|
41 * </ul> |
|
42 * </p> |
|
43 * |
|
44 * @generated |
|
45 */ |
|
46 public class SettingImpl extends EObjectImpl implements Setting { |
|
47 /** |
|
48 * The default value of the '{@link #getName() <em>Name</em>}' attribute. |
|
49 * <!-- begin-user-doc --> |
|
50 * <!-- end-user-doc --> |
|
51 * @see #getName() |
|
52 * @generated |
|
53 * @ordered |
|
54 */ |
|
55 protected static final String NAME_EDEFAULT = null; |
|
56 |
|
57 /** |
|
58 * The cached value of the '{@link #getName() <em>Name</em>}' attribute. |
|
59 * <!-- begin-user-doc --> |
|
60 * <!-- end-user-doc --> |
|
61 * @see #getName() |
|
62 * @generated |
|
63 * @ordered |
|
64 */ |
|
65 protected String name = NAME_EDEFAULT; |
|
66 |
|
67 /** |
|
68 * The default value of the '{@link #getValue() <em>Value</em>}' attribute. |
|
69 * <!-- begin-user-doc --> |
|
70 * <!-- end-user-doc --> |
|
71 * @see #getValue() |
|
72 * @generated |
|
73 * @ordered |
|
74 */ |
|
75 protected static final String VALUE_EDEFAULT = ""; |
|
76 |
|
77 /** |
|
78 * The cached value of the '{@link #getValue() <em>Value</em>}' attribute. |
|
79 * <!-- begin-user-doc --> |
|
80 * <!-- end-user-doc --> |
|
81 * @see #getValue() |
|
82 * @generated |
|
83 * @ordered |
|
84 */ |
|
85 protected String value = VALUE_EDEFAULT; |
|
86 |
|
87 /** |
|
88 * The cached value of the '{@link #getRef() <em>Ref</em>}' reference. |
|
89 * <!-- begin-user-doc --> |
|
90 * <!-- end-user-doc --> |
|
91 * @see #getRef() |
|
92 * @generated |
|
93 * @ordered |
|
94 */ |
|
95 protected ConfigurationElement ref = null; |
|
96 |
|
97 /** |
|
98 * <!-- begin-user-doc --> |
|
99 * <!-- end-user-doc --> |
|
100 * @generated |
|
101 */ |
|
102 protected SettingImpl() { |
|
103 super(); |
|
104 } |
|
105 |
|
106 /** |
|
107 * <!-- begin-user-doc --> |
|
108 * <!-- end-user-doc --> |
|
109 * @generated |
|
110 */ |
|
111 protected EClass eStaticClass() { |
|
112 return IQRFPackage.Literals.SETTING; |
|
113 } |
|
114 |
|
115 /** |
|
116 * <!-- begin-user-doc --> |
|
117 * <!-- end-user-doc --> |
|
118 * @generated |
|
119 */ |
|
120 public String getName() { |
|
121 return name; |
|
122 } |
|
123 |
|
124 /** |
|
125 * <!-- begin-user-doc --> |
|
126 * <!-- end-user-doc --> |
|
127 * @generated |
|
128 */ |
|
129 public void setName(String newName) { |
|
130 String oldName = name; |
|
131 name = newName; |
|
132 if (eNotificationRequired()) |
|
133 eNotify(new ENotificationImpl(this, Notification.SET, IQRFPackage.SETTING__NAME, oldName, name)); |
|
134 } |
|
135 |
|
136 /** |
|
137 * <!-- begin-user-doc --> |
|
138 * <!-- end-user-doc --> |
|
139 * @generated |
|
140 */ |
|
141 public String getValue() { |
|
142 return value; |
|
143 } |
|
144 |
|
145 /** |
|
146 * <!-- begin-user-doc --> |
|
147 * <!-- end-user-doc --> |
|
148 * @generated |
|
149 */ |
|
150 public void setValue(String newValue) { |
|
151 String oldValue = value; |
|
152 value = newValue; |
|
153 if (eNotificationRequired()) |
|
154 eNotify(new ENotificationImpl(this, Notification.SET, IQRFPackage.SETTING__VALUE, oldValue, value)); |
|
155 } |
|
156 |
|
157 /** |
|
158 * <!-- begin-user-doc --> |
|
159 * <!-- end-user-doc --> |
|
160 * @generated |
|
161 */ |
|
162 public ConfigurationElement getRef() { |
|
163 if (ref != null && ref.eIsProxy()) { |
|
164 InternalEObject oldRef = (InternalEObject)ref; |
|
165 ref = (ConfigurationElement)eResolveProxy(oldRef); |
|
166 if (ref != oldRef) { |
|
167 if (eNotificationRequired()) |
|
168 eNotify(new ENotificationImpl(this, Notification.RESOLVE, IQRFPackage.SETTING__REF, oldRef, ref)); |
|
169 } |
|
170 } |
|
171 return ref; |
|
172 } |
|
173 |
|
174 /** |
|
175 * <!-- begin-user-doc --> |
|
176 * <!-- end-user-doc --> |
|
177 * @generated |
|
178 */ |
|
179 public ConfigurationElement basicGetRef() { |
|
180 return ref; |
|
181 } |
|
182 |
|
183 /** |
|
184 * <!-- begin-user-doc --> |
|
185 * <!-- end-user-doc --> |
|
186 * @generated |
|
187 */ |
|
188 public void setRef(ConfigurationElement newRef) { |
|
189 ConfigurationElement oldRef = ref; |
|
190 ref = newRef; |
|
191 if (eNotificationRequired()) |
|
192 eNotify(new ENotificationImpl(this, Notification.SET, IQRFPackage.SETTING__REF, oldRef, ref)); |
|
193 } |
|
194 |
|
195 /** |
|
196 * <!-- begin-user-doc --> |
|
197 * <!-- end-user-doc --> |
|
198 * @generated NOT |
|
199 */ |
|
200 public void setConfigurationElement(ConfigurationElement element) { |
|
201 // Ensure that you remove @generated or mark it @generated NOT |
|
202 ref = element; |
|
203 //throw new UnsupportedOperationException(); |
|
204 } |
|
205 |
|
206 /** |
|
207 * <!-- begin-user-doc --> |
|
208 * <!-- end-user-doc --> |
|
209 * @generated |
|
210 */ |
|
211 public Object eGet(int featureID, boolean resolve, boolean coreType) { |
|
212 switch (featureID) { |
|
213 case IQRFPackage.SETTING__NAME: |
|
214 return getName(); |
|
215 case IQRFPackage.SETTING__VALUE: |
|
216 return getValue(); |
|
217 case IQRFPackage.SETTING__REF: |
|
218 if (resolve) return getRef(); |
|
219 return basicGetRef(); |
|
220 } |
|
221 return super.eGet(featureID, resolve, coreType); |
|
222 } |
|
223 |
|
224 /** |
|
225 * <!-- begin-user-doc --> |
|
226 * <!-- end-user-doc --> |
|
227 * @generated |
|
228 */ |
|
229 public void eSet(int featureID, Object newValue) { |
|
230 switch (featureID) { |
|
231 case IQRFPackage.SETTING__NAME: |
|
232 setName((String)newValue); |
|
233 return; |
|
234 case IQRFPackage.SETTING__VALUE: |
|
235 setValue((String)newValue); |
|
236 return; |
|
237 case IQRFPackage.SETTING__REF: |
|
238 setRef((ConfigurationElement)newValue); |
|
239 return; |
|
240 } |
|
241 super.eSet(featureID, newValue); |
|
242 } |
|
243 |
|
244 /** |
|
245 * <!-- begin-user-doc --> |
|
246 * <!-- end-user-doc --> |
|
247 * @generated |
|
248 */ |
|
249 public void eUnset(int featureID) { |
|
250 switch (featureID) { |
|
251 case IQRFPackage.SETTING__NAME: |
|
252 setName(NAME_EDEFAULT); |
|
253 return; |
|
254 case IQRFPackage.SETTING__VALUE: |
|
255 setValue(VALUE_EDEFAULT); |
|
256 return; |
|
257 case IQRFPackage.SETTING__REF: |
|
258 setRef((ConfigurationElement)null); |
|
259 return; |
|
260 } |
|
261 super.eUnset(featureID); |
|
262 } |
|
263 |
|
264 /** |
|
265 * <!-- begin-user-doc --> |
|
266 * <!-- end-user-doc --> |
|
267 * @generated |
|
268 */ |
|
269 public boolean eIsSet(int featureID) { |
|
270 switch (featureID) { |
|
271 case IQRFPackage.SETTING__NAME: |
|
272 return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); |
|
273 case IQRFPackage.SETTING__VALUE: |
|
274 return VALUE_EDEFAULT == null ? value != null : !VALUE_EDEFAULT.equals(value); |
|
275 case IQRFPackage.SETTING__REF: |
|
276 return ref != null; |
|
277 } |
|
278 return super.eIsSet(featureID); |
|
279 } |
|
280 |
|
281 /** |
|
282 * <!-- begin-user-doc --> |
|
283 * <!-- end-user-doc --> |
|
284 * @generated |
|
285 */ |
|
286 public String toString() { |
|
287 if (eIsProxy()) return super.toString(); |
|
288 |
|
289 StringBuffer result = new StringBuffer(super.toString()); |
|
290 result.append(" (name: "); |
|
291 result.append(name); |
|
292 result.append(", value: "); |
|
293 result.append(value); |
|
294 result.append(')'); |
|
295 return result.toString(); |
|
296 } |
|
297 |
|
298 public boolean equals(Object object) { |
|
299 if(object==null || !(object instanceof Setting)) return false; |
|
300 Setting other = (Setting)object; |
|
301 boolean self = IQRFUtil.equals(getName(),other.getName()) && |
|
302 IQRFUtil.equals(getValue(),other.getValue()); |
|
303 if(!self) return false; |
|
304 boolean ret = (getRef()==null) ? (other.getRef()==null):getRef().equals(other.getRef()); |
|
305 return ret; |
|
306 } |
|
307 |
|
308 @Override |
|
309 public int hashCode() { |
|
310 final int hashMultiplier = 41; |
|
311 int result = 7; |
|
312 result=result*hashMultiplier + getName().hashCode(); |
|
313 result=result*hashMultiplier + getValue().hashCode(); |
|
314 return result; |
|
315 } |
|
316 } //SettingImpl |