本文整理匯總了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);
}
}
}
}