Java 类org.eclipse.emf.ecore.EEnumLiteral 实例源码

项目:BIMplatform    文件:IfcStepStreamingDeserializer.java   
private void readEnum(String val, VirtualObject object, EStructuralFeature structuralFeature) throws DeserializeException, MetaDataException, DatabaseException {
    if (val.equals(".T.")) {
        object.setAttribute(structuralFeature, Boolean.TRUE);
    } else if (val.equals(".F.")) {
        object.setAttribute(structuralFeature, Boolean.FALSE);
    } else if (val.equals(".U.")) {
        object.eUnset(structuralFeature);
    } else {
        if (structuralFeature.getEType() instanceof EEnumImpl) {
            String realEnumValue = val.substring(1, val.length() - 1);
            EEnumLiteral enumValue = (((EEnumImpl) structuralFeature.getEType()).getEEnumLiteral(realEnumValue));
            if (enumValue == null) {
                throw new DeserializeException(lineNumber, "Enum type " + structuralFeature.getEType().getName() + " has no literal value '" + realEnumValue + "'");
            }
            object.setAttribute(structuralFeature, enumValue.getLiteral());
        } else {
            throw new DeserializeException(lineNumber, "Value " + val + " indicates enum type but " + structuralFeature.getEType().getName() + " expected");
        }
    }
}
项目:BIMplatform    文件:PackageMetaData.java   
public EEnumLiteral getEEnumLiteral(String enumName, String literalName) {
    EClassifier eClassifier = ePackage.getEClassifier(enumName);
    if (eClassifier == null) {
        throw new RuntimeException("Classifier " + enumName + " not found in package " + ePackage.getName());
    }
    if (eClassifier instanceof EEnum) {
        EEnum eEnum = (EEnum)eClassifier;
        EEnumLiteral literal = eEnum.getEEnumLiteral(literalName);
        if (literal == null) {
            throw new RuntimeException("No enum literal " + literalName + " found on " + ePackage.getName() + "." + enumName);
        }
        return literal;
    } else {
        throw new RuntimeException("Classifier " + enumName + " is not of type enum");
    }
}
项目:JavaGraph    文件:EcoreToType.java   
private Enum visitEnum(TypeModel mm, EEnum eEnum) {
    Id enumID = EcoreUtil.idFromClassifier(eEnum);

    if (mm.hasEnum(enumID)) {
        return mm.getEnum(enumID);
    }

    Enum cmEnum = mm.getEnum(enumID, true);

    for (EEnumLiteral eEnumLiteral : eEnum.getELiterals()) {
        Name litName = Name.getName(eEnumLiteral.getName());
        cmEnum.addLiteral(litName);
    }

    return cmEnum;
}
项目:OCCI-Studio    文件:OCCIExtension2Ecore.java   
private EEnum createEnumerationType(EnumerationType type) {
    EEnum eenum = EcoreFactory.eINSTANCE.createEEnum();
    eenum.setName(type.getName());
    int value = 0;
    for (EnumerationLiteral literal : type.getLiterals()) {
        EEnumLiteral eenumliteral = EcoreFactory.eINSTANCE.createEEnumLiteral();
        eenum.getELiterals().add(eenumliteral);
        eenumliteral.setName(literal.getName());
        eenumliteral.setLiteral(literal.getName());
        eenumliteral.setValue(value);
        value++;
        if (literal.getDocumentation() != null) {
            attachInfo(eenumliteral, literal.getDocumentation());
        }
    }
    if (type.getDocumentation() != null) {
        attachInfo(eenum, type.getDocumentation());
    }
    return eenum;
}
项目:IfcPlugins    文件:IfcXmlDeserializer.java   
private Object parsePrimitive(EClassifier eType, String text) throws DeserializeException {
    if (eType == EcorePackage.eINSTANCE.getEString()) {
        return text;
    } else if (eType == EcorePackage.eINSTANCE.getEInt()) {
        return Integer.parseInt(text);
    } else if (eType == EcorePackage.eINSTANCE.getELong()) {
        return Long.parseLong(text);
    } else if (eType == EcorePackage.eINSTANCE.getEDouble()) {
        return Double.parseDouble(text);
    } else if (eType == EcorePackage.eINSTANCE.getEBoolean()) {
        return Boolean.parseBoolean(text);
    } else if (eType instanceof EEnum) {
        EEnumLiteral eEnumLiteral = ((EEnum) eType).getEEnumLiteral(text.toUpperCase());
        if (eEnumLiteral == null) {
            if (text.equals("unknown")) {
                return null;
            } else {
                throw new DeserializeException("Unknown enum literal " + text + " in enum " + ((EEnum) eType).getName());
            }
        }
        return eEnumLiteral.getInstance();
    } else {
        throw new DeserializeException("Unimplemented primitive type: " + eType.getName());
    }
}
项目:xtext-core    文件:GrammarParserTest.java   
@Test public void testEnum_01() throws Exception {
    String modelAsString =
        "grammar TestLanguage with org.eclipse.xtext.common.Terminals\n" +
        "generate testLanguage 'http://www.eclipse.org/2009/tmf/xtext/AbstractEnumRulesTest/TestEnum/1'\n" +
        "Model: enumValue=MyEnum;\n" +
        "enum MyEnum: Value1;";
    Grammar grammar = (Grammar) getModel(modelAsString);
    assertTrue(grammar.eResource().getErrors().toString(), grammar.eResource().getErrors().isEmpty());
    checkEnums(grammar);
    EPackage pack = grammar.getMetamodelDeclarations().get(0).getEPackage();
    assertEquals("http://www.eclipse.org/2009/tmf/xtext/AbstractEnumRulesTest/TestEnum/1", pack.getNsURI());
    EEnum eEnum = (EEnum) pack.getEClassifier("MyEnum");
    assertNotNull(eEnum);
    assertEquals(1, eEnum.getELiterals().size());
    EEnumLiteral value = eEnum.getELiterals().get(0);
    assertEquals("Value1", value.getName());
    assertEquals(0, value.getValue());
    assertEquals("Value1", value.getLiteral());
}
项目:xtext-core    文件:GrammarParserTest.java   
@Test public void testEnum_02() throws Exception {
    String modelAsString =
        "grammar TestLanguage with org.eclipse.xtext.common.Terminals\n" +
        "generate testLanguage 'http://www.eclipse.org/2009/tmf/xtext/AbstractEnumRulesTest/TestEnum/2'\n" +
        "Model: enumValue=MyEnumRule;\n" +
        "enum MyEnumRule returns MyEnum: Value1;";
    Grammar grammar = (Grammar) getModel(modelAsString);
    assertTrue(grammar.eResource().getErrors().toString(), grammar.eResource().getErrors().isEmpty());
    checkEnums(grammar);
    EPackage pack = grammar.getMetamodelDeclarations().get(0).getEPackage();
    assertEquals("http://www.eclipse.org/2009/tmf/xtext/AbstractEnumRulesTest/TestEnum/2", pack.getNsURI());
    EEnum eEnum = (EEnum) pack.getEClassifier("MyEnum");
    assertNotNull(eEnum);
    assertEquals(1, eEnum.getELiterals().size());
    EEnumLiteral value = eEnum.getELiterals().get(0);
    assertEquals("Value1", value.getName());
    assertEquals(0, value.getValue());
    assertEquals("Value1", value.getLiteral());
}
项目:xtext-core    文件:GrammarParserTest.java   
@Test public void testEnum_03() throws Exception {
    String modelAsString =
        "grammar TestLanguage with org.eclipse.xtext.common.Terminals\n" +
        "generate testLanguage 'http://www.eclipse.org/2009/tmf/xtext/AbstractEnumRulesTest/TestEnum/3'\n" +
        "Model: enumValue=MyEnumRule;\n" +
        "enum MyEnumRule returns MyEnum: Value1 = 'value';";
    Grammar grammar = (Grammar) getModel(modelAsString);
    assertTrue(grammar.eResource().getErrors().toString(), grammar.eResource().getErrors().isEmpty());
    checkEnums(grammar);
    EPackage pack = grammar.getMetamodelDeclarations().get(0).getEPackage();
    assertEquals("http://www.eclipse.org/2009/tmf/xtext/AbstractEnumRulesTest/TestEnum/3", pack.getNsURI());
    EEnum eEnum = (EEnum) pack.getEClassifier("MyEnum");
    assertNotNull(eEnum);
    assertEquals(1, eEnum.getELiterals().size());
    EEnumLiteral value = eEnum.getELiterals().get(0);
    assertEquals("Value1", value.getName());
    assertEquals(0, value.getValue());
    assertEquals("value", value.getLiteral());
}
项目:xtext-core    文件:GrammarParserTest.java   
@Test public void testEnum_07() throws Exception {
    String modelAsString =
        "grammar TestLanguage with org.eclipse.xtext.common.Terminals\n" +
        "generate testLanguage 'http://www.eclipse.org/2009/tmf/xtext/AbstractEnumRulesTest/TestEnum/7'\n" +
        "Model: enumValue=MyEnum;\n" +
        "enum MyEnum: Value | Value;";
    Grammar grammar = (Grammar) getModel(modelAsString);
    assertTrue(grammar.eResource().getErrors().toString(), grammar.eResource().getErrors().isEmpty());
    checkEnums(grammar);
    EPackage pack = grammar.getMetamodelDeclarations().get(0).getEPackage();
    assertEquals("http://www.eclipse.org/2009/tmf/xtext/AbstractEnumRulesTest/TestEnum/7", pack.getNsURI());
    EEnum eEnum = (EEnum) pack.getEClassifier("MyEnum");
    assertNotNull(eEnum);
    assertEquals(1, eEnum.getELiterals().size());
    EEnumLiteral value = eEnum.getELiterals().get(0);
    assertEquals("Value", value.getName());
    assertEquals(0, value.getValue());
    assertEquals("Value", value.getLiteral());
}
项目:xtext-core    文件:GrammarParserTest.java   
@Test public void testEnum_08() throws Exception {
    String modelAsString =
        "grammar TestLanguage with org.eclipse.xtext.common.Terminals\n" +
        "generate testLanguage 'http://www.eclipse.org/2009/tmf/xtext/AbstractEnumRulesTest/TestEnum/8'\n" +
        "Model: enumValue=MyEnum;\n" +
        "enum MyEnum: Value | Value = 'foo';";
    Grammar grammar = (Grammar) getModel(modelAsString);
    assertTrue(grammar.eResource().getErrors().toString(), grammar.eResource().getErrors().isEmpty());
    checkEnums(grammar);
    EPackage pack = grammar.getMetamodelDeclarations().get(0).getEPackage();
    assertEquals("http://www.eclipse.org/2009/tmf/xtext/AbstractEnumRulesTest/TestEnum/8", pack.getNsURI());
    EEnum eEnum = (EEnum) pack.getEClassifier("MyEnum");
    assertNotNull(eEnum);
    assertEquals(1, eEnum.getELiterals().size());
    EEnumLiteral value = eEnum.getELiterals().get(0);
    assertEquals("Value", value.getName());
    assertEquals(0, value.getValue());
    assertEquals("Value", value.getLiteral());
}
项目:bts    文件:EnumTemplateVariableResolver.java   
@Override
public List<String> resolveValues(TemplateVariable variable,
        XtextTemplateContext castedContext) {
    String enumerationName = (String) variable.getVariableType()
            .getParams().iterator().next();
    Grammar grammar = getGrammar(castedContext);
    if (grammar == null)
        return Collections.emptyList();
    EEnum enumeration = (EEnum) getEClassifierForGrammar(enumerationName, grammar);
    if (enumeration == null) {
        return Collections.emptyList();
    }
    return Lists.transform(enumeration.getELiterals(), new Function<EEnumLiteral, String>() {
        public String apply(EEnumLiteral enumLiteral) {
            return enumLiteral.getLiteral();
        }
    });
}
项目:OpenSPIFe    文件:DynamicProfileDependency.java   
private Object combine(Object previousValue, Object value) {
    if (previousValue instanceof Number && value instanceof Number) {
        return normalize(((Number)previousValue).doubleValue() + ((Number)value).doubleValue());
    } else if (previousValue instanceof Amount && value instanceof Amount) {
        return ((Amount)previousValue).plus(((Amount)value));
    } else if (previousValue instanceof String && value instanceof String) {
        return value;
    } else if (previousValue instanceof EEnumLiteral && value instanceof EEnumLiteral) {
        return value;
    } else if (previousValue instanceof Boolean && value instanceof Boolean) {
        return value;
    } else {
        LogUtil.errorOnce(profileKey+": unrecognized value pair '"+previousValue+"' & '"+value+"'");
    }
    return null;
}
项目:OpenSPIFe    文件:TestPlanIORoundTrip.java   
protected EActivity createActivityRandomly(EActivityDef def) {
    EActivity activity = PlanFactory.getInstance().createActivity(def, null);
    for (EStructuralFeature feature : def.getEAllStructuralFeatures()) {
        if (!feature.isChangeable()) {
            continue;
        }
        Object value = activity.getData().eGet(feature);
        EClassifier type = feature.getEType();
        if (type instanceof EEnum) {
            EList<EEnumLiteral> literals = ((EEnum)type).getELiterals();
            int index = (int) (Math.random() * literals.size());
            value = literals.get(index);
            if (feature.isMany()) {
                value = Collections.singletonList(value);
            }
        } else if (EcorePackage.Literals.ESTRING == type) {
            value = "String "+Math.random();
        }
        activity.getData().eSet(feature, value);
    }
    return activity;
}
项目:OpenSPIFe    文件:PlanElementRowHeaderEditPart.java   
@Override
public Image getImage(Object element) {
    if (element instanceof DynamicActivityGroup) {
        DynamicActivityGroup dag = (DynamicActivityGroup) element;
        Object value = dag.getValue();
        if (value instanceof EEnumLiteral) {
            return null;
        }
        IItemLabelProvider lp = EMFUtils.adapt(value, IItemLabelProvider.class);
        if (lp != null) {
            Object image = lp.getImage(value);
            return ExtendedImageRegistry.getInstance().getImage(image);
        }
        return null;
    }
    return delegate.getImage(element);
}
项目:OpenSPIFe    文件:GroupingTimelineContentProvider.java   
protected String getValueString(Object value) {
    if (value instanceof EEnumLiteral) {
        return ((EEnumLiteral)value).getLiteral();
    } else if (value instanceof EObject) {
        IItemLabelProvider labeler = EMFUtils.adapt(value, IItemLabelProvider.class);
        if (labeler != null) {
            String text = labeler.getText(value);
            if (text != null) {
                return text;
            }
        }
    } else if (NULL_VALUE == value) {
        return "";
    }
    return value.toString();
}
项目:OpenSPIFe    文件:EAttributeTimelineContentProvider.java   
@Override
protected Comparator getGroupingValuesComparator() {
    EClassifier eType = attributeDef.getEType();
    if (eType instanceof EEnum) {
        final EEnum eEnum = (EEnum) eType;
        return new Comparator<EEnumLiteral>() {
            @Override
            public int compare(EEnumLiteral o1, EEnumLiteral o2) {
                int v1 = eEnum.getELiterals().indexOf(o1);
                int v2 = eEnum.getELiterals().indexOf(o2);
                return v1 - v2;
            }
        };
    }
    return null;
}
项目:OpenSPIFe    文件:PlotRgbRegistry.java   
public RGB getRgb(Plot plot, Object value) {
    RGB rgb = null;
    if (value instanceof EEnumLiteral) {
        rgb = getRgb(plot, (EEnumLiteral) value);
    } else if (value instanceof String) {
        rgb = getRgb(plot, (String) value);
    } else if (value instanceof Boolean) {
        rgb = getRgb(plot, (Boolean)value);
    } else if (value instanceof Amount) {
        rgb = getRgb(plot, (Amount)value);
    } else if (value instanceof Number) {
        rgb = getRgb(plot, (Number)value);
    } else if (value instanceof PowerValue) {
        return getRgb(plot, ((PowerValue)value).getStateValue());
    }
    return rgb == NULL ? null : rgb;
}
项目:OpenSPIFe    文件:DataPoint.java   
public boolean isZero() {
    T value = getValue();
    if (value == null) {
        return true;
    }
    if (value instanceof Boolean) {
        Boolean b = (Boolean) value;
        return (b == Boolean.FALSE);
    }
    if (value instanceof EEnumLiteral) {
        return ((EEnumLiteral) value).getValue() == 0;
    }
    if (value instanceof Enum) {
        return ((Enum) value).ordinal() == 0;
    }
    Number number = (value instanceof Number ? (Number)value : null);
    if (value instanceof Amount) {
        Amount amount = (Amount) value;
        number = AmountUtils.getNumericValue(amount);
    }
    if (number != null) {
        return number.doubleValue() == 0;
    }
    return false;
}
项目:OpenSPIFe    文件:PowerValueImpl.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void eSet(int featureID, Object newValue) {
    switch (featureID) {
        case JSciencePackage.POWER_VALUE__STATE_NAME:
            setStateName((String)newValue);
            return;
        case JSciencePackage.POWER_VALUE__DUTY_FACTOR:
            setDutyFactor((Double)newValue);
            return;
        case JSciencePackage.POWER_VALUE__ACTUAL_WATTAGE:
            setActualWattage((Double)newValue);
            return;
        case JSciencePackage.POWER_VALUE__STATE_VALUE:
            setStateValue((EEnumLiteral)newValue);
            return;
    }
    super.eSet(featureID, newValue);
}
项目:OpenSPIFe    文件:PowerValueImpl.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void eUnset(int featureID) {
    switch (featureID) {
        case JSciencePackage.POWER_VALUE__STATE_NAME:
            setStateName(STATE_NAME_EDEFAULT);
            return;
        case JSciencePackage.POWER_VALUE__DUTY_FACTOR:
            setDutyFactor(DUTY_FACTOR_EDEFAULT);
            return;
        case JSciencePackage.POWER_VALUE__ACTUAL_WATTAGE:
            setActualWattage(ACTUAL_WATTAGE_EDEFAULT);
            return;
        case JSciencePackage.POWER_VALUE__STATE_VALUE:
            setStateValue((EEnumLiteral)null);
            return;
    }
    super.eUnset(featureID);
}
项目:OpenSPIFe    文件:ADParameterUtils.java   
/**
 * Get the value of the named AD parameter for the activity as a string.
 * Works with several types, not just strings -- enums, for example.
 * @param element
 * @param parameterName
 * @return null if the parameter is not found
 */
public static String getParameterString(EPlanElement element, String parameterName) {
    EObject data = element.getData();
    if (data==null) return null;
    EStructuralFeature feature;
       try {
        feature = getParameterFeature(data, parameterName);
       } catch (UndefinedParameterException e) {
        return null;
       }
    Object object = data.eGet(feature);
    if (object instanceof EEnumLiteral) {
        EEnumLiteral literal = (EEnumLiteral) object;
        return literal.getName();
    }
    EClassifier type = feature.getEType();
    if (type instanceof EDataType) {
        EDataType dataType = (EDataType) type;
        EPackage typePackage = dataType.getEPackage();
        EFactory factory = typePackage.getEFactoryInstance();
        String string = factory.convertToString(dataType, object);
        return string;
    }
    LogUtil.warnOnce("feature type '" + type + "'is not EDataType: " + parameterName);
    return String.valueOf(object);
}
项目:OpenSPIFe    文件:ADParameterUtils.java   
public static String getObjectString(EObject object, String parameterName) {
    EStructuralFeature feature;
       try {
        feature = getParameterFeature(object, parameterName);
       } catch (UndefinedParameterException e) {
        return null;
       }
    Object value = object.eGet(feature);
    if (value instanceof EEnumLiteral) {
        EEnumLiteral literal = (EEnumLiteral) value;
        return literal.getName();
    }
    EClassifier type = feature.getEType();
    if (type instanceof EDataType) {
        EDataType dataType = (EDataType) type;
        EPackage typePackage = dataType.getEPackage();
        EFactory factory = typePackage.getEFactoryInstance();
        String string = factory.convertToString(dataType, value);
        return string;
    }
    LogUtil.warnOnce("feature type '" + type + "'is not EDataType: " + parameterName);
    return String.valueOf(value);
}
项目:eclipse-avro    文件:EPackageImpl.java   
protected void fixEEnumLiterals(EEnum eEnum)
{
  Class<?> enumClass = eEnum.getInstanceClass();

  try
  {
    Method getter = enumClass.getMethod("get", new Class[] { Integer.TYPE });

    for (EEnumLiteral eEnumLiteral : eEnum.getELiterals())
    {
      Enumerator instance = (Enumerator)getter.invoke(null, new Object[] { eEnumLiteral.getValue() });
      eEnumLiteral.setInstance(instance);
      ((EEnumLiteralImpl)eEnumLiteral).setGeneratedInstance(true);
    }
  }
  catch (Exception e)
  {
    // Do nothing
  }
}
项目:BIMserver    文件:ByteBufferVirtualObject.java   
private void writeEnum(EStructuralFeature feature, Object value) {
    if (value == null) {
        ensureCapacity(buffer.position(), 4);
        buffer.putInt(-1);
    } else {
        EEnum eEnum = (EEnum) feature.getEType();
        EEnumLiteral eEnumLiteral = eEnum.getEEnumLiteralByLiteral(((Enum<?>) value).toString());
        ensureCapacity(buffer.position(), 4);
        if (eEnumLiteral != null) {
            buffer.putInt(eEnumLiteral.getValue());
        } else {
            LOGGER.error(((Enum<?>) value).toString() + " not found");
            buffer.putInt(-1);
        }
    }
}
项目:BIMserver    文件:Schema.java   
public EEnumLiteral createEEnumLiteral(EEnum eEnum, String name) {
    EEnumLiteral eEnumLiteral = EcoreFactory.eINSTANCE.createEEnumLiteral();
    if (eEnum.getELiterals().size() == 0) {
        eEnumLiteral.setValue(0);
    } else {
        int largestValue = Integer.MIN_VALUE;
        for (EEnumLiteral existingLiteral : eEnum.getELiterals()) {
            if (existingLiteral.getValue() > largestValue) {
                largestValue = existingLiteral.getValue();
            }
        }
        eEnumLiteral.setValue(largestValue + 1);
    }
    eEnum.getELiterals().add(eEnumLiteral);
    eEnumLiteral.setName(name);
    return eEnumLiteral;
}
项目:BIMserver    文件:Express2EMF.java   
private void createTristate() {
    tristate = eFactory.createEEnum();
    tristate.setName("Tristate");
    EEnumLiteral trueLiteral = eFactory.createEEnumLiteral();
    trueLiteral.setName("TRUE");
    trueLiteral.setValue(0);
    EEnumLiteral falseLiteral = eFactory.createEEnumLiteral();
    falseLiteral.setName("FALSE");
    falseLiteral.setValue(1);
    EEnumLiteral undefinedLiteral = eFactory.createEEnumLiteral();
    undefinedLiteral.setName("UNDEFINED");
    undefinedLiteral.setValue(2);
    tristate.getELiterals().add(trueLiteral);
    tristate.getELiterals().add(falseLiteral);
    tristate.getELiterals().add(undefinedLiteral);
    schemaPack.getEClassifiers().add(tristate);
}
项目:BIMserver    文件:PackageMetaData.java   
public EEnumLiteral getEEnumLiteral(String enumName, String literalName) {
    EClassifier eClassifier = ePackage.getEClassifier(enumName);
    if (eClassifier == null) {
        throw new RuntimeException("Classifier " + enumName + " not found in package " + ePackage.getName());
    }
    if (eClassifier instanceof EEnum) {
        EEnum eEnum = (EEnum)eClassifier;
        EEnumLiteral literal = eEnum.getEEnumLiteral(literalName);
        if (literal == null) {
            throw new RuntimeException("No enum literal " + literalName + " found on " + ePackage.getName() + "." + enumName);
        }
        return literal;
    } else {
        throw new RuntimeException("Classifier " + enumName + " is not of type enum");
    }
}
项目:clickwatch    文件:EPackageImpl.java   
protected void fixEEnumLiterals(EEnum eEnum)
{
  Class<?> enumClass = eEnum.getInstanceClass();

  try
  {
    Method getter = enumClass.getMethod("get", new Class[] { Integer.TYPE });

    for (EEnumLiteral eEnumLiteral : eEnum.getELiterals())
    {
      Enumerator instance = (Enumerator)getter.invoke(null, new Object[] { eEnumLiteral.getValue() });
      eEnumLiteral.setInstance(instance);
      ((EEnumLiteralImpl)eEnumLiteral).setGeneratedInstance(true);
    }
  }
  catch (Exception e)
  {
    // Do nothing
  }
}
项目:JavaGraph    文件:TypeToEcore.java   
@Override
public void visit(Enum enum1, String param) {
    if (hasElement(enum1)) {
        return;
    }

    EEnum eEnum = g_EcoreFactory.createEEnum();
    setElement(enum1, eEnum);

    eEnum.setName(enum1.getId()
        .getName()
        .toString());

    EPackage enumPackage = packageFromId(enum1.getId()
        .getNamespace());
    enumPackage.getEClassifiers()
        .add(eEnum);

    List<EEnumLiteral> eLiterals = eEnum.getELiterals();
    for (Name litName : enum1.getLiterals()) {
        EEnumLiteral eEnumLit = g_EcoreFactory.createEEnumLiteral();
        eEnumLit.setName(litName.toString());
        //eEnumLit.setLiteral(litName.toString());

        eLiterals.add(eEnumLit);
    }
}
项目:gemoc-studio    文件:GEnumLiteralExpressionImpl.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setValue(EEnumLiteral newValue) {
    EEnumLiteral oldValue = value;
    value = newValue;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, GexpressionsPackage.GENUM_LITERAL_EXPRESSION__VALUE, oldValue, value));
}
项目:gemoc-studio    文件:GEnumLiteralExpressionImpl.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void eSet(int featureID, Object newValue) {
    switch (featureID) {
        case GexpressionsPackage.GENUM_LITERAL_EXPRESSION__VALUE:
            setValue((EEnumLiteral)newValue);
            return;
    }
    super.eSet(featureID, newValue);
}
项目:gemoc-studio    文件:GEnumLiteralExpressionImpl.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void eUnset(int featureID) {
    switch (featureID) {
        case GexpressionsPackage.GENUM_LITERAL_EXPRESSION__VALUE:
            setValue((EEnumLiteral)null);
            return;
    }
    super.eUnset(featureID);
}
项目:DarwinSPL    文件:DwprofileCodeCompletionHelper.java   
protected Collection<de.darwinspl.preferences.resource.dwprofile.ui.DwprofileCompletionProposal> handleEnumAttribute(de.darwinspl.preferences.resource.dwprofile.mopp.DwprofileExpectedTerminal expectedTerminal, de.darwinspl.preferences.resource.dwprofile.mopp.DwprofileExpectedStructuralFeature expectedFeature, EEnum enumType, String prefix, EObject container) {
    Collection<EEnumLiteral> enumLiterals = enumType.getELiterals();
    Collection<de.darwinspl.preferences.resource.dwprofile.ui.DwprofileCompletionProposal> result = new LinkedHashSet<de.darwinspl.preferences.resource.dwprofile.ui.DwprofileCompletionProposal>();
    for (EEnumLiteral literal : enumLiterals) {
        String unResolvedLiteral = literal.getLiteral();
        // use token resolver to get de-resolved value of the literal
        de.darwinspl.preferences.resource.dwprofile.IDwprofileTokenResolverFactory tokenResolverFactory = metaInformation.getTokenResolverFactory();
        de.darwinspl.preferences.resource.dwprofile.IDwprofileTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver(expectedFeature.getTokenName());
        String resolvedLiteral = tokenResolver.deResolve(unResolvedLiteral, expectedFeature.getFeature(), container);
        boolean matchesPrefix = matches(resolvedLiteral, prefix);
        result.add(new de.darwinspl.preferences.resource.dwprofile.ui.DwprofileCompletionProposal(expectedTerminal, resolvedLiteral, prefix, matchesPrefix, expectedFeature.getFeature(), container));
    }
    return result;
}
项目:DarwinSPL    文件:HyexpressionCodeCompletionHelper.java   
protected Collection<eu.hyvar.feature.expression.resource.hyexpression.ui.HyexpressionCompletionProposal> handleEnumAttribute(eu.hyvar.feature.expression.resource.hyexpression.mopp.HyexpressionExpectedTerminal expectedTerminal, eu.hyvar.feature.expression.resource.hyexpression.mopp.HyexpressionExpectedStructuralFeature expectedFeature, EEnum enumType, String prefix, EObject container) {
    Collection<EEnumLiteral> enumLiterals = enumType.getELiterals();
    Collection<eu.hyvar.feature.expression.resource.hyexpression.ui.HyexpressionCompletionProposal> result = new LinkedHashSet<eu.hyvar.feature.expression.resource.hyexpression.ui.HyexpressionCompletionProposal>();
    for (EEnumLiteral literal : enumLiterals) {
        String unResolvedLiteral = literal.getLiteral();
        // use token resolver to get de-resolved value of the literal
        eu.hyvar.feature.expression.resource.hyexpression.IHyexpressionTokenResolverFactory tokenResolverFactory = metaInformation.getTokenResolverFactory();
        eu.hyvar.feature.expression.resource.hyexpression.IHyexpressionTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver(expectedFeature.getTokenName());
        String resolvedLiteral = tokenResolver.deResolve(unResolvedLiteral, expectedFeature.getFeature(), container);
        boolean matchesPrefix = matches(resolvedLiteral, prefix);
        result.add(new eu.hyvar.feature.expression.resource.hyexpression.ui.HyexpressionCompletionProposal(expectedTerminal, resolvedLiteral, prefix, matchesPrefix, expectedFeature.getFeature(), container));
    }
    return result;
}
项目:DarwinSPL    文件:HyvalidityformulaCodeCompletionHelper.java   
protected Collection<eu.hyvar.context.contextValidity.resource.hyvalidityformula.ui.HyvalidityformulaCompletionProposal> handleEnumAttribute(eu.hyvar.context.contextValidity.resource.hyvalidityformula.mopp.HyvalidityformulaExpectedTerminal expectedTerminal, eu.hyvar.context.contextValidity.resource.hyvalidityformula.mopp.HyvalidityformulaExpectedStructuralFeature expectedFeature, EEnum enumType, String prefix, EObject container) {
    Collection<EEnumLiteral> enumLiterals = enumType.getELiterals();
    Collection<eu.hyvar.context.contextValidity.resource.hyvalidityformula.ui.HyvalidityformulaCompletionProposal> result = new LinkedHashSet<eu.hyvar.context.contextValidity.resource.hyvalidityformula.ui.HyvalidityformulaCompletionProposal>();
    for (EEnumLiteral literal : enumLiterals) {
        String unResolvedLiteral = literal.getLiteral();
        // use token resolver to get de-resolved value of the literal
        eu.hyvar.context.contextValidity.resource.hyvalidityformula.IHyvalidityformulaTokenResolverFactory tokenResolverFactory = metaInformation.getTokenResolverFactory();
        eu.hyvar.context.contextValidity.resource.hyvalidityformula.IHyvalidityformulaTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver(expectedFeature.getTokenName());
        String resolvedLiteral = tokenResolver.deResolve(unResolvedLiteral, expectedFeature.getFeature(), container);
        boolean matchesPrefix = matches(resolvedLiteral, prefix);
        result.add(new eu.hyvar.context.contextValidity.resource.hyvalidityformula.ui.HyvalidityformulaCompletionProposal(expectedTerminal, resolvedLiteral, prefix, matchesPrefix, expectedFeature.getFeature(), container));
    }
    return result;
}
项目:DarwinSPL    文件:HydatavalueCodeCompletionHelper.java   
protected Collection<eu.hyvar.dataValues.resource.hydatavalue.ui.HydatavalueCompletionProposal> handleEnumAttribute(eu.hyvar.dataValues.resource.hydatavalue.mopp.HydatavalueExpectedTerminal expectedTerminal, eu.hyvar.dataValues.resource.hydatavalue.mopp.HydatavalueExpectedStructuralFeature expectedFeature, EEnum enumType, String prefix, EObject container) {
    Collection<EEnumLiteral> enumLiterals = enumType.getELiterals();
    Collection<eu.hyvar.dataValues.resource.hydatavalue.ui.HydatavalueCompletionProposal> result = new LinkedHashSet<eu.hyvar.dataValues.resource.hydatavalue.ui.HydatavalueCompletionProposal>();
    for (EEnumLiteral literal : enumLiterals) {
        String unResolvedLiteral = literal.getLiteral();
        // use token resolver to get de-resolved value of the literal
        eu.hyvar.dataValues.resource.hydatavalue.IHydatavalueTokenResolverFactory tokenResolverFactory = metaInformation.getTokenResolverFactory();
        eu.hyvar.dataValues.resource.hydatavalue.IHydatavalueTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver(expectedFeature.getTokenName());
        String resolvedLiteral = tokenResolver.deResolve(unResolvedLiteral, expectedFeature.getFeature(), container);
        boolean matchesPrefix = matches(resolvedLiteral, prefix);
        result.add(new eu.hyvar.dataValues.resource.hydatavalue.ui.HydatavalueCompletionProposal(expectedTerminal, resolvedLiteral, prefix, matchesPrefix, expectedFeature.getFeature(), container));
    }
    return result;
}
项目:DarwinSPL    文件:HymappingCodeCompletionHelper.java   
protected Collection<eu.hyvar.feature.mapping.resource.hymapping.ui.HymappingCompletionProposal> handleEnumAttribute(eu.hyvar.feature.mapping.resource.hymapping.mopp.HymappingExpectedTerminal expectedTerminal, eu.hyvar.feature.mapping.resource.hymapping.mopp.HymappingExpectedStructuralFeature expectedFeature, EEnum enumType, String prefix, EObject container) {
    Collection<EEnumLiteral> enumLiterals = enumType.getELiterals();
    Collection<eu.hyvar.feature.mapping.resource.hymapping.ui.HymappingCompletionProposal> result = new LinkedHashSet<eu.hyvar.feature.mapping.resource.hymapping.ui.HymappingCompletionProposal>();
    for (EEnumLiteral literal : enumLiterals) {
        String unResolvedLiteral = literal.getLiteral();
        // use token resolver to get de-resolved value of the literal
        eu.hyvar.feature.mapping.resource.hymapping.IHymappingTokenResolverFactory tokenResolverFactory = metaInformation.getTokenResolverFactory();
        eu.hyvar.feature.mapping.resource.hymapping.IHymappingTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver(expectedFeature.getTokenName());
        String resolvedLiteral = tokenResolver.deResolve(unResolvedLiteral, expectedFeature.getFeature(), container);
        boolean matchesPrefix = matches(resolvedLiteral, prefix);
        result.add(new eu.hyvar.feature.mapping.resource.hymapping.ui.HymappingCompletionProposal(expectedTerminal, resolvedLiteral, prefix, matchesPrefix, expectedFeature.getFeature(), container));
    }
    return result;
}
项目:DarwinSPL    文件:HyconstraintsCodeCompletionHelper.java   
protected Collection<eu.hyvar.feature.constraint.resource.hyconstraints.ui.HyconstraintsCompletionProposal> handleEnumAttribute(eu.hyvar.feature.constraint.resource.hyconstraints.mopp.HyconstraintsExpectedTerminal expectedTerminal, eu.hyvar.feature.constraint.resource.hyconstraints.mopp.HyconstraintsExpectedStructuralFeature expectedFeature, EEnum enumType, String prefix, EObject container) {
    Collection<EEnumLiteral> enumLiterals = enumType.getELiterals();
    Collection<eu.hyvar.feature.constraint.resource.hyconstraints.ui.HyconstraintsCompletionProposal> result = new LinkedHashSet<eu.hyvar.feature.constraint.resource.hyconstraints.ui.HyconstraintsCompletionProposal>();
    for (EEnumLiteral literal : enumLiterals) {
        String unResolvedLiteral = literal.getLiteral();
        // use token resolver to get de-resolved value of the literal
        eu.hyvar.feature.constraint.resource.hyconstraints.IHyconstraintsTokenResolverFactory tokenResolverFactory = metaInformation.getTokenResolverFactory();
        eu.hyvar.feature.constraint.resource.hyconstraints.IHyconstraintsTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver(expectedFeature.getTokenName());
        String resolvedLiteral = tokenResolver.deResolve(unResolvedLiteral, expectedFeature.getFeature(), container);
        boolean matchesPrefix = matches(resolvedLiteral, prefix);
        result.add(new eu.hyvar.feature.constraint.resource.hyconstraints.ui.HyconstraintsCompletionProposal(expectedTerminal, resolvedLiteral, prefix, matchesPrefix, expectedFeature.getFeature(), container));
    }
    return result;
}
项目:DarwinSPL    文件:HymanifestCodeCompletionHelper.java   
protected Collection<eu.hyvar.mspl.manifest.resource.hymanifest.ui.HymanifestCompletionProposal> handleEnumAttribute(eu.hyvar.mspl.manifest.resource.hymanifest.mopp.HymanifestExpectedTerminal expectedTerminal, eu.hyvar.mspl.manifest.resource.hymanifest.mopp.HymanifestExpectedStructuralFeature expectedFeature, EEnum enumType, String prefix, EObject container) {
    Collection<EEnumLiteral> enumLiterals = enumType.getELiterals();
    Collection<eu.hyvar.mspl.manifest.resource.hymanifest.ui.HymanifestCompletionProposal> result = new LinkedHashSet<eu.hyvar.mspl.manifest.resource.hymanifest.ui.HymanifestCompletionProposal>();
    for (EEnumLiteral literal : enumLiterals) {
        String unResolvedLiteral = literal.getLiteral();
        // use token resolver to get de-resolved value of the literal
        eu.hyvar.mspl.manifest.resource.hymanifest.IHymanifestTokenResolverFactory tokenResolverFactory = metaInformation.getTokenResolverFactory();
        eu.hyvar.mspl.manifest.resource.hymanifest.IHymanifestTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver(expectedFeature.getTokenName());
        String resolvedLiteral = tokenResolver.deResolve(unResolvedLiteral, expectedFeature.getFeature(), container);
        boolean matchesPrefix = matches(resolvedLiteral, prefix);
        result.add(new eu.hyvar.mspl.manifest.resource.hymanifest.ui.HymanifestCompletionProposal(expectedTerminal, resolvedLiteral, prefix, matchesPrefix, expectedFeature.getFeature(), container));
    }
    return result;
}
项目:dynemf    文件:EObjectWrapper.java   
/**
 * Gets the value of an attribute/reference wrapped in a
 * {@link ValueWrapper}.
 * 
 * @param name the name of the attribute/reference to navigate
 * @return a new instance of ValueWrapper wrapping the result
 */
@SuppressWarnings("unchecked")
public ValueWrapper<?> property(String name) {
    if (obj == null) {
        throw new RuntimeException("Object has not been loaded (no model given)");
    }
    EFeatureWrapper efeature = eFeature(name);
    EStructuralFeature feature = efeature.result();
    Object o = obj.eGet(feature);

    if (o == null) {
        return NullValueWrapper.NULL;
    }

    if (o instanceof EObject) {
        return obj((EObject) o);
    } else if (o instanceof List<?>) {
        List<EObjectWrapper<?>> values = new LinkedList<>();
        for (EObject e : (List<EObject>) o) {
            values.add(obj(e));
        }
        return new ListWrapper((EList<EObject>) o, values);
    } else if (o instanceof EEnumLiteral) {
        return new EEnumLiteralWrapper((EEnumLiteral) o);
    } else {
        return new ValueWrapper<Object>(o);
    }
}