本文整理汇总了Java中org.eclipse.emf.ecore.EAttribute.isMany方法的典型用法代码示例。如果您正苦于以下问题:Java EAttribute.isMany方法的具体用法?Java EAttribute.isMany怎么用?Java EAttribute.isMany使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.ecore.EAttribute
的用法示例。
在下文中一共展示了EAttribute.isMany方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setAttribute
import org.eclipse.emf.ecore.EAttribute; //导入方法依赖的package包/类
private void setAttribute(final EObject eObject, final EAttribute eAttribute, final List<RAMLParser.IdContext> valueTokens) {
if (eAttribute.isMany()) {
final List<Object> values = valueTokens.stream()
.map(v -> createFromString(eAttribute, v))
.collect(Collectors.toList());
eObject.eSet(eAttribute, values);
} else {
final String messagePattern = "Trying to set attribute {0} with many values";
if (valueTokens.isEmpty()) {
scope.addError(messagePattern, eAttribute);
} else {
scope.addError(messagePattern + " at {1}", eAttribute, valueTokens.get(0).getStart());
}
}
}
示例2: mergeAttributes
import org.eclipse.emf.ecore.EAttribute; //导入方法依赖的package包/类
private void mergeAttributes(final EObject extension, final EObject extendsEObject) {
final List<EAttribute> commonAttributes = new ArrayList<>();
commonAttributes.addAll(extension.eClass().getEAllAttributes());
commonAttributes.retainAll(extendsEObject.eClass().getEAllAttributes());
final List<EAttribute> nonDerivedAttributes = commonAttributes.stream()
.filter(a -> !a.isDerived())
.collect(Collectors.toList());
for (final EAttribute attribute : nonDerivedAttributes) {
if (extension.eIsSet(attribute)) {
final Object attributeValue = extension.eGet(attribute);
if (attribute.isMany()) {
final List<Object> values = (List<Object>) extendsEObject.eGet(attribute);
final List<Object> mergeAttributeValues = (List<Object>) attributeValue;
for (final Object mergeAttributeValue : mergeAttributeValues) {
if (!values.contains(mergeAttributeValue)) {
values.add(mergeAttributeValue);
}
}
} else {
extendsEObject.eSet(attribute, attributeValue);
}
}
}
}