本文整理匯總了Java中org.eclipse.emf.ecore.EAttribute.getEType方法的典型用法代碼示例。如果您正苦於以下問題:Java EAttribute.getEType方法的具體用法?Java EAttribute.getEType怎麽用?Java EAttribute.getEType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.emf.ecore.EAttribute
的用法示例。
在下文中一共展示了EAttribute.getEType方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: visitAttribute
import org.eclipse.emf.ecore.EAttribute; //導入方法依賴的package包/類
private void visitAttribute(TypeModel mm, Class cmClass, EAttribute eAttribute) {
Name attrName = Name.getName(eAttribute.getName());
// Get the correct type
Type attribType = null;
if (eAttribute.getEType() instanceof EEnum) {
attribType = visitEnum(mm, (EEnum) eAttribute.getEType());
} else if (eAttribute.getEType() instanceof EDataType) {
attribType = visitDataType(mm, (EDataType) eAttribute.getEType());
if (attribType == null) {
addMessage(new Message("Unsupported EDataType " + eAttribute.getEType()
.getName(), MessageType.ERROR));
}
} else {
// Cannot handle other types as attribute
addMessage(new Message("Invalid type as attribute " + eAttribute, MessageType.ERROR));
}
if (attribType == null) {
// error message already generated
return;
}
// Handle container type
if (eAttribute.getUpperBound() > 1 || eAttribute.getUpperBound() == -1) {
Kind type = eAttribute.isUnique() ? (eAttribute.isOrdered() ? Kind.ORD : Kind.SET) : // Unique
(eAttribute.isOrdered() ? Kind.SEQ : Kind.BAG); // Non-unique
attribType = new Container(type, attribType);
}
if (eAttribute.getDefaultValue() != null) {
Object value = eAttribute.getDefaultValue();
// Ignore default value defined by type
if (value != eAttribute.getEType()
.getDefaultValue()) {
try {
Value defaultVal = objectToDataType(mm, attribType, value);
if (!attribType.acceptValue(defaultVal)) {
addMessage(
new Message("Incorrect value type of default value " + defaultVal,
MessageType.ERROR));
} else {
mm.addProperty(new DefaultValueProperty(cmClass, attrName, defaultVal));
}
} catch (InvalidTypeException e) {
addMessage(new Message(e.getMessage(), MessageType.ERROR));
}
}
}
// Add the attribute
cmClass.addField(new Field(Name.getName(eAttribute.getName()), attribType,
eAttribute.getLowerBound(), eAttribute.getUpperBound()));
}