ParameterDeserializer { public static boolean isAnnotatedParameter(Class<?> navigationTarget, Class<? extends Annotation> parameterAnnotation) { if (!HasUrlParameter.class.isAssignableFrom(navigationTarget)) { return false; } String methodName = "setParameter"; assert methodName.equals(ReflectTools .getFunctionalMethod(HasUrlParameter.class).getName()); Type parameterType = GenericTypeReflector.getTypeParameter( navigationTarget, HasUrlParameter.class.getTypeParameters()[0]); if (parameterType == null) { parameterType = GenericTypeReflector.getTypeParameter( navigationTarget.getGenericSuperclass(), HasUrlParameter.class.getTypeParameters()[0]); } if (parameterType == null) { for (Type iface : navigationTarget.getGenericInterfaces()) { parameterType = GenericTypeReflector.getTypeParameter(iface, HasUrlParameter.class.getTypeParameters()[0]); if (parameterType != null) { break; } } } Class<?> parameterClass = GenericTypeReflector.erase(parameterType); return Stream.of(navigationTarget.getMethods()) .filter(method -> methodName.equals(method.getName())) .filter(method -> hasValidParameterTypes(method, parameterClass)) .anyMatch(method -> method.getParameters()[1] .isAnnotationPresent(parameterAnnotation)); } private  ParameterDeserializer(); static T deserializeParameter(Class<T> parameterType,
            String parameter, String targetClass); static Object deserializeRouteParameters(Class<?> navigationTarget,
            List<String> parameters); static void validateWildcardType(Class<?> navigationTarget,
            Class<?> parameterType); static boolean verifyParameters(Class<?> navigationTarget,
            List<String> parameters); static Class<?> getClassType(Class<?> navigationTarget); static boolean isAnnotatedParameter(Class<?> navigationTarget,
            Class<? extends Annotation> parameterAnnotation); static final Set<Class<?>> supportedTypes; }
@Test public void testSimple() { assertFalse(ParameterDeserializer.isAnnotatedParameter(Simple.class, OptionalParameter.class)); assertTrue(ParameterDeserializer.isAnnotatedParameter( SimpleAnnotated.class, OptionalParameter.class)); }
@Test public void testInterface() { assertFalse(ParameterDeserializer.isAnnotatedParameter(Normal.class, OptionalParameter.class)); assertTrue(ParameterDeserializer.isAnnotatedParameter( NormalAnnotated.class, OptionalParameter.class)); }
@Test public void parameterizedViaClass() { assertFalse(ParameterDeserializer.isAnnotatedParameter( ParameterizedViaSuperClass.class, OptionalParameter.class)); assertTrue(ParameterDeserializer.isAnnotatedParameter( ParameterizedAnnotatedViaSuperClass.class, OptionalParameter.class)); }
@Test public void parameterizedViaInterface() { assertFalse(ParameterDeserializer.isAnnotatedParameter( ParameterizedClass.class, OptionalParameter.class)); assertTrue(ParameterDeserializer.isAnnotatedParameter( ParameterizedAnnotatedClass.class, OptionalParameter.class)); }
@Test public void testGenericInterface() { assertFalse(ParameterDeserializer.isAnnotatedParameter(Generic.class, OptionalParameter.class)); assertTrue(ParameterDeserializer.isAnnotatedParameter( GenericAnnotated.class, OptionalParameter.class)); }