本文整理汇总了Java中org.eclipse.emf.ecore.EObject.eIsSet方法的典型用法代码示例。如果您正苦于以下问题:Java EObject.eIsSet方法的具体用法?Java EObject.eIsSet怎么用?Java EObject.eIsSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.ecore.EObject
的用法示例。
在下文中一共展示了EObject.eIsSet方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mergeAttributes
import org.eclipse.emf.ecore.EObject; //导入方法依赖的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);
}
}
}
}
示例2: objToStrImpl
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
private static void objToStrImpl(Object obj, String indent, Appendable buf) throws Exception {
String innerIdent = INDENT + indent;
if (obj instanceof EObject) {
EObject eobj = (EObject) obj;
buf.append(eobj.eClass().getName()).append(" {\n");
for (EStructuralFeature f : getAllFeatures(eobj.eClass())) {
if (!eobj.eIsSet(f))
continue;
buf.append(innerIdent);
if (f instanceof EReference) {
EReference r = (EReference) f;
if (r.isContainment()) {
buf.append("cref ");
buf.append(f.getEType().getName()).append(SPACE);
buf.append(f.getName()).append(SPACE);
objToStrImpl(eobj.eGet(f), innerIdent, buf);
} else {
buf.append("ref ");
buf.append(f.getEType().getName()).append(SPACE);
buf.append(f.getName()).append(SPACE);
refToStr(eobj, r, innerIdent, buf);
}
} else if (f instanceof EAttribute) {
buf.append("attr ");
buf.append(f.getEType().getName()).append(SPACE);
buf.append(f.getName()).append(SPACE);
// logger.debug(Msg.create("Path:").path(eobj));
Object at = eobj.eGet(f);
if (eobj != at)
objToStrImpl(at, innerIdent, buf);
else
buf.append("<same as container object>");
} else {
buf.append("attr ");
buf.append(f.getEType().getName()).append(SPACE);
buf.append(f.getName()).append(" ??????");
}
buf.append('\n');
}
buf.append(indent).append("}");
return;
}
if (obj instanceof FeatureMap.Entry) {
FeatureMap.Entry e = (FeatureMap.Entry) obj;
buf.append(e.getEStructuralFeature().getEContainingClass().getName());
buf.append(".");
buf.append(e.getEStructuralFeature().getName());
buf.append("->");
objToStrImpl(e.getValue(), innerIdent, buf);
return;
}
if (obj instanceof Collection<?>) {
int counter = 0;
Collection<?> coll = (Collection<?>) obj;
buf.append("[\n");
for (Object o : coll) {
buf.append(innerIdent);
printInt(counter++, coll.size(), buf);
buf.append(": ");
objToStrImpl(o, innerIdent, buf);
buf.append("\n");
}
buf.append(indent + "]");
return;
}
if (obj != null) {
buf.append("'").append(Strings.notNull(obj)).append("'");
return;
}
buf.append("null");
}
示例3: merge
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
private EObject merge(final EObject from, final EObject to, final Collection<Object> visitedObjects) {
if (null == from || null == to) {
return null;
}
// This is against cycles through EReferences.
if (visitedObjects.contains(from) || visitedObjects.contains(to)) {
return to;
}
visitedObjects.add(to);
visitedObjects.add(from);
final Collection<EStructuralFeature> fromFeatures = from.eClass().getEAllStructuralFeatures();
for (final EStructuralFeature feature : fromFeatures) {
if (-1 != to.eClass().getFeatureID(feature) && feature.isChangeable()) {
if (from.eIsSet(feature)) {
final Object fromValue = from.eGet(feature, true);
final Object toValue = to.eGet(feature, true);
if (null == toValue) {
to.eSet(feature, fromValue);
} else {
if (feature.isMany()) {
@SuppressWarnings("unchecked")
final Collection<Object> toManyValue = (Collection<Object>) toValue;
@SuppressWarnings("unchecked")
final Collection<Object> fromManyValue = (Collection<Object>) fromValue;
for (final Iterator<Object> itr = fromManyValue.iterator(); itr.hasNext(); /**/) {
final Object fromElement = itr.next();
if (!contains(toManyValue, fromElement)) {
itr.remove();
toManyValue.add(fromElement);
}
}
} else {
if (feature instanceof EAttribute) {
to.eSet(feature, fromValue);
} else if (feature instanceof EReference) {
to.eSet(feature, merge((EObject) fromValue, (EObject) toValue, visitedObjects));
}
}
}
}
}
}
return to;
}