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