/** * {@inheritDoc} */ @SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST", justification = "The implicit field type casting is not understood by Findbugs") public AnnotationList getDeclaredAnnotations() { Annotation[][] annotation = parameterAnnotationSource.getParameterAnnotations(); MethodDescription.InDefinedShape declaringMethod = getDeclaringMethod(); if (annotation.length != declaringMethod.getParameters().size() && declaringMethod.getDeclaringType().isInnerClass()) { return index == 0 ? new AnnotationList.Empty() : new AnnotationList.ForLoadedAnnotations(annotation[index - 1]); } else { return new AnnotationList.ForLoadedAnnotations(annotation[index]); } } }
/** * Returns a builder with the additional annotation array property. * * @param property The name of the property to define. * @param annotationType The type of the annotations, i.e. the component type of the enumeration array. * @param annotation The annotation values to be contained by the array. * @param <T> The annotation type. * @return A builder with the additional annotation property. */ @SuppressWarnings("unchecked") public <T extends Annotation> Builder defineAnnotationArray(String property, Class<T> annotationType, T... annotation) { return defineAnnotationArray(property, TypeDescription.ForLoadedType.of(annotationType), new AnnotationList.ForLoadedAnnotations(annotation).toArray(new AnnotationDescription[annotation.length])); }
/** * {@inheritDoc} */ public AnnotationList getDeclaredAnnotations() { MethodDescription.InDefinedShape declaringMethod = getDeclaringMethod(); Annotation[][] parameterAnnotation = parameterAnnotationSource.getParameterAnnotations(); if (parameterAnnotation.length != declaringMethod.getParameters().size() && declaringMethod.getDeclaringType().isInnerClass()) { return index == 0 ? new AnnotationList.Empty() : new AnnotationList.ForLoadedAnnotations(parameterAnnotation[index - 1]); } else { return new AnnotationList.ForLoadedAnnotations(parameterAnnotation[index]); } } }
/** * Creates a list of annotation lists representing the given loaded annotations. * * @param annotations The annotations to represent where each dimension is converted into a list. * @return A list of annotation lists representing the given annotations. */ public static List<AnnotationList> asList(Annotation[][] annotations) { List<AnnotationList> result = new ArrayList<AnnotationList>(annotations.length); for (Annotation[] annotation : annotations) { result.add(new ForLoadedAnnotations(annotation)); } return result; }
/** * {@inheritDoc} */ public AnnotationList getDeclaredAnnotations() { return new AnnotationList.ForLoadedAnnotations(aPackage.getDeclaredAnnotations()); }
/** * {@inheritDoc} */ @CachedReturnPlugin.Enhance("declaredAnnotations") public AnnotationList getDeclaredAnnotations() { return new AnnotationList.ForLoadedAnnotations(method.getDeclaredAnnotations()); }
/** * {@inheritDoc} */ @CachedReturnPlugin.Enhance("declaredAnnotations") public AnnotationList getDeclaredAnnotations() { return new AnnotationList.ForLoadedAnnotations(type.getDeclaredAnnotations()); }
/** * Finalizes the build and finalizes the created type as a generic type description. * * @param annotations Type annotations place for the built generic type to declare. * @return A generic type description of the built type. */ public Generic build(List<? extends Annotation> annotations) { return build(new AnnotationList.ForLoadedAnnotations(annotations)); }
/** * {@inheritDoc} */ public Builder<S> annotateType(List<? extends Annotation> annotations) { return annotateType(new AnnotationList.ForLoadedAnnotations(annotations)); }
/** * {@inheritDoc} */ public MethodDefinition<U> annotateMethod(List<? extends Annotation> annotations) { return annotateMethod(new AnnotationList.ForLoadedAnnotations(annotations)); }
/** * {@inheritDoc} */ @CachedReturnPlugin.Enhance("declaredAnnotations") public AnnotationList getDeclaredAnnotations() { return new AnnotationList.ForLoadedAnnotations(field.getDeclaredAnnotations()); }
/** * Creates a matcher that matches none of the given annotations as {@link AnnotationDescription}s * by the {@link java.lang.Object#equals(Object)} method. None of the values must be {@code null}. * * @param value The input values to be compared against. * @param <T> The type of the matched object. * @return A matcher that checks for the equality with any of the given objects. */ public static <T extends AnnotationDescription> ElementMatcher.Junction<T> noneOf(Annotation... value) { return noneOf(new AnnotationList.ForLoadedAnnotations(value)); }
/** * Creates a matcher that matches any of the given annotations as {@link AnnotationDescription}s * by the {@link java.lang.Object#equals(Object)} method. None of the values must be {@code null}. * * @param value The input values to be compared against. * @param <T> The type of the matched object. * @return A matcher that checks for the equality with any of the given objects. */ public static <T extends AnnotationDescription> ElementMatcher.Junction<T> anyOf(Annotation... value) { return anyOf(new AnnotationList.ForLoadedAnnotations(value)); }
/** * {@inheritDoc} */ public TypeVariableDefinition<U> annotateTypeVariable(List<? extends Annotation> annotations) { return annotateTypeVariable(new AnnotationList.ForLoadedAnnotations(annotations)); }
/** * {@inheritDoc} */ @CachedReturnPlugin.Enhance("declaredAnnotations") public AnnotationList getDeclaredAnnotations() { return new AnnotationList.ForLoadedAnnotations(constructor.getDeclaredAnnotations()); }
/** * Transforms this type into the upper bound of a wildcard type. * * @param annotations Type annotations to be declared by the wildcard type. * @return A generic type description of a wildcard type with this builder's type as an upper bound. */ public Generic asWildcardUpperBound(List<? extends Annotation> annotations) { return asWildcardUpperBound(new AnnotationList.ForLoadedAnnotations(annotations)); }
/** * {@inheritDoc} */ public AnnotationList asList() { return new AnnotationList.ForLoadedAnnotations(resolve().getDeclaredAnnotations()); }
/** * {@inheritDoc} */ public Simple.Annotatable<W> annotateParameter(List<? extends Annotation> annotations) { return annotateParameter(new AnnotationList.ForLoadedAnnotations(annotations)); }
/** * {@inheritDoc} */ public ParameterDefinition.Annotatable<W> annotateParameter(List<? extends Annotation> annotations) { return annotateParameter(new AnnotationList.ForLoadedAnnotations(annotations)); }
/** * Transforms this type into the lower bound of a wildcard type. * * @param annotations Type annotations to be declared by the wildcard type. * @return A generic type description of a wildcard type with this builder's type as an lower bound. */ public Generic asWildcardLowerBound(List<? extends Annotation> annotations) { return asWildcardLowerBound(new AnnotationList.ForLoadedAnnotations(annotations)); }