/**
  * Retrieves all EClasses from <code>allEClasses</code> that can possibly be referenced by <code>
  * reference</code> and returns them as a list.
  *
  * @param reference the EReference to get EClasses for
  * @param allEClasses set of all possible EClasses
  * @return list of all EClasses that can be referenced by <code>reference</code>
  */
 public static Set<EClass> getReferenceClasses(EReference reference, Set<EClass> allEClasses) {
   Set<EClass> result = new LinkedHashSet<EClass>();
   EClass referenceType = reference.getEReferenceType();
   // 'referenceType: EObject' allows all kinds of EObjects
   if (referenceType.equals(EcorePackage.eINSTANCE.getEObject())) {
     return allEClasses;
   }
   for (EClass eClass : allEClasses) {
     // can eClass be referenced by reference
     if (referenceType.equals(eClass) || referenceType.isSuperTypeOf(eClass)) {
       result.add(eClass);
     }
   }
   return result;
 }
 /**
  * Returns all containing references where <code>parentClass</code> is the container and <code>
  * childClass</code> the containment.
  *
  * @param childClass the EClass which shall be contained
  * @param parentClass the EClass to get containment references from
  * @return all possible container-references as a set
  */
 public static Set<EReference> getAllPossibleContainingReferences(
     EClass childClass, EClass parentClass) {
   List<EReference> allReferences = parentClass.getEAllContainments();
   Set<EReference> result = new LinkedHashSet<EReference>();
   for (EReference reference : allReferences) {
     EClass referenceType = reference.getEReferenceType();
     if (referenceType == null) {
       continue;
     }
     // is the reference type a perfect match?
     if (referenceType.equals(childClass)) {
       result.add(reference);
       // is the reference type either EObject or a super type?
     } else if (referenceType.equals(EcorePackage.eINSTANCE.getEObject())
         || referenceType.isSuperTypeOf(childClass)) {
       result.add(reference);
     }
   }
   return result;
 }
  public boolean equals(Object o) {
    if (this == o) return true;
    if (!(o instanceof CreateModelElementCommand)) return false;

    final CreateModelElementCommand createModelElementCommand = (CreateModelElementCommand) o;

    if (!eClass.equals(createModelElementCommand.eClass)) return false;
    if (!idFactory.equals(createModelElementCommand.idFactory)) return false;

    return true;
  }
 /**
  * Walks up the containment hierarchy to find an EObject that is able to hold (contain) the given
  * object.
  */
 protected EObject findHookParent(
     EObject container,
     EClass startClass,
     org.emftext.language.xpath3.resource.xpath3.mopp.Xpath3ContainedFeature currentLink,
     EObject object) {
   EClass containerClass = currentLink.getContainerClass();
   while (container != null) {
     if (containerClass.isInstance(object)) {
       if (startClass.equals(container.eClass())) {
         return container;
       }
     }
     container = container.eContainer();
   }
   return null;
 }
  @Override
  public boolean isPageComplete() {
    if (getDataName() == null || getDataName().trim().length() == 0) {
      setErrorMessage(Messages.AddSimulationDataWizardPage_Error_EmptyName);
      return false;
    }

    if (!isExpressionBased()) {
      if (SimulationPackage.eINSTANCE.getSimulationLiteralData().equals(dataClass)) {
        double total = 0;
        boolean emptyValue = false;
        for (SimulationLiteral l : getLiterals()) {
          total = total + l.getProbability();
          final String simuValue = l.getValue();
          if (simuValue == null || simuValue.trim().length() == 0) {
            emptyValue = true;
          }
        }
        if (total != 1.0) {
          setErrorMessage(Messages.AddSimulationDataWizardPage_Error_Proba);
          return false;
        }
        if (emptyValue) {
          setErrorMessage(Messages.AddSimulationDataWizardPage_Error_EmptyLiteral);
          return false;
        }

      } else if (dataClass.equals(SimulationPackage.eINSTANCE.getSimulationNumberData())) {
        double total = 0;
        for (SimulationNumberRange l : getRanges()) {
          total = total + l.getProbability();
        }
        if (total != 1.0) {
          setErrorMessage(Messages.AddSimulationDataWizardPage_Error_Proba);
          return false;
        }
        for (SimulationNumberRange l : getRanges()) {
          if (l.getMin() >= l.getMax()) {
            setErrorMessage(Messages.AddSimulationDataWizardPage_Error_MinMax);
            return false;
          }
        }
      }
    }
    return super.isPageComplete();
  }
 @Override
 public boolean equals(final Object obj) {
   if (this == obj) return true;
   if (!(obj instanceof EClassAttributeMatch)) { // this should be infrequent			
     if (obj == null) return false;
     if (!(obj instanceof IPatternMatch)) return false;
     IPatternMatch otherSig = (IPatternMatch) obj;
     if (!pattern().equals(otherSig.pattern())) return false;
     return Arrays.deepEquals(toArray(), otherSig.toArray());
   }
   EClassAttributeMatch other = (EClassAttributeMatch) obj;
   if (fE == null) {
     if (other.fE != null) return false;
   } else if (!fE.equals(other.fE)) return false;
   if (fAttr == null) {
     if (other.fAttr != null) return false;
   } else if (!fAttr.equals(other.fAttr)) return false;
   if (fType == null) {
     if (other.fType != null) return false;
   } else if (!fType.equals(other.fType)) return false;
   return true;
 }