private static Class extractClass(Type type) { if ( type instanceof Class ) { return (Class) type; } else if ( type instanceof ParameterizedType ) { return extractClass( ( (ParameterizedType) type ).getRawType() ); } return null; }
private static Type resolveTypeVariable(TypeVariable typeVariable, ParameterizedType context) { Class clazz = extractClass( context.getRawType() ); TypeVariable[] typeParameters = clazz.getTypeParameters(); for ( int idx = 0; idx < typeParameters.length; idx++ ) { if ( typeVariable.getName().equals( typeParameters[idx].getName() ) ) { return resolveType( context.getActualTypeArguments()[idx], context ); } } return typeVariable; }
private ParameterizedType extractAttributeConverterParameterizedType(Type base) { if ( base != null ) { Class clazz = extractClass( base ); List<Type> types = new ArrayList<>(); types.add( clazz.getGenericSuperclass() ); types.addAll( Arrays.asList( clazz.getGenericInterfaces() ) ); for ( Type type : types ) { type = resolveType( type, base ); if ( ParameterizedType.class.isInstance( type ) ) { final ParameterizedType parameterizedType = (ParameterizedType) type; if ( AttributeConverter.class.equals( parameterizedType.getRawType() ) ) { return parameterizedType; } } ParameterizedType parameterizedType = extractAttributeConverterParameterizedType( type ); if ( parameterizedType != null ) { return parameterizedType; } } } return null; }
); entityAttributeType = extractClass( attributeConverterSignature.getActualTypeArguments()[0] ); if ( entityAttributeType == null ) { throw new AnnotationException( databaseColumnType = extractClass(attributeConverterSignature.getActualTypeArguments()[1]); if ( databaseColumnType == null ) { throw new AnnotationException(