public LightweightTypeReference convertToList(final ArrayTypeReference type) { ITypeReferenceOwner owner = type.getOwner(); return owner.newReferenceTo(List.class, new TypeReferenceInitializer<ParameterizedTypeReference>() { @Override public LightweightTypeReference enhance(ParameterizedTypeReference reference) { LightweightTypeReference componentType = type.getComponentType(); LightweightTypeReference wrapper = componentType.getWrapperTypeIfPrimitive(); reference.addTypeArgument(wrapper); return reference; } }); }
@Override public LightweightTypeReference getRawTypeReference() { LightweightTypeReference rawComponent = component.getRawTypeReference(); if (rawComponent == component) { return this; } return getOwner().newArrayTypeReference(rawComponent); }
@Override protected List<LightweightTypeReference> getSuperTypes(TypeParameterSubstitutor<?> substitutor) { List<LightweightTypeReference> componentSuperTypes = component.getSuperTypes(substitutor); ITypeReferenceOwner owner = getOwner(); if (!componentSuperTypes.isEmpty()) { List<LightweightTypeReference> result = Lists.newArrayListWithCapacity(componentSuperTypes.size()); for(LightweightTypeReference componentSuperType: componentSuperTypes) { result.add(owner.newArrayTypeReference(componentSuperType)); } return result; } List<LightweightTypeReference> result = Lists.newArrayListWithCapacity(2); result.add(owner.newParameterizedTypeReference(findNonNullType(Cloneable.class))); result.add(owner.newParameterizedTypeReference(findNonNullType(Serializable.class))); return result; }
@Override /* @Nullable */ public LightweightTypeReference getSuperType(Class<?> rawType) { if (isType(rawType)) { return this; } Class<?> rawComponentType = rawType.getComponentType(); if (rawComponentType == null) { if (Object.class.equals(rawType) || Cloneable.class.equals(rawType) || Serializable.class.equals(rawType)) { return internalFindTopLevelType(rawType); } return null; } LightweightTypeReference resultComponent = component.getSuperType(rawComponentType); if (resultComponent == null) { return null; } return getOwner().newArrayTypeReference(resultComponent); }
@Override /* @Nullable */ public LightweightTypeReference getSuperType(JvmType rawType) { if (rawType.eClass() == TypesPackage.Literals.JVM_ARRAY_TYPE) { JvmComponentType rawComponentType = ((JvmArrayType) rawType).getComponentType(); LightweightTypeReference result = component.getSuperType(rawComponentType); if (result == null) { return null; } if (result == component) return this; return getOwner().newArrayTypeReference(result); } else if (rawType.eClass() == TypesPackage.Literals.JVM_GENERIC_TYPE) { String identifier = rawType.getIdentifier(); if (Object.class.getName().equals(identifier) || Cloneable.class.getName().equals(identifier) || Serializable.class.getName().equals(identifier)) { return getOwner().newParameterizedTypeReference(rawType); } } return null; }
@Override public LightweightTypeReference getNamedType() { if (isAnonymous()) { return getOwner().newArrayTypeReference(component.getNamedType()); } return super.getNamedType(); }
@Override protected ArrayTypeReference doVisitArrayTypeReference(ArrayTypeReference reference, ResourceSet resourceSet) { if (reference.isRawType()) return reference; LightweightTypeReference componentType = reference.getComponentType(); LightweightTypeReference rawComponentType = componentType.accept(this, resourceSet); return reference.getOwner().newArrayTypeReference(rawComponentType); }
null, -1, null)); state.refineExpectedType(value, array.getOwner().newArrayTypeReference(primitiveComponentType));