本文整理匯總了Java中org.eclipse.emf.ecore.EReference.getEReferenceType方法的典型用法代碼示例。如果您正苦於以下問題:Java EReference.getEReferenceType方法的具體用法?Java EReference.getEReferenceType怎麽用?Java EReference.getEReferenceType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.emf.ecore.EReference
的用法示例。
在下文中一共展示了EReference.getEReferenceType方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getEObject
import org.eclipse.emf.ecore.EReference; //導入方法依賴的package包/類
@Override
protected EObject getEObject(final List<String> uriFragmentPath) {
if (uriFragmentPath.size() != 2) {
throw new AssertionError("Invalid uri fragment path:" + uriFragmentPath.stream().collect(Collectors.joining("/")));
}
if (uriFragmentPath.size() == 2) {
final EObject rootObject = getEObjectForURIFragmentRootSegment("");
final String featureName = uriFragmentPath.get(0);
final EReference feature = (EReference) rootObject.eClass().getEStructuralFeature(featureName);
final EClass eReferenceType = feature.getEReferenceType();
if (IDENTIFIABLE_ELEMENT.isSuperTypeOf(eReferenceType)) {
@SuppressWarnings("unchecked") final EList<EObject> children = (EList<EObject>) rootObject.eGet(feature);
final String name = uriFragmentPath.get(1);
return children.stream()
.filter(eObject -> name.equals(eObject.eGet(IDENTIFIABLE_ELEMENT__NAME)))
.findFirst()
.orElse(null);
}
}
return null;
}
示例2: getLinkedObjects
import org.eclipse.emf.ecore.EReference; //導入方法依賴的package包/類
@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
final EClass requiredType = ref.getEReferenceType();
if (requiredType == null)
return Collections.<EObject> emptyList();
final String crossRefString = getCrossRefNodeAsString(context, ref, node);
if (crossRefString != null && !crossRefString.equals("")) {
final IScope scope = getScope(context, ref);
QualifiedName qualifiedLinkName = qualifiedNameConverter.toQualifiedName(crossRefString);
IEObjectDescription eObjectDescription = scope.getSingleElement(qualifiedLinkName);
if (IEObjectDescriptionWithError.isErrorDescription(eObjectDescription) && context.eResource() != null
&& !n4jsCore.isNoValidate(context.eResource().getURI())) {
addError(context, node, IEObjectDescriptionWithError.getDescriptionWithError(eObjectDescription));
} else if (eObjectDescription instanceof UnresolvableObjectDescription) {
return Collections.<EObject> singletonList((EObject) context.eGet(ref, false));
}
if (eObjectDescription != null) {
EObject candidate = eObjectDescription.getEObjectOrProxy();
if (!candidate.eIsProxy() && candidate.eResource() == null) {
// Error is necessary since EMF catches all exceptions in EcoreUtil#resolve
throw new AssertionError("Found an instance without resource and without URI");
}
return Collections.singletonList(candidate);
}
}
return Collections.emptyList();
}