/** * Search for an annotation on a configuration interface method. In * addition to searching the method itself, the {@link #getGetMethod * plain get method} is also searched, as can the {@link * #getMethodType method type} be. * * @param configInterface The configuration interface. * @param method The method. * @param annotationType The annotation type of interest. * @param searchMethodType Whether to search the method type. * @return The annotation, or null. */ public static <T extends Annotation> T getAnnotation(Class<?> configInterface, Method method, Class<T> annotationType, boolean searchMethodType) { T annotation = method.getAnnotation(annotationType); if (annotation == null) { Method getMethod = getGetMethod(configInterface, method); if (getMethod != null) { annotation = getMethod.getAnnotation(annotationType); } if ((annotation == null) && searchMethodType) { String methodName = method.getName(); if (ACCESS_RE.matcher(methodName).matches()) { // Is the annotation present on the method type? Class<?> methodType = getMethodType(method); annotation = methodType.getAnnotation(annotationType); } } } return annotation; }
getMethod = configInterface.getMethod("get" + prop); } catch (NoSuchMethodException ex) { Class<?> methodType = getMethodType(method); try { getMethod = configInterface.getMethod("get" + prop, methodType);
/** * Create a new ConfigSetter instance. * * @param configInterface The configuration interface. * @param method The method. */ public ConfigSetter(Class<?> configInterface, Method method) { super(configInterface, method); Method getMethod = ConfigUtil.getGetMethod(configInterface, method); Preconditions.checkNotNullArgument(getMethod, String.format("Cannot find getter for config \"%s\" property \"%s\"", configInterface.getSimpleName(), getPropertyName())); sourceType = ConfigUtil.getSourceType(configInterface, method); if (!String.class.equals(ConfigUtil.getMethodType(method))) stringifier = TypeStringify.getInstance(configInterface, method); }
Class<?> methodType = ConfigUtil.getMethodType(method); try { Stringify stringify = ConfigUtil.getAnnotation(configInterface, method, Stringify.class, true);