public Annotation[] getAnnotations() { return field.getAnnotations(); }
@Override public Annotation[] getAnnotations() { return fField.getAnnotations(); }
private static boolean isRequired(Field field) { for (Annotation annotation : field.getAnnotations()) { if (annotation.annotationType().getSimpleName().equals("Nullable")) { return false; } } return true; }
private static boolean ignore(Field f) { for( Annotation a : f.getAnnotations() ) if( a.annotationType() == Ignore.class ) return true; return false; }
public List<Annotation> callFieldGetAnnotations(Field m) { return Arrays.asList(m.getAnnotations()); } public List<Annotation> callFieldGetDeclaredAnnotations(Field m) {
private Annotation getFactory(Field field) { Annotation[] annotations = field.getAnnotations(); for (Annotation annotation : annotations) { if (factories.containsKey(annotation.annotationType())) { return annotation; } } return null; }
@Override public List<Annotation> getAnnotations() { Annotation[] annotations = null; if (read != null) { annotations = read.getAnnotations(); } else if (field != null) { annotations = field.getAnnotations(); } return annotations != null ? Arrays.asList(annotations) : delegate.getAnnotations(); }
@Override public List<Annotation> getAnnotations() { return ArrayUtils.toUnmodifiableList(field.getAnnotations()); }
private List<Pair<Field, Column>> getFieldColumnPairs() { List<Pair<Field, Column>> fields = new ArrayList<>(); for (Field field : klass.getDeclaredFields()) for (Annotation annotation : field.getAnnotations()) { if (!(annotation instanceof Column)) continue; Column column = (Column) annotation; fields.add(new ImmutablePair<>(field, column)); } return fields; }
try { Field field = getDeclaringClass().getDeclaredField(this.parameterName); Annotation[] fieldAnns = field.getAnnotations(); if (fieldAnns.length > 0) { List<Annotation> merged = new ArrayList<>(anns.length + fieldAnns.length);
/** * Create a new type descriptor from a {@link Field}. * <p>Use this constructor when a source or target conversion point is a field. * @param field the field */ public TypeDescriptor(Field field) { this.resolvableType = ResolvableType.forField(field); this.type = this.resolvableType.resolve(field.getType()); this.annotatedElement = new AnnotatedElementAdapter(field.getAnnotations()); }
/** * Obtain the annotations associated with the wrapped field or method/constructor parameter. */ public Annotation[] getAnnotations() { if (this.field != null) { Annotation[] fieldAnnotations = this.fieldAnnotations; if (fieldAnnotations == null) { fieldAnnotations = this.field.getAnnotations(); this.fieldAnnotations = fieldAnnotations; } return fieldAnnotations; } else { return obtainMethodParameter().getParameterAnnotations(); } }
@Override public void attach(Linker linker) { bindings = new Binding<?>[fields.length]; for (int i = 0; i < fields.length; i++) { Field field = fields[i]; String key = Keys.get(field.getGenericType(), field.getAnnotations(), field); bindings[i] = linker.requestBinding(key, field, loader); } }
/** * Collects field-level parameters from class. * * @param cls is a class for collecting * @param components * @return the collection of supported parameters */ public static List<Parameter> collectFieldParameters(Class<?> cls, Components components, javax.ws.rs.Consumes classConsumes, JsonView jsonViewAnnotation) { final List<Parameter> parameters = new ArrayList<Parameter>(); for (Field field : ReflectionUtils.getDeclaredFields(cls)) { final List<Annotation> annotations = Arrays.asList(field.getAnnotations()); final Type genericType = field.getGenericType(); parameters.addAll(collectParameters(genericType, annotations, components, classConsumes, jsonViewAnnotation)); } return parameters; }
/** * Create a new type descriptor from a {@link Field}. * <p>Use this constructor when a source or target conversion point is a field. * @param field the field */ public TypeDescriptor(Field field) { this.resolvableType = ResolvableType.forField(field); this.type = this.resolvableType.resolve(field.getType()); this.annotatedElement = new AnnotatedElementAdapter(field.getAnnotations()); }
public static AnnotatedElement getAnnotatedElement(Class<?> beanClass, String propertyName, Class<?> propertyClass) { Field field = getFieldOrNull(beanClass, propertyName); Method method = getGetterOrNull(beanClass, propertyName, propertyClass); if (field == null || field.getAnnotations().length == 0) { return (method != null && method.getAnnotations().length > 0) ? method : EMPTY; } else if (method == null || method.getAnnotations().length == 0) { return field; } else { return new Annotations(field, method); } }
/** * Obtain the annotations associated with the wrapped field or method/constructor parameter. */ public Annotation[] getAnnotations() { if (this.field != null) { Annotation[] fieldAnnotations = this.fieldAnnotations; if (fieldAnnotations == null) { fieldAnnotations = this.field.getAnnotations(); this.fieldAnnotations = fieldAnnotations; } return fieldAnnotations; } else { return obtainMethodParameter().getParameterAnnotations(); } }
@Override public void process(Class<?> clazz, Object testInstance) { Field[] fields = clazz.getDeclaredFields(); for (Field field : fields) { boolean alreadyAssigned = false; for(Annotation annotation : field.getAnnotations()) { Object mock = createMockFor(annotation, field); if (mock != null) { throwIfAlreadyAssigned(field, alreadyAssigned); alreadyAssigned = true; try { setField(testInstance, field,mock); } catch (Exception e) { throw new MockitoException("Problems setting field " + field.getName() + " annotated with " + annotation, e); } } } } }
private String fieldKey(String fieldName) throws NoSuchFieldException { Field field = KeysTest.class.getDeclaredField(fieldName); return Keys.get(field.getGenericType(), field.getAnnotations(), field); }
@SuppressWarnings("deprecation") static void processAnnotationDeprecatedWay(AnnotationEngine annotationEngine, Object testClass, Field field) { boolean alreadyAssigned = false; for(Annotation annotation : field.getAnnotations()) { Object mock = annotationEngine.createMockFor(annotation, field); if (mock != null) { throwIfAlreadyAssigned(field, alreadyAssigned); alreadyAssigned = true; try { new FieldSetter(testClass, field).set(mock); } catch (Exception e) { throw new MockitoException("Problems setting field " + field.getName() + " annotated with " + annotation, e); } } } }