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


Java EReference.getEOpposite方法代碼示例

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


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

示例1: initOppositeInfo

import org.eclipse.emf.ecore.EReference; //導入方法依賴的package包/類
private void initOppositeInfo() {
	for (EClassifier eClassifier : ePackage.getEClassifiers()) {
		if (eClassifier instanceof EClass) {
			EClass eClass = (EClass)eClassifier;
			boolean hasOpposites = false;
			boolean hasManyOpposites = false;
			for (EReference eReference : eClass.getEAllReferences()) {
				if (eReference.getEOpposite() != null) {
					hasOpposites = true;
					if (eReference.isMany()) {
						hasManyOpposites = true;
					}
				}
			}
			oppositeInfos.put(eClass, new OppositeInfo(hasOpposites, hasManyOpposites));
		}
	}
}
 
開發者ID:shenan4321,項目名稱:BIMplatform,代碼行數:19,代碼來源:PackageMetaData.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


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