當前位置: 首頁>>代碼示例>>Java>>正文


Java EReference.isContainer方法代碼示例

本文整理匯總了Java中org.eclipse.emf.ecore.EReference.isContainer方法的典型用法代碼示例。如果您正苦於以下問題:Java EReference.isContainer方法的具體用法?Java EReference.isContainer怎麽用?Java EReference.isContainer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.emf.ecore.EReference的用法示例。


在下文中一共展示了EReference.isContainer方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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);
				}
			}
		}
	}
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:19,代碼來源:N4JSPostProcessor.java

示例2: 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) + ".");
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:35,代碼來源:N4JSValidationTestHelper.java

示例3: getConnectedEdgesForEObject

import org.eclipse.emf.ecore.EReference; //導入方法依賴的package包/類
/**
 * Add outgoing references
 */
private void getConnectedEdgesForEObject(Node node, final List<Node> allNodes, final List<Edge> result,
		final EObject eobj) {

	for (EReference currRef : eobj.eClass().getEAllReferences()) {
		if (!currRef.isDerived() && !currRef.isContainer()) {
			if (currRef.isMany()) {
				final Object targets = eobj.eGet(currRef, false);
				if (targets instanceof Collection<?>) {
					getConnectedEdgesForEObjectManyCase(node, allNodes, result, currRef, targets);
				}
			} else {
				final Object target = eobj.eGet(currRef, false);
				if (target instanceof EObject) {
					getConnectedEdgesForEObjectSingleCase(node, allNodes, result, currRef, target);
				}
			}
		}
	}

	// add reference to containing Resource if immediate container is not in graph
	// (required when showing lower-level objects while hiding their ancestors)
	Node nodeForElement = GraphUtils.getNodeForElement(eobj.eContainer(), allNodes);

	if (eobj.eResource() != null && eobj.eContainer() != null && nodeForElement == null) {
		final Node nodeForResource = GraphUtils.getNodeForElement(eobj.eResource(), allNodes);
		if (nodeForResource != null) {
			Edge edge = new Edge(
					"<... containment omitted ...>",
					false, // not a cross-link
					nodeForResource,
					Collections.singletonList(node),
					Collections.emptyList());

			result.add(edge);
		}
	}
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:41,代碼來源:ASTGraphProvider.java


注:本文中的org.eclipse.emf.ecore.EReference.isContainer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。