public Annotation[] getDeclaredAnnotations() { return (Annotation[]) f_annotated.getDeclaredAnnotations(); }
public static Annotation[] callGetDeclaredAnnotations(Field thiz) { return thiz.getDeclaredAnnotations(); }
public Annotation[] getAnnotations() { try { return (this.field != null) ? this.field.getDeclaredAnnotations() : null; } catch (Exception ex) { return null; } }
@Override public Annotation[] getDeclaredAnnotations() { return field.getDeclaredAnnotations(); }
/** Returns an array of {@link Annotation} objects reflecting all annotations declared by this field, * or an empty array if there are none. Does not include inherited annotations. */ public Annotation[] getDeclaredAnnotations () { java.lang.annotation.Annotation[] annotations = field.getDeclaredAnnotations(); Annotation[] result = new Annotation[annotations.length]; for (int i = 0; i < annotations.length; i++) { result[i] = new Annotation(annotations[i]); } return result; }
/** Returns an array of {@link Annotation} objects reflecting all annotations declared by this field, * or an empty array if there are none. Does not include inherited annotations. */ public Annotation[] getDeclaredAnnotations () { java.lang.annotation.Annotation[] annotations = field.getDeclaredAnnotations(); Annotation[] result = new Annotation[annotations.length]; for (int i = 0; i < annotations.length; i++) { result[i] = new Annotation(annotations[i]); } return result; }
public List<Annotation> callFieldGetDeclaredAnnotations(Field m) { return Arrays.asList(m.getDeclaredAnnotations()); } public boolean callFieldIsAnnotationPresent(Field m, Class<? extends Annotation> annotClass) {
for(Field field : cls.getDeclaredFields()){ Class type = field.getType(); String name = field.getName(); Annotation[] annotations = field.getDeclaredAnnotations(); }
/** Returns an {@link Annotation} object reflecting the annotation provided, or null of this field doesn't * have such an annotation. This is a convenience function if the caller knows already which annotation * type he's looking for. */ public Annotation getDeclaredAnnotation (Class<? extends java.lang.annotation.Annotation> annotationType) { java.lang.annotation.Annotation[] annotations = field.getDeclaredAnnotations(); if (annotations == null) { return null; } for (java.lang.annotation.Annotation annotation : annotations) { if (annotation.annotationType().equals(annotationType)) { return new Annotation(annotation); } } return null; }
/** Returns an {@link Annotation} object reflecting the annotation provided, or null of this field doesn't * have such an annotation. This is a convenience function if the caller knows already which annotation * type he's looking for. */ public Annotation getDeclaredAnnotation (Class<? extends java.lang.annotation.Annotation> annotationType) { java.lang.annotation.Annotation[] annotations = field.getDeclaredAnnotations(); if (annotations == null) { return null; } for (java.lang.annotation.Annotation annotation : annotations) { if (annotation.annotationType().equals(annotationType)) { return new Annotation(annotation); } } return null; }
private static Set<Annotation> getQualifierAnnotations(Field field) { // Assume that any annotations other than @MockBean/@SpyBean are qualifiers Annotation[] candidates = field.getDeclaredAnnotations(); Set<Annotation> annotations = new HashSet<>(candidates.length); for (Annotation candidate : candidates) { if (!isMockOrSpyAnnotation(candidate)) { annotations.add(candidate); } } return annotations; }
public List<String> getFieldAnnotationNames(Field field) { return getAnnotationNames(field.getDeclaredAnnotations()); }
public List<String> getFieldAnnotationNames(Field field) { return getAnnotationNames(field.getDeclaredAnnotations()); }
/** * @param name the name of a property key * @return if this property key is deprecated */ public static boolean isDeprecated(String name) { try { PropertyKey key = new PropertyKey(name); Class c = key.getClass(); Field field = c.getDeclaredField(name); Annotation[] annotations = field.getDeclaredAnnotations(); for (Annotation anno : annotations) { if (anno instanceof Deprecated) { return true; } } return false; } catch (NoSuchFieldException e) { return false; } } }
/** * {@inheritDoc} */ @CachedReturnPlugin.Enhance("declaredAnnotations") public AnnotationList getDeclaredAnnotations() { return new AnnotationList.ForLoadedAnnotations(field.getDeclaredAnnotations()); }
/** * Method called to add field mix-ins from given mix-in class (and its fields) * into already collected actual fields (from introspected classes and their * super-classes) */ private void _addFieldMixIns(Class<?> mixInCls, Class<?> targetClass, Map<String,FieldBuilder> fields) { List<Class<?>> parents = ClassUtil.findSuperClasses(mixInCls, targetClass, true); for (Class<?> mixin : parents) { for (Field mixinField : ClassUtil.getDeclaredFields(mixin)) { // there are some dummy things (static, synthetic); better ignore if (!_isIncludableField(mixinField)) { continue; } String name = mixinField.getName(); // anything to mask? (if not, quietly ignore) FieldBuilder b = fields.get(name); if (b != null) { b.annotations = collectAnnotations(b.annotations, mixinField.getDeclaredAnnotations()); } } } }
/** * Method called to add field mix-ins from given mix-in class (and its fields) * into already collected actual fields (from introspected classes and their * super-classes) */ private void _addFieldMixIns(Class<?> mixInCls, Class<?> targetClass, Map<String,FieldBuilder> fields) { List<Class<?>> parents = ClassUtil.findSuperClasses(mixInCls, targetClass, true); for (Class<?> mixin : parents) { for (Field mixinField : ClassUtil.getDeclaredFields(mixin)) { // there are some dummy things (static, synthetic); better ignore if (!_isIncludableField(mixinField)) { continue; } String name = mixinField.getName(); // anything to mask? (if not, quietly ignore) FieldBuilder b = fields.get(name); if (b != null) { b.annotations = collectAnnotations(b.annotations, mixinField.getDeclaredAnnotations()); } } } }
static FFilter Request2FFilter = new FFilter() { @Override boolean involve(Field f) { return contains(API.class, f.getDeclaredAnnotations()); } }; static boolean contains(Class<? extends Annotation> annoType, Annotation[] annotations) {
/** * Gets a method parameter (or a parameter field) name, if the violation raised in it. */ private static Optional<String> getMemberName(ConstraintViolation<?> violation, Invocable invocable) { final List<Path.Node> propertyPath = Lists.of(violation.getPropertyPath()); final int size = propertyPath.size(); if (size < 2) { return Optional.empty(); } final Path.Node parent = propertyPath.get(size - 2); final Path.Node member = propertyPath.get(size - 1); switch (parent.getKind()) { case PARAMETER: // Constraint violation most likely failed with a BeanParam final List<Parameter> parameters = invocable.getParameters(); final Parameter param = parameters.get(parent.as(Path.ParameterNode.class).getParameterIndex()); // Extract the failing *Param annotation inside the Bean Param if (param.getSource().equals(Parameter.Source.BEAN_PARAM)) { final Field field = FieldUtils.getField(param.getRawType(), member.getName(), true); return JerseyParameterNameProvider.getParameterNameFromAnnotations(field.getDeclaredAnnotations()); } break; case METHOD: return Optional.of(member.getName()); default: break; } return Optional.empty(); }
protected AnnotatedField _constructField(Field f) { if (_annotationIntrospector == null) { // when annotation processing is disabled return new AnnotatedField(f, _emptyAnnotationMap()); } return new AnnotatedField(f, _collectRelevantAnnotations(f.getDeclaredAnnotations())); }