Code example for Annotation

Methods: annotationType

0
 
    protected ValidationException validate(Annotation annotation, View viewToValidate) throws IllegalAccessException, InvocationTargetException {
 
        ValidationException e = null;
 
        DVConstraint constraint = (annotation.annotationType().getAnnotation(DVConstraint.class));
        if (constraint != null) {
 
            String methodName = constraint.value();
            Method validationMethod;
 
            try { 
                validationMethod = getClass().getDeclaredMethod(methodName, new Class[]{annotation.annotationType(), TextView.class});
            } catch (NoSuchMethodException noSuchMethod) {
                throw new RuntimeException(noSuchMethod);
            } 
 
            Object[] args = new Object[]{annotation, viewToValidate};
            e = (ValidationException) validationMethod.invoke(this, args);
        }