本文整理汇总了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()));
}