public JvmParameterizedTypeReference createTypeRef(JvmType type, JvmTypeReference... typeArgs) { List<JvmTypeReference> typeReferences = Collections.emptyList(); if (typeArgs != null && typeArgs.length > 0) { typeReferences = newArrayListWithCapacity(typeArgs.length); for (int i = 0; i < typeArgs.length; i++) { JvmTypeReference jvmTypeReference = typeArgs[i]; typeReferences.add(EcoreUtil2.clone(jvmTypeReference)); } } if (type instanceof JvmGenericType) { List<JvmTypeParameter> list = ((JvmGenericType) type).getTypeParameters(); if (!typeReferences.isEmpty() && list.size() != typeReferences.size()) { throw new IllegalArgumentException( "The type " + type.getIdentifier() + " expects " + list.size() + " type arguments, but was " + typeReferences.size() + ". Either pass zero arguments (raw type) or the correct number."); } // Raw type -> create type references to type param if (typeReferences.isEmpty() && !list.isEmpty()) { typeReferences = newArrayListWithCapacity(list.size()); for (JvmTypeParameter typeParameter : list) { typeReferences.add(createTypeRef(typeParameter)); } } } JvmParameterizedTypeReference reference = factory.createJvmParameterizedTypeReference(); reference.setType(type); if (!typeReferences.isEmpty()) reference.getArguments().addAll(typeReferences); return reference; }
public List<Class> getCopyOfAddedClasses(DeltaModule delta) { List<Class> addedClasses = DeltaJUtils.getAddedClasses(delta); List<Class> copy = new LinkedList<Class>(); for (Class class1 : addedClasses) { copy.add(EcoreUtil2.clone(class1)); } return copy; }
protected void addClonedMethod(Class classToModify, Method method) { classToModify.getMethods().add(EcoreUtil2.clone(method)); }
protected void addClonedField(Class classToModify, Field field) { classToModify.getFields().add(EcoreUtil2.clone(field)); }