本文整理匯總了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));
}
}
}
示例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) + ".");
}