Exemple #1
0
  public void test_enumerationLiteralEquality_137546() {
    EObject ctx = fruitEFactory.create((EClass) fruitEPackage.getEClassifier(apple.getName()));
    helper.setContext(apple);

    EEnum ecolor = (EEnum) fruitEPackage.getEClassifier(color.getName());
    ctx.eSet(
        ctx.eClass().getEStructuralFeature(fruit_color.getName()),
        ecolor.getEEnumLiteral(color_green.getName()));

    try {
      assertTrue(check(helper, ctx, "ocltest::Color::green = self.color"));
      assertTrue(check(helper, ctx, "self.color = ocltest::Color::green"));
    } catch (Exception e) {
      fail("Failed to parse or evaluate: " + e.getLocalizedMessage());
    }
  }
 /**
  * Use setParameterString instead, unless calling from an XML loader that has not yet created the
  * plan element.
  */
 public static void setParameterStringInData(EObject data, String parameterName, String newValue)
     throws UndefinedParameterException {
   EStructuralFeature feature = getParameterFeature(data, parameterName);
   EClassifier type = feature.getEType();
   Object object;
   if (type instanceof EEnum) {
     EEnum enumType = (EEnum) type;
     object = enumType.getEEnumLiteral(newValue);
   } else if (type instanceof EDataType) {
     EDataType dataType = (EDataType) type;
     EPackage typePackage = dataType.getEPackage();
     EFactory factory = typePackage.getEFactoryInstance();
     object = factory.createFromString(dataType, newValue);
   } else {
     Logger logger = Logger.getLogger(ADParameterUtils.class);
     logger.warn("feature type '" + type + "'is not EDataType: " + parameterName);
     object = newValue;
   }
   data.eSet(feature, object);
 }
 /**
  * Add a value to a named AD multi-select EEnum parameter for the activity
  *
  * @param element
  * @param parameterName
  * @param newValue
  * @throws UndefinedParameterException
  */
 @SuppressWarnings("unchecked")
 public static void addParameterStringToList(
     EPlanElement element, String parameterName, String newValue)
     throws UndefinedParameterException {
   EObject data = element.getData();
   EStructuralFeature feature = getParameterFeature(data, parameterName);
   EClassifier type = feature.getEType();
   Object object;
   if (type instanceof EEnum) {
     EEnum enumType = (EEnum) type;
     object = enumType.getEEnumLiteral(newValue);
   } else if (type instanceof EDataType) {
     EDataType dataType = (EDataType) type;
     EPackage typePackage = dataType.getEPackage();
     EFactory factory = typePackage.getEFactoryInstance();
     object = factory.createFromString(dataType, newValue);
   } else {
     Logger logger = Logger.getLogger(ADParameterUtils.class);
     logger.warn("feature type '" + type + "'is not EDataType: " + parameterName);
     object = newValue;
   }
   addParameterObjectToList(element, parameterName, object);
 }