private static Class < ? > getSerializerType ( Object instance ) { Type type = instance . getClass ( ) . getGenericInterfaces ( ) [ 0 ] ; if ( type instanceof ParameterizedType ) { Class < ? > cls = null ; Type clsType = ( ( ParameterizedType ) type ) . getActualTypeArguments ( ) [ 0 ] ; if ( clsType instanceof GenericArrayType ) { // Workaround for Java 6 (JDK bug 7151486) cls = Array . newInstance ( ( Class ) ( ( GenericArrayType ) clsType ) . getGenericComponentType ( ) , 0 ) . getClass ( ) ; } else { cls = ( Class < ? > ) clsType ; } if ( Object . class . equals ( cls ) ) { throw new RuntimeException ( "The serializer type can't be object" ) ; } return cls ; } else { throw new RuntimeException ( String . format ( "The serializer class %s is not generic or has an unknown type" , instance . getClass ( ) . getName ( ) ) ) ; } }
Returns the serializer s generic type .