本文整理匯總了Java中org.eclipse.emf.ecore.EReference.isContainment方法的典型用法代碼示例。如果您正苦於以下問題:Java EReference.isContainment方法的具體用法?Java EReference.isContainment怎麽用?Java EReference.isContainment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.emf.ecore.EReference
的用法示例。
在下文中一共展示了EReference.isContainment方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getConnectedEdgesForEObjectManyCase
import org.eclipse.emf.ecore.EReference; //導入方法依賴的package包/類
private void getConnectedEdgesForEObjectManyCase(Node node, final List<Node> allNodes, final List<Edge> result,
EReference currRef, final Object targets) {
final List<Node> targetNodes = new ArrayList<>();
final List<String> targetNodesExternal = new ArrayList<>();
for (Object currTarget : (Collection<?>) targets) {
final Node currTargetNode = GraphUtils.getNodeForElement(currTarget, allNodes);
if (currTargetNode != null)
targetNodes.add(currTargetNode);
else if (currTarget instanceof EObject && ((EObject) currTarget).eIsProxy())
targetNodesExternal.add(EcoreUtil.getURI((EObject) currTarget).toString());
}
if (!targetNodes.isEmpty() || !targetNodesExternal.isEmpty()) {
Edge edge = new Edge(
currRef.getName(),
!currRef.isContainment(),
node,
targetNodes,
targetNodesExternal);
result.add(edge);
}
}
示例2: getConnectedEdgesForEObjectSingleCase
import org.eclipse.emf.ecore.EReference; //導入方法依賴的package包/類
private void getConnectedEdgesForEObjectSingleCase(Node node, final List<Node> allNodes, final List<Edge> result,
EReference currRef, final Object target) {
final Node targetNode = GraphUtils.getNodeForElement(target, allNodes);
final String targetNodeExternal;
if (targetNode == null && ((EObject) target).eIsProxy())
targetNodeExternal = EcoreUtil.getURI((EObject) target).toString();
else
targetNodeExternal = null;
if (targetNode != null || targetNodeExternal != null) {
Edge edge = new Edge(
currRef.getName(),
!currRef.isContainment(),
node,
asCollection(targetNode),
asCollection(targetNodeExternal));
result.add(edge);
}
}
示例3: exposeTypesReferencedBy
import org.eclipse.emf.ecore.EReference; //導入方法依賴的package包/類
private static void exposeTypesReferencedBy(EObject root) {
final TreeIterator<EObject> i = root.eAllContents();
while (i.hasNext()) {
final EObject object = i.next();
for (EReference currRef : object.eClass().getEAllReferences()) {
if (!currRef.isContainment() && !currRef.isContainer()) {
final Object currTarget = object.eGet(currRef);
if (currTarget instanceof Collection<?>) {
for (Object currObj : (Collection<?>) currTarget) {
exposeType(currObj);
}
} else {
exposeType(currTarget);
}
}
}
}
}
示例4: findContainers
import org.eclipse.emf.ecore.EReference; //導入方法依賴的package包/類
public Set<String> findContainers(Collection<EClass> collection, String selectedType) {
Set<String> result = new HashSet<String>();
SigTrace typeTrace;
try {
typeTrace = getSigTraceByType(selectedType);
} catch (TraceException e1) {
return result;
}
EList<EClass> superTypes = typeTrace.getEClass().getEAllSuperTypes();
for (EClass eClass : collection) {
for (EReference eReference : eClass.getEAllReferences()) {
if (eReference.isContainment()) {
try {
if (superTypes.stream()
.anyMatch(s -> s.getName().equals(eReference.getEReferenceType().getName()))) {
result.add(getSigTraceByClassName(eClass.getName()).getSigType());
}
} catch (TraceException e) {
// no need to handle
}
}
}
}
return result;
}
示例5: assertNoDanglingReferences
import org.eclipse.emf.ecore.EReference; //導入方法依賴的package包/類
/**
* Asserts that root and the entire object tree below root does not contain any dangling references, i.e.
* cross-references to target {@link EObject}s that are not contained in a {@link Resource}.
*/
public void assertNoDanglingReferences(EObject root) {
final List<String> errMsgs = new ArrayList<>();
final TreeIterator<EObject> iter = root.eAllContents();
while (iter.hasNext()) {
final EObject currObj = iter.next();
if (currObj != null && !currObj.eIsProxy()) {
for (EReference currRef : currObj.eClass().getEAllReferences()) {
if (!currRef.isContainment() && !currRef.isContainer() && currRef.getEOpposite() == null) {
if (currRef.isMany()) {
@SuppressWarnings("unchecked")
final EList<? extends EObject> targets = (EList<? extends EObject>) currObj.eGet(currRef,
false);
for (EObject currTarget : targets) {
if (isDangling(currTarget)) {
errMsgs.add(getErrorInfoForDanglingEObject(currObj, currRef));
break;
}
}
} else {
final EObject target = (EObject) currObj.eGet(currRef, false);
if (isDangling(target))
errMsgs.add(getErrorInfoForDanglingEObject(currObj, currRef));
}
}
}
}
}
if (!errMsgs.isEmpty())
fail("Expected no dangling references, but found the following: " + Joiner.on("; ").join(errMsgs) + ".");
}
示例6: getContainmentEReference
import org.eclipse.emf.ecore.EReference; //導入方法依賴的package包/類
/**
*
* @param container
* @param eObject
* @return
*/
public static EReference getContainmentEReference(final EObject container,
final EObject eObject) {
for (final EReference eReference : container.eClass().getEAllReferences()) {
if ((eObject.eClass().getName().equals(eReference.getEReferenceType().getName())
|| eObject.eClass().getEAllSuperTypes().stream()
.anyMatch(s -> s.getName().equals(eReference.getEReferenceType().getName())))
&& eReference.isContainment()) {
return eReference;
}
}
return null;
}
示例7: objToStrImpl
import org.eclipse.emf.ecore.EReference; //導入方法依賴的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");
}
示例8: appendSig
import org.eclipse.emf.ecore.EReference; //導入方法依賴的package包/類
private void appendSig(String alias, EClass eClass) {
if (eClass.getName().equals(containerClassName) && ignoreContainer)
return;
// append sig trace
builder.append("-- [email protected]" + alias + "." + eClass.getName() + "\n");
EReference containerRef = getRefToContainer(eClass);
if (containerRef != null) {
String mul = getMultiplicity(containerRef);
if ("set ".equals(mul))
mul = "";
builder.append(mul);
}
// append sig
if (eClass.isAbstract()) {
builder.append("abstract sig " + eClass.getName());
} else {
builder.append("sig " + eClass.getName());
}
// extends parts
if (!eClass.getESuperTypes().isEmpty()) {
builder.append(" extends ");
}
for (Iterator<EClass> it = eClass.getESuperTypes().iterator(); it.hasNext();) {
EClass superClass = it.next();
builder.append(superClass.getName());
if (it.hasNext())
builder.append(", ");
}
builder.append(" {\n");
// relations
for (Iterator<EReference> iterator = eClass.getEReferences().iterator(); iterator.hasNext();) {
EReference eReference = iterator.next();
String sig = eReference.getEType().getName();
if (eReference.isContainment()) {
if (containmentFacts.get(sig) == null)
containmentFacts.put(sig, new ContainmentFact(sig));
containmentFacts.get(sig).addConRel(eClass.getName(), eReference.getName());
}
String multiplicity = getMultiplicity(eReference);
if (multiplicity.isEmpty()) {
multiplicity = "set ";
char c = eClass.getName().toLowerCase().charAt(0);
String fact = "all " + c + ":" + eClass.getName() + " | ";
if (eReference.getLowerBound() != -1)
fact += "#" + c + "." + eReference.getName() + " >= " + eReference.getLowerBound();
if (eReference.getUpperBound() != -1) {
fact += " and #" + c + "." + eReference.getName() + " <= " + eReference.getUpperBound();
}
facts.add(fact);
updateInt(Math.max(eReference.getLowerBound(), eReference.getUpperBound()));
}
// append trace
builder.append(
"\t-- [email protected]" + alias + "." + eClass.getName() + "." + eReference.getName() + "\n");
// append relation
builder.append(
"\t" + eReference.getName() + ": " + multiplicity + eReference.getEType().getName());
if (iterator.hasNext())
builder.append(",");
builder.append("\n");
}
builder.append("}\n\n");
}