Java Code Examples for org.eclipse.emf.ecore.EEnum#setName()

The following examples show how to use org.eclipse.emf.ecore.EEnum#setName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Schema.java    From BIMserver with GNU Affero General Public License v3.0 5 votes vote down vote up
public EEnum createEEnum(EPackage ePackage, String name) {
	EEnum eEnum = EcoreFactory.eINSTANCE.createEEnum();
	changes.add(new NewEnumChange(eEnum));
	ePackage.getEClassifiers().add(eEnum);
	eEnum.setName(name);
	return eEnum;
}
 
Example 2
Source File: Express2EMF.java    From BIMserver with GNU Affero General Public License v3.0 5 votes vote down vote up
private void addEnumerations() {
	Iterator<DefinedType> typeIter = schema.getTypes().iterator();
	while (typeIter.hasNext()) {
		DefinedType type = typeIter.next();
		if (type instanceof EnumerationType) {
			EEnum enumeration = eFactory.createEEnum();
			enumeration.setName(type.getName());

			EEnumLiteral nullValue = eFactory.createEEnumLiteral();
			nullValue.setName("NULL");
			nullValue.setLiteral("NULL");
			nullValue.setValue(0);
			enumeration.getELiterals().add(nullValue);

			int counter = 1;
			Iterator<String> values = ((EnumerationType) type).getElements().iterator();
			while (values.hasNext()) {
				String stringVal = values.next();
				if (!stringVal.equals("NULL")) {
					EEnumLiteral value = eFactory.createEEnumLiteral();
					value.setName(stringVal);
					value.setLiteral(stringVal);
					value.setValue(counter);
					counter++;
					enumeration.getELiterals().add(value);
				}
			}
			schemaPack.getEClassifiers().add(enumeration);
		}
	}
}