public TypeInformation<?> getReturnType(Method method) { Assert.notNull(method); return createInfo(method.getGenericReturnType()); }
public List<TypeInformation<?>> getParameterTypes(Method method) { Assert.notNull(method); Type[] parameterTypes = method.getGenericParameterTypes(); List<TypeInformation<?>> result = new ArrayList<TypeInformation<?>>(parameterTypes.length); for (Type type : parameterTypes) { result.add(createInfo(type)); } return result; }
public TypeInformation<?> getReturnType(Method method) { Assert.notNull(method, "Method must not be null!"); return createInfo(method.getGenericReturnType()); }
public List<TypeInformation<?>> getParameterTypes(Constructor<?> constructor) { Assert.notNull(constructor); List<TypeInformation<?>> result = new ArrayList<TypeInformation<?>>(); for (Type type : constructor.getGenericParameterTypes()) { result.add(createInfo(type)); } return result; }
public List<TypeInformation<?>> getParameterTypes(Constructor<?> constructor) { Assert.notNull(constructor, "Constructor must not be null!"); Type[] types = constructor.getGenericParameterTypes(); List<TypeInformation<?>> result = new ArrayList<>(types.length); for (Type parameterType : types) { result.add(createInfo(parameterType)); } return result; }
@Override protected TypeInformation<?> createInfo(Type fieldType) { if (parent.getType().equals(fieldType)) { return parent; } return super.createInfo(fieldType); }
private TypeInformation<?> getTypeArgument(Class<?> type, Class<?> bound, int index) { Class<?>[] arguments = GenericTypeResolver.resolveTypeArguments(type, bound); return arguments == null ? null : createInfo(arguments[index]); }
@Override protected TypeInformation<?> createInfo(Type fieldType) { if (parent.getType().equals(fieldType)) { return parent; } return super.createInfo(fieldType); }
/** * Returns the {@link TypeInformation} for the given atomic field. Will inspect fields first and return the type of a * field if available. Otherwise it will fall back to a {@link PropertyDescriptor}. * * @see #getGenericType(PropertyDescriptor) * @param fieldname * @return */ @SuppressWarnings("null") private Optional<TypeInformation<?>> getPropertyInformation(String fieldname) { Class<?> rawType = getType(); Field field = ReflectionUtils.findField(rawType, fieldname); if (field != null) { return Optional.of(createInfo(field.getGenericType())); } return findPropertyDescriptor(rawType, fieldname).map(it -> createInfo(getGenericType(it))); }
/** * Returns the {@link TypeInformation} for the given atomic field. Will inspect fields first and return the type of a * field if available. Otherwise it will fall back to a {@link PropertyDescriptor}. * * @see #getGenericType(PropertyDescriptor) * @param fieldname * @return */ private TypeInformation<?> getPropertyInformation(String fieldname) { Class<?> type = getType(); Field field = ReflectionUtils.findField(type, fieldname); if (field != null) { return createInfo(field.getGenericType()); } PropertyDescriptor descriptor = BeanUtils.getPropertyDescriptor(type, fieldname); return descriptor == null ? null : createInfo(getGenericType(descriptor)); }
@Nullable private TypeInformation<?> getTypeArgument(Class<?> bound, int index) { Class<?>[] arguments = GenericTypeResolver.resolveTypeArguments(getType(), bound); if (arguments == null) { return getSuperTypeInformation(bound) instanceof ParameterizedTypeInformation ? ClassTypeInformation.OBJECT : null; } return createInfo(arguments[index]); }
public TypeInformation<?> getSuperTypeInformation(Class<?> superType) { Class<?> type = getType(); if (!superType.isAssignableFrom(type)) { return null; } if (getType().equals(superType)) { return this; } List<Type> candidates = new ArrayList<Type>(); Type genericSuperclass = type.getGenericSuperclass(); if (genericSuperclass != null) { candidates.add(genericSuperclass); } candidates.addAll(Arrays.asList(type.getGenericInterfaces())); for (Type candidate : candidates) { TypeInformation<?> candidateInfo = createInfo(candidate); if (superType.equals(candidateInfo.getType())) { return candidateInfo; } else { TypeInformation<?> nestedSuperType = candidateInfo.getSuperTypeInformation(superType); if (nestedSuperType != null) { return nestedSuperType; } } } return null; }
public TypeInformation<?> getComponentType() { Class<S> rawType = getType(); if (rawType.isArray()) { return createInfo(rawType.getComponentType()); } if (isMap()) { return getTypeArgument(rawType, Map.class, 0); } if (Iterable.class.isAssignableFrom(rawType)) { return getTypeArgument(rawType, Iterable.class, 0); } List<TypeInformation<?>> arguments = getTypeArguments(); if (arguments.size() > 0) { return arguments.get(0); } return null; }
@Nullable public TypeInformation<?> getSuperTypeInformation(Class<?> superType) { Class<?> rawType = getType(); if (!superType.isAssignableFrom(rawType)) { return null; } if (getType().equals(superType)) { return this; } List<Type> candidates = new ArrayList<>(); Type genericSuperclass = rawType.getGenericSuperclass(); if (genericSuperclass != null) { candidates.add(genericSuperclass); } candidates.addAll(Arrays.asList(rawType.getGenericInterfaces())); for (Type candidate : candidates) { TypeInformation<?> candidateInfo = createInfo(candidate); if (superType.equals(candidateInfo.getType())) { return candidateInfo; } else { TypeInformation<?> nestedSuperType = candidateInfo.getSuperTypeInformation(superType); if (nestedSuperType != null) { return nestedSuperType; } } } return null; }
@Nullable protected TypeInformation<?> doGetComponentType() { Class<S> rawType = getType(); if (rawType.isArray()) { return createInfo(rawType.getComponentType()); } if (isMap()) { return getTypeArgument(getBaseType(MAP_TYPES), 0); } if (Iterable.class.isAssignableFrom(rawType)) { return getTypeArgument(Iterable.class, 0); } List<TypeInformation<?>> arguments = getTypeArguments(); return arguments.size() > 0 ? arguments.get(0) : null; }
@Override @SuppressWarnings("unchecked") public TypeInformation<? extends S> specialize(ClassTypeInformation<?> type) { Assert.isTrue(getType().isAssignableFrom(type.getType()), String.format("%s must be assignable from %s", getType(), type.getType())); List<TypeInformation<?>> arguments = getTypeArguments(); return (TypeInformation<? extends S>) (arguments.isEmpty() ? type : createInfo(new SyntheticParamterizedType(type, arguments))); }
return createInfo(bounds[0]); return createInfo(bounds[0]);
return createInfo(bounds[0]); return createInfo(bounds[0]);