imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/internal/iqrf/impl/ResultImpl.java
changeset 0 61163b28edca
equal deleted inserted replaced
-1:000000000000 0:61163b28edca
       
     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 java.util.Collection;
       
    21 import java.util.Iterator;
       
    22 
       
    23 import org.eclipse.emf.common.notify.NotificationChain;
       
    24 import org.eclipse.emf.common.util.EList;
       
    25 import org.eclipse.emf.ecore.EClass;
       
    26 import org.eclipse.emf.ecore.InternalEObject;
       
    27 import org.eclipse.emf.ecore.impl.EObjectImpl;
       
    28 import org.eclipse.emf.ecore.util.EObjectContainmentEList;
       
    29 import org.eclipse.emf.ecore.util.InternalEList;
       
    30 
       
    31 import com.nokia.s60tools.imaker.internal.iqrf.Configuration;
       
    32 import com.nokia.s60tools.imaker.internal.iqrf.IQRFPackage;
       
    33 import com.nokia.s60tools.imaker.internal.iqrf.Interface;
       
    34 import com.nokia.s60tools.imaker.internal.iqrf.Result;
       
    35 import com.nokia.s60tools.imaker.internal.iqrf.Target;
       
    36 
       
    37 /**
       
    38  * <!-- begin-user-doc -->
       
    39  * An implementation of the model object '<em><b>Result</b></em>'.
       
    40  * <!-- end-user-doc -->
       
    41  * <p>
       
    42  * The following features are implemented:
       
    43  * <ul>
       
    44  *   <li>{@link com.nokia.s60tools.imaker.internal.iqrf.impl.ResultImpl#getInterfaces <em>Interfaces</em>}</li>
       
    45  *   <li>{@link com.nokia.s60tools.imaker.internal.iqrf.impl.ResultImpl#getConfigurations <em>Configurations</em>}</li>
       
    46  *   <li>{@link com.nokia.s60tools.imaker.internal.iqrf.impl.ResultImpl#getTargets <em>Targets</em>}</li>
       
    47  * </ul>
       
    48  * </p>
       
    49  *
       
    50  * @generated
       
    51  */
       
    52 public class ResultImpl extends EObjectImpl implements Result {
       
    53 	/**
       
    54 	 * The cached value of the '{@link #getInterfaces() <em>Interfaces</em>}' containment reference list.
       
    55 	 * <!-- begin-user-doc -->
       
    56 	 * <!-- end-user-doc -->
       
    57 	 * @see #getInterfaces()
       
    58 	 * @generated
       
    59 	 * @ordered
       
    60 	 */
       
    61 	protected EList interfaces = null;
       
    62 
       
    63 	/**
       
    64 	 * The cached value of the '{@link #getConfigurations() <em>Configurations</em>}' containment reference list.
       
    65 	 * <!-- begin-user-doc -->
       
    66 	 * <!-- end-user-doc -->
       
    67 	 * @see #getConfigurations()
       
    68 	 * @generated
       
    69 	 * @ordered
       
    70 	 */
       
    71 	protected EList configurations = null;
       
    72 
       
    73 	/**
       
    74 	 * The cached value of the '{@link #getTargets() <em>Targets</em>}' containment reference list.
       
    75 	 * <!-- begin-user-doc -->
       
    76 	 * <!-- end-user-doc -->
       
    77 	 * @see #getTargets()
       
    78 	 * @generated
       
    79 	 * @ordered
       
    80 	 */
       
    81 	protected EList targets = null;
       
    82 
       
    83 	/**
       
    84 	 * <!-- begin-user-doc -->
       
    85 	 * <!-- end-user-doc -->
       
    86 	 * @generated
       
    87 	 */
       
    88 	protected ResultImpl() {
       
    89 		super();
       
    90 	}
       
    91 
       
    92 	/**
       
    93 	 * <!-- begin-user-doc -->
       
    94 	 * <!-- end-user-doc -->
       
    95 	 * @generated
       
    96 	 */
       
    97 	protected EClass eStaticClass() {
       
    98 		return IQRFPackage.Literals.RESULT;
       
    99 	}
       
   100 
       
   101 	/**
       
   102 	 * <!-- begin-user-doc -->
       
   103 	 * <!-- end-user-doc -->
       
   104 	 * @generated
       
   105 	 */
       
   106 	public EList getInterfaces() {
       
   107 		if (interfaces == null) {
       
   108 			interfaces = new EObjectContainmentEList(Interface.class, this, IQRFPackage.RESULT__INTERFACES);
       
   109 		}
       
   110 		return interfaces;
       
   111 	}
       
   112 
       
   113 	/**
       
   114 	 * <!-- begin-user-doc -->
       
   115 	 * <!-- end-user-doc -->
       
   116 	 * @generated
       
   117 	 */
       
   118 	public EList getConfigurations() {
       
   119 		if (configurations == null) {
       
   120 			configurations = new EObjectContainmentEList(Configuration.class, this, IQRFPackage.RESULT__CONFIGURATIONS);
       
   121 		}
       
   122 		return configurations;
       
   123 	}
       
   124 
       
   125 	/**
       
   126 	 * <!-- begin-user-doc -->
       
   127 	 * <!-- end-user-doc -->
       
   128 	 * @generated
       
   129 	 */
       
   130 	public EList getTargets() {
       
   131 		if (targets == null) {
       
   132 			targets = new EObjectContainmentEList(Target.class, this, IQRFPackage.RESULT__TARGETS);
       
   133 		}
       
   134 		return targets;
       
   135 	}
       
   136 
       
   137 	/**
       
   138 	 * <!-- begin-user-doc -->
       
   139 	 * <!-- end-user-doc -->
       
   140 	 * @generated NOT
       
   141 	 */
       
   142 	@SuppressWarnings("unchecked")
       
   143 	public void addConfiguration(Configuration config) {
       
   144 		// Ensure that you remove @generated or mark it @generated NOT
       
   145 		if (configurations == null) {
       
   146 			configurations = new EObjectContainmentEList(Configuration.class, this, IQRFPackage.RESULT__CONFIGURATIONS);
       
   147 		}
       
   148 		configurations.add(config);
       
   149 		//throw new UnsupportedOperationException();
       
   150 	}
       
   151 
       
   152 	/**
       
   153 	 * <!-- begin-user-doc -->
       
   154 	 * <!-- end-user-doc -->
       
   155 	 * @generated NOT
       
   156 	 */
       
   157 	@SuppressWarnings("unchecked")
       
   158 	public void addInterface(Interface intf) {
       
   159 		// Ensure that you remove @generated or mark it @generated NOT
       
   160 		if (interfaces == null) {
       
   161 			interfaces = new EObjectContainmentEList(Interface.class, this, IQRFPackage.RESULT__INTERFACES);
       
   162 		}
       
   163 		interfaces.add(intf);
       
   164 		//throw new UnsupportedOperationException();
       
   165 	}
       
   166 
       
   167 	/**
       
   168 	 * <!-- begin-user-doc -->
       
   169 	 * <!-- end-user-doc -->
       
   170 	 * @generated NOT
       
   171 	 */
       
   172 	@SuppressWarnings("unchecked")
       
   173 	public void addTarget(Target target) {
       
   174 		// Ensure that you remove @generated or mark it @generated NOT
       
   175 		if (this.targets == null) {
       
   176 			this.targets = new EObjectContainmentEList(Target.class, this, IQRFPackage.RESULT__TARGETS);
       
   177 		}
       
   178 		this.targets.add(target);
       
   179 		//throw new UnsupportedOperationException();
       
   180 	}
       
   181 
       
   182 	/**
       
   183 	 * <!-- begin-user-doc -->
       
   184 	 * <!-- end-user-doc -->
       
   185 	 * @generated
       
   186 	 */
       
   187 	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
       
   188 		switch (featureID) {
       
   189 			case IQRFPackage.RESULT__INTERFACES:
       
   190 				return ((InternalEList)getInterfaces()).basicRemove(otherEnd, msgs);
       
   191 			case IQRFPackage.RESULT__CONFIGURATIONS:
       
   192 				return ((InternalEList)getConfigurations()).basicRemove(otherEnd, msgs);
       
   193 			case IQRFPackage.RESULT__TARGETS:
       
   194 				return ((InternalEList)getTargets()).basicRemove(otherEnd, msgs);
       
   195 		}
       
   196 		return super.eInverseRemove(otherEnd, featureID, msgs);
       
   197 	}
       
   198 
       
   199 	/**
       
   200 	 * <!-- begin-user-doc -->
       
   201 	 * <!-- end-user-doc -->
       
   202 	 * @generated
       
   203 	 */
       
   204 	public Object eGet(int featureID, boolean resolve, boolean coreType) {
       
   205 		switch (featureID) {
       
   206 			case IQRFPackage.RESULT__INTERFACES:
       
   207 				return getInterfaces();
       
   208 			case IQRFPackage.RESULT__CONFIGURATIONS:
       
   209 				return getConfigurations();
       
   210 			case IQRFPackage.RESULT__TARGETS:
       
   211 				return getTargets();
       
   212 		}
       
   213 		return super.eGet(featureID, resolve, coreType);
       
   214 	}
       
   215 
       
   216 	/**
       
   217 	 * <!-- begin-user-doc -->
       
   218 	 * <!-- end-user-doc -->
       
   219 	 * @generated
       
   220 	 */
       
   221 	@SuppressWarnings("unchecked")
       
   222 	public void eSet(int featureID, Object newValue) {
       
   223 		switch (featureID) {
       
   224 			case IQRFPackage.RESULT__INTERFACES:
       
   225 				getInterfaces().clear();
       
   226 				getInterfaces().addAll((Collection)newValue);
       
   227 				return;
       
   228 			case IQRFPackage.RESULT__CONFIGURATIONS:
       
   229 				getConfigurations().clear();
       
   230 				getConfigurations().addAll((Collection)newValue);
       
   231 				return;
       
   232 			case IQRFPackage.RESULT__TARGETS:
       
   233 				getTargets().clear();
       
   234 				getTargets().addAll((Collection)newValue);
       
   235 				return;
       
   236 		}
       
   237 		super.eSet(featureID, newValue);
       
   238 	}
       
   239 
       
   240 	/**
       
   241 	 * <!-- begin-user-doc -->
       
   242 	 * <!-- end-user-doc -->
       
   243 	 * @generated
       
   244 	 */
       
   245 	public void eUnset(int featureID) {
       
   246 		switch (featureID) {
       
   247 			case IQRFPackage.RESULT__INTERFACES:
       
   248 				getInterfaces().clear();
       
   249 				return;
       
   250 			case IQRFPackage.RESULT__CONFIGURATIONS:
       
   251 				getConfigurations().clear();
       
   252 				return;
       
   253 			case IQRFPackage.RESULT__TARGETS:
       
   254 				getTargets().clear();
       
   255 				return;
       
   256 		}
       
   257 		super.eUnset(featureID);
       
   258 	}
       
   259 
       
   260 	/**
       
   261 	 * <!-- begin-user-doc -->
       
   262 	 * <!-- end-user-doc -->
       
   263 	 * @generated
       
   264 	 */
       
   265 	public boolean eIsSet(int featureID) {
       
   266 		switch (featureID) {
       
   267 			case IQRFPackage.RESULT__INTERFACES:
       
   268 				return interfaces != null && !interfaces.isEmpty();
       
   269 			case IQRFPackage.RESULT__CONFIGURATIONS:
       
   270 				return configurations != null && !configurations.isEmpty();
       
   271 			case IQRFPackage.RESULT__TARGETS:
       
   272 				return targets != null && !targets.isEmpty();
       
   273 		}
       
   274 		return super.eIsSet(featureID);
       
   275 	}
       
   276 	
       
   277 	public boolean equals(Object object) {
       
   278 		if(object==null || !(object instanceof Result)) return false;
       
   279 		Result result = (Result)object;
       
   280 		
       
   281 		// Iterate through targets and compare their member values.
       
   282 		Iterator iterT1 = getTargets().iterator();
       
   283 		Iterator iterT2 = result.getTargets().iterator();
       
   284 		while (iterT1.hasNext() || iterT2.hasNext())
       
   285 		{
       
   286 			Target t1, t2;
       
   287 			t1 = (Target)iterT1.next();
       
   288 			t2 = (Target)iterT2.next();
       
   289 			if(!t1.equals(t2)) return false;
       
   290 		}
       
   291 		
       
   292 		// Compare Interfaces
       
   293 		// Iterate through interfaces and compare their member values.
       
   294 		Iterator iterI1 = getInterfaces().iterator();
       
   295 		Iterator iterI2 = result.getInterfaces().iterator();
       
   296 		while (iterI1.hasNext() || iterI2.hasNext())
       
   297 		{
       
   298 			Interface i1, i2;
       
   299 			i1 = (Interface)iterI1.next();
       
   300 			i2 = (Interface)iterI2.next();
       
   301 			if(!i1.equals(i2)) return false;
       
   302 		}
       
   303 		
       
   304 		// Compare Configuration
       
   305 		Iterator iterC1 = getConfigurations().iterator();
       
   306 		Iterator iterC2 = result.getConfigurations().iterator();
       
   307 		while (iterC1.hasNext() || iterC2.hasNext())
       
   308 		{
       
   309 			Configuration c1, c2;
       
   310 			c1 = (Configuration)iterC1.next();
       
   311 			c2 = (Configuration)iterC2.next();
       
   312 			if(!c1.equals(c2)) return false;
       
   313 		}
       
   314 		return true;
       
   315 	}
       
   316 	
       
   317 	@Override
       
   318 	public int hashCode() {
       
   319 		final int hashMultiplier = 41;
       
   320 		int result = 7;
       
   321 		result=result*hashMultiplier + getInterfaces().hashCode();
       
   322 		result=result*hashMultiplier + getConfigurations().hashCode();
       
   323 		result=result*hashMultiplier + getTargets().hashCode();
       
   324 		return result;
       
   325 	}
       
   326 } //ResultImpl