public ElementDescriptorImpl(Type type, Set<ConstraintDescriptorImpl<?>> constraintDescriptors, boolean defaultGroupSequenceRedefined, List<Class<?>> defaultGroupSequence) { this.type = (Class<?>) TypeHelper.getErasedType( type ); this.constraintDescriptors = Collections.unmodifiableSet( constraintDescriptors ); this.defaultGroupSequenceRedefined = defaultGroupSequenceRedefined; this.defaultGroupSequence = Collections.unmodifiableList( defaultGroupSequence ); }
/** * @param member The {@code Member} instance for which to retrieve the type. * * @return Returns the {@code Type} of the given {@code Field} or {@code Method}. * * @throws IllegalArgumentException in case {@code member} is not a {@code Field} or {@code Method}. */ public static Type typeOf(Member member) { Type type; if ( member instanceof Field ) { type = ( (Field) member ).getGenericType(); } else if ( member instanceof Method ) { type = ( (Method) member ).getGenericReturnType(); } else if ( member instanceof Constructor<?> ) { type = member.getDeclaringClass(); } //TODO HV-571 change log method name else { throw LOG.getMemberIsNeitherAFieldNorAMethodException( member ); } if ( type instanceof TypeVariable ) { type = TypeHelper.getErasedType( type ); } return type; }
public ElementDescriptorImpl(Type type, Set<ConstraintDescriptorImpl<?>> constraintDescriptors, boolean defaultGroupSequenceRedefined, List<Class<?>> defaultGroupSequence) { this.type = (Class<?>) TypeHelper.getErasedType( type ); this.constraintDescriptors = CollectionHelper.toImmutableSet( constraintDescriptors ); this.defaultGroupSequenceRedefined = defaultGroupSequenceRedefined; this.defaultGroupSequence = CollectionHelper.toImmutableList( defaultGroupSequence ); }
Type rawType = ( (ParameterizedType) type ).getRawType(); return getErasedType( rawType ); Type erasedComponentType = getErasedType( componentType ); Type[] bounds = ( (TypeVariable<?>) type ).getBounds(); return getErasedType( bounds[0] ); Type[] upperBounds = ( (WildcardType) type ).getUpperBounds(); return getErasedType( upperBounds[0] );
/** * @param member The <code>Member</code> instance for which to retrieve the type. * * @return Returns the <code>Type</code> of the given <code>Field</code> or <code>Method</code>. * * @throws IllegalArgumentException in case <code>member</code> is not a <code>Field</code> or <code>Method</code>. */ public static Type typeOf(Member member) { Type type; if ( member instanceof Field ) { type = ( (Field) member ).getGenericType(); } else if ( member instanceof Method ) { type = ( (Method) member ).getGenericReturnType(); } else if ( member instanceof Constructor<?> ) { type = member.getDeclaringClass(); } //TODO HV-571 change log method name else { throw log.getMemberIsNeitherAFieldNorAMethodException( member ); } if ( type instanceof TypeVariable ) { type = TypeHelper.getErasedType( type ); } return type; }
/** * Gets the erased type of the specified type. * * @param type the type to perform erasure on * * @return the erased type, never a parameterized type nor a type variable * * @see <a href="http://docs.oracle.com/javase/specs/jls/se6/html/typesValues.html#4.6">4.6 Type Erasure</a> */ public static Type getErasedType(Type type) { // the erasure of a parameterized type G<T1, ... ,Tn> is |G| if ( type instanceof ParameterizedType ) { Type rawType = ( (ParameterizedType) type ).getRawType(); return getErasedType( rawType ); } // TODO: the erasure of a nested type T.C is |T|.C // the erasure of an array type T[] is |T|[] if ( isArray( type ) ) { Type componentType = getComponentType( type ); Type erasedComponentType = getErasedType( componentType ); return getArrayType( erasedComponentType ); } // the erasure of a type variable is the erasure of its leftmost bound if ( type instanceof TypeVariable<?> ) { Type[] bounds = ( (TypeVariable<?>) type ).getBounds(); return getErasedType( bounds[0] ); } // the erasure of every other type is the type itself return type; }
public static Class<?> getErasedReferenceType(Type type) { Contracts.assertTrue( isReferenceType( type ), "type is not a reference type: %s", type ); return (Class<?>) getErasedType( type ); }
private static Class<?> getErasedReferenceType(Type type) { Contracts.assertTrue( isReferenceType( type ), "type is not a reference type: " + type ); return (Class<?>) getErasedType( type ); }
/** * Returns the type of the parameter of the given method with the given parameter index. * * @param executable The executable of interest. * @param parameterIndex The index of the parameter for which the type should be returned. * * @return The erased type. */ public static Type typeOf(Executable executable, int parameterIndex) { Type[] genericParameterTypes = executable.getGenericParameterTypes(); // getGenericParameterTypes() doesn't return synthetic parameters; in this case fall back to getParameterTypes() if ( parameterIndex >= genericParameterTypes.length ) { genericParameterTypes = executable.getParameterTypes(); } Type type = genericParameterTypes[parameterIndex]; if ( type instanceof TypeVariable ) { type = TypeHelper.getErasedType( type ); } return type; }
/** * Returns the type of the parameter of the given method with the given parameter index. * * @param executable The executable of interest. * @param parameterIndex The index of the parameter for which the type should be returned. * * @return The erased type. */ public static Type typeOf(ExecutableElement executable, int parameterIndex) { Type[] genericParameterTypes = executable.getGenericParameterTypes(); // getGenericParameterTypes() doesn't return synthetic parameters; in this case fall back to getParameterTypes() if ( parameterIndex >= genericParameterTypes.length ) { genericParameterTypes = executable.getParameterTypes(); } Type type = genericParameterTypes[parameterIndex]; if ( type instanceof TypeVariable ) { type = TypeHelper.getErasedType( type ); } return type; }
Class<? extends ValueExtractor> extractorImplementationType) { AnnotatedType containerType = valueExtractorDefinition.getAnnotatedActualTypeArguments()[0]; Class<?> containerTypeRaw = (Class<?>) TypeHelper.getErasedType( containerType.getType() );
TypeHelper.getErasedType( parameterMetaData.getType() ), valueType ) ) {
TypeHelper.getErasedType( parameterMetaData.getType() ), valueType ) ) {