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


Java EGenericType.getEClassifier方法代碼示例

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


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

示例1: getBoundGenericType

import org.eclipse.emf.ecore.EGenericType; //導入方法依賴的package包/類
public EGenericType getBoundGenericType(EGenericType genericType, EClass context) {
	ETypeParameter typeParameter = genericType.getETypeParameter();
	if (typeParameter != null) {
		// the reference type is a type parameter
		TypeBindingAcceptor typeBindingAcceptor = new TypeBindingAcceptor();
		addTypeParameterBindingsRecursively(context, typeBindingAcceptor);
		return typeBindingAcceptor.getBoundGenericType(typeParameter);
	} else {
		// the reference type is a generic type
		if (genericType.getEClassifier() == null) {
			throw new IllegalStateException("Either typeParameter or eRawType must be set in EGenericType "
					+ genericType);
		}
		return genericType;
	}
}
 
開發者ID:eclipse,項目名稱:xtext-core,代碼行數:17,代碼來源:EcoreGenericsUtil.java

示例2: addTypeParameterBindingsRecursively

import org.eclipse.emf.ecore.EGenericType; //導入方法依賴的package包/類
protected static void addTypeParameterBindingsRecursively(EClass context, TypeBindingAcceptor bindingAcceptor) {
	for (EGenericType genericSuperType : context.getEGenericSuperTypes()) {
		EClassifier rawSuperType = genericSuperType.getEClassifier();
		EList<EGenericType> typeArguments = genericSuperType.getETypeArguments();
		EList<ETypeParameter> typeParameters = rawSuperType.getETypeParameters();
		if (typeArguments.size() != typeParameters.size()) {
			throw new IllegalStateException(
					"Number of typeArguments does not match number of typeParameters in EGenericType "
							+ genericSuperType);
		}
		for (int i = 0; i < typeArguments.size(); ++i) {
			bindingAcceptor.accept(typeParameters.get(i), typeArguments.get(i));
		}
		if (rawSuperType instanceof EClass) {
			addTypeParameterBindingsRecursively((EClass) rawSuperType, bindingAcceptor);
		}
	}
}
 
開發者ID:eclipse,項目名稱:xtext-core,代碼行數:19,代碼來源:EcoreGenericsUtil.java

示例3: accept

import org.eclipse.emf.ecore.EGenericType; //導入方法依賴的package包/類
public void accept(ETypeParameter typeParameter, EGenericType typeArgument) {
	if(bindings==null) {
		bindings = new HashMap<ETypeParameter, EGenericType>();
	}
	ETypeParameter replacedParameter = typeArgument.getETypeParameter();
	if (replacedParameter != null) {
		EGenericType existingBoundType = bindings.get(replacedParameter);
		if (existingBoundType != null) {
			bindings.remove(replacedParameter);
			bindings.put(typeParameter, existingBoundType);
			return;
		}
	} else {
		if (typeArgument.getEClassifier() == null) {
			throw new IllegalStateException("Either typeParameter or eClassifier must be set in ETypeArgument "
					+ typeArgument);
		}
	}
	bindings.put(typeParameter, typeArgument);
}
 
開發者ID:eclipse,項目名稱:xtext-core,代碼行數:21,代碼來源:EcoreGenericsUtil.java

示例4: getChoiceOfObjects

import org.eclipse.emf.ecore.EGenericType; //導入方法依賴的package包/類
private List<?> getChoiceOfObjects(String parameterName) {
	if (parameterName != null) {
		EParameterDef def = ActivityDictionary.getInstance().getAttributeDef(parameterName);
		if (def != null) {
			EGenericType eGenericType = def.getEGenericType();
			EClassifier classifier = eGenericType.getEClassifier();
			if (classifier instanceof EEnumImpl) {
				EEnumImpl enumImpl = (EEnumImpl) classifier;
				return enumImpl.getELiterals();
			} 
			LogUtil.warn("Row Highlighting only supports Enum types. Not supported for " + parameterName + " (" +classifier+").");
		} else {
			LogUtil.error("Invalid parameter name for Row Highligther: "+ parameterName);
		}
	} 
	return Collections.EMPTY_LIST;
}
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:18,代碼來源:MergeRowHighlightDecorator.java

示例5: getReferenceType

import org.eclipse.emf.ecore.EGenericType; //導入方法依賴的package包/類
public EClass getReferenceType(EReference reference, EClass context) {
	EGenericType genericType = reference.getEGenericType();
	if (genericType == null) {
		return reference.getEReferenceType();
	}
	EGenericType boundGenericType = getBoundGenericType(genericType, context);
	if (boundGenericType.getEClassifier() == null) {
		throw new IllegalStateException("Either typeParameter or eRawType must be set in EGenericType "
				+ genericType);
	}
	return (EClass) boundGenericType.getEClassifier();
}
 
開發者ID:eclipse,項目名稱:xtext-core,代碼行數:13,代碼來源:EcoreGenericsUtil.java

示例6: getEEnum

import org.eclipse.emf.ecore.EGenericType; //導入方法依賴的package包/類
private EEnum getEEnum(String parameterName) {
	EParameterDef def = ActivityDictionary.getInstance().getAttributeDef(parameterName);
	if (def != null) {
		EGenericType eGenericType = def.getEGenericType();
		EClassifier classifier = eGenericType.getEClassifier();
		if (classifier instanceof EEnumImpl) {
			return (EEnum) classifier;
		} 
	}
	return null;
}
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:12,代碼來源:OneOfEachRowDecoratorParameter.java

示例7: convertJavaInstanceTypeName

import org.eclipse.emf.ecore.EGenericType; //導入方法依賴的package包/類
/**
 * Converts a generic type to its Java representation in the result.
 * @param result the target in which to accumulate the result
 * @param eGenericType the generic type to convert.
 */
public void convertJavaInstanceTypeName(StringBuilder result, EGenericType eGenericType)
{
  EClassifier eClassifier = eGenericType.getEClassifier();
  if (eClassifier != null)
  {
    String instanceTypeName = getInstanceTypeName(eClassifier);
    EList<EGenericType> eTypeArguments = eGenericType.getETypeArguments();
    if (eTypeArguments.isEmpty())
    {
      result.append(instanceTypeName);
    }
    else
    {
      int index = instanceTypeName.indexOf('[');
      result.append(index == -1 ? instanceTypeName : instanceTypeName.substring(0, index));
      result.append('<');
      for (int i = 0, size = eTypeArguments.size(); i < size; ++i)
      {
        if (i != 0)
        {
          result.append(", ");
        }
        convertJavaInstanceTypeName(result, eTypeArguments.get(i));
      }
      result.append('>');
      if (index != -1)
      {
        result.append(instanceTypeName.substring(index));
      }
    }
  }
  else
  {
    ETypeParameter eTypeParameter = eGenericType.getETypeParameter();
    if (eTypeParameter != null)
    {
      result.append(eTypeParameter.getName());
    }
    else
    {
      result.append('?');
      EGenericType eUpperBound = eGenericType.getEUpperBound();
      if (eUpperBound != null)
      {
        result.append(" extends ");
        convertJavaInstanceTypeName(result, eUpperBound);
      }
      else
      {
        EGenericType eLowerBound = eGenericType.getELowerBound();
        if (eLowerBound != null)
        {
          result.append(" super ");
          convertJavaInstanceTypeName(result, eLowerBound);
        }
      }
    }
  }
}
 
開發者ID:LangleyStudios,項目名稱:eclipse-avro,代碼行數:65,代碼來源:EcoreUtil.java

示例8: getReifiedType

import org.eclipse.emf.ecore.EGenericType; //導入方法依賴的package包/類
/**
 * @since 2.9
 */
public static EGenericType getReifiedType(EClass eClass, EGenericType eGenericType)
{
  if (eGenericType == null)
  {
    return null;
  }
  else
  {
    Map<ETypeParameter, EGenericType> substitutions = new HashMap<ETypeParameter, EGenericType>();
    for (EGenericType eGenericSuperType : eClass.getEAllGenericSuperTypes())
    {
      EClassifier eClassifier = eGenericSuperType.getEClassifier();
      if (eClassifier != null)
      {
        EList<ETypeParameter> eTypeParameters = eClassifier.getETypeParameters();
        int size = eTypeParameters.size();
        if (size > 0)
        {
          EList<EGenericType> eTypeArguments = eGenericSuperType.getETypeArguments();
          if (eTypeArguments.size() == size)
          {
            for (int i = 0; i < size; ++i)
            {
              substitutions.put(eTypeParameters.get(i), eTypeArguments.get(i));
            }
          }
        }
      }
    }
    if (substitutions.isEmpty() || !hasReifiedType(substitutions, eGenericType))
    {
      return eGenericType;
    }
    else
    {
      EGenericType reifiedType = getReifiedType(substitutions, eGenericType);

      // Ensure that erasure produces the correct type of classifier by creating a container that forces it.
      //
      EObject eContainer = eGenericType.eContainer();
      if (eContainer instanceof EClass || eContainer instanceof EReference)
      {
        EcoreFactory.eINSTANCE.createEReference().setEGenericType(reifiedType);
      }
      else if (eContainer instanceof EAttribute)
      {
        EcoreFactory.eINSTANCE.createEAttribute().setEGenericType(reifiedType);
      }

      return reifiedType;
    }
  }
}
 
開發者ID:LangleyStudios,項目名稱:eclipse-avro,代碼行數:57,代碼來源:EcoreUtil.java

示例9: isEqualArgument

import org.eclipse.emf.ecore.EGenericType; //導入方法依賴的package包/類
protected static boolean isEqualArgument(EGenericType eGenericType1, EGenericType eGenericType2)
{
  // If they are the same instance they are equal.
  //
  if (eGenericType1 == eGenericType2)
  {
    return true;
  }
  // If one is null (but the other is not) then they are not equal.
  //
  else if (eGenericType1 == null || eGenericType2 == null)
  {
    return false;
  }
  else
  {
    // Consider the classifiers in a special way
    // to take into account the fact they they often acts as wrappers for instance type names
    // and that two classifiers that wrap the same instance type name should be considered equal.
    //
    EClassifier eClassifier1 = eGenericType1.getEClassifier();
    EClassifier eClassifier2 = eGenericType2.getEClassifier();

    // If they are the same classifier, they are of course equal.
    //
    if (eClassifier1 != eClassifier2)
    {
      // If they both aren't null...
      //
      if (eClassifier1 != null && eClassifier2 != null)
      {
        // Consider the instance type names they wrap
        // to see if they are non-null and equal.
        //
        String instanceTypeName1 = eClassifier1.getInstanceTypeName();
        String instanceTypeName2 = eClassifier2.getInstanceTypeName();

        // I.e., the classifiers are considered equal if they wrap the same non-null type.
        //
        if (instanceTypeName1 == null || !instanceTypeName1.equals(instanceTypeName2))
        {
          return false;
        }
      }
      // If one is null (but the other is not) then they can't be equal.
      //
      else if (eClassifier1 != null || eClassifier2 != null)
      {
        return false;
      }
    }

    // Type parameters are assumed to be equal.
    //
    ETypeParameter eTypeParameter1 = eGenericType1.getETypeParameter();
    ETypeParameter eTypeParameter2 = eGenericType2.getETypeParameter();
    if (eTypeParameter1 != null && eTypeParameter2 != null)
    {
      return true;
    }

    // The arguments, type parameters, lower bounds and upper bounds must be equal type arguments.
    //
    return
      isEqualArguments(eGenericType1.getETypeArguments(), eGenericType2.getETypeArguments()) &&
        isEqualArgument(eGenericType1.getELowerBound(), eGenericType2.getELowerBound()) &&
        isEqualArgument(eGenericType1.getEUpperBound(), eGenericType2.getEUpperBound());
  }
}
 
開發者ID:LangleyStudios,項目名稱:eclipse-avro,代碼行數:70,代碼來源:EGenericTypeImpl.java


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