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


Java EReference.getEReferenceType方法代碼示例

本文整理匯總了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;
}
 
開發者ID:vrapio,項目名稱:rest-modeling-framework,代碼行數:23,代碼來源:RamlResource.java

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


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