Java Code Examples for java.lang.annotation.ElementType#PARAMETER
The following examples show how to use
java.lang.annotation.ElementType#PARAMETER .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnnotationId.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Construct an instance. It initially contains no elements. * * @param declaringType the type declaring the program element. * @param type the annotation type. * @param annotatedElement the program element type to be annotated. * @return an annotation {@code AnnotationId<D,V>} instance. */ public static <D, V> AnnotationId<D, V> get(TypeId<D> declaringType, TypeId<V> type, ElementType annotatedElement) { if (annotatedElement != ElementType.TYPE && annotatedElement != ElementType.METHOD && annotatedElement != ElementType.FIELD && annotatedElement != ElementType.PARAMETER) { throw new IllegalArgumentException("element type is not supported to annotate yet."); } return new AnnotationId<>(declaringType, type, annotatedElement); }
Example 2
Source File: ActionControllerTest.java From dolphin-platform with Apache License 2.0 | 5 votes |
/** Start ElementType Type Related Integration Test */ @Test(dataProvider = ENDPOINTS_DATAPROVIDER, description = "Tests if an public action method with ElementType param can be called") public void testCallPublicMethodWithElementTypeParams(String containerType, String endpoint) { final ElementType value = ElementType.PARAMETER; performActionForElementType(containerType, endpoint, PUBLIC_WITH_ELEMENT_TYPE_PARAM_ACTION, value, new Param(PARAM_NAME, value)); }
Example 3
Source File: AnnotationId.java From dexmaker with Apache License 2.0 | 5 votes |
/** * Construct an instance. It initially contains no elements. * * @param declaringType the type declaring the program element. * @param type the annotation type. * @param annotatedElement the program element type to be annotated. * @return an annotation {@code AnnotationId<D,V>} instance. */ public static <D, V> AnnotationId<D, V> get(TypeId<D> declaringType, TypeId<V> type, ElementType annotatedElement) { if (annotatedElement != ElementType.TYPE && annotatedElement != ElementType.METHOD && annotatedElement != ElementType.FIELD && annotatedElement != ElementType.PARAMETER) { throw new IllegalArgumentException("element type is not supported to annotate yet."); } return new AnnotationId<>(declaringType, type, annotatedElement); }
Example 4
Source File: JAXBUtils.java From cxf with Apache License 2.0 | 5 votes |
public static boolean isJAXB22() { Target t = XmlElement.class.getAnnotation(Target.class); //JAXB 2.2 allows XmlElement on params. for (ElementType et : t.value()) { if (et == ElementType.PARAMETER) { return true; } } return false; }
Example 5
Source File: AnnotationId.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
public static void addToParameters(DexMaker dexMaker, MethodId<?, ?> methodId, List<List<AnnotationId<?,?>>> annotationIds) { ClassDefItem classDefItem = dexMaker.getTypeDeclaration(methodId.declaringType).toClassDefItem(); if (classDefItem == null) { throw new NullPointerException("No class defined item is found"); } CstMethodRef cstMethodRef = methodId.constant; if (cstMethodRef == null) { throw new NullPointerException("Method reference is NULL"); } AnnotationsList list=new AnnotationsList(annotationIds.size()); for (int i=list.size()-1;i>=0;--i) { List<AnnotationId<?, ?>> ids = annotationIds.get(i); if(ids==null) continue; Annotations annotations = new Annotations(); for (AnnotationId<?,?> id:ids) { if (id.annotatedElement != ElementType.PARAMETER) { throw new IllegalStateException("This annotation is not for method"); } if (id.declaringType != methodId.declaringType) { throw new IllegalArgumentException("Method" + methodId + "'s declaring type is inconsistent with" + id); } // Generate CstType CstType cstType = CstType.intern(id.type.ropType); // Generate Annotation Annotation annotation = new Annotation(cstType, AnnotationVisibility.RUNTIME); // Add generated annotation for (NameValuePair nvp : id.elements.values()) { annotation.add(nvp); } annotations.add(annotation); } list.set(i,annotations); } classDefItem.addParameterAnnotations(cstMethodRef,list , dexMaker.getDexFile()); }
Example 6
Source File: TypeQualifierApplications.java From spotbugs with GNU Lesser General Public License v2.1 | 3 votes |
/** * Get the collection of resolved TypeQualifierAnnotations for a given * parameter, taking into account annotations applied to outer scopes (e.g., * enclosing classes and packages.) * * @param o * a method * @param parameter * a parameter (0 == first parameter) * @return Collection of resolved TypeQualifierAnnotations */ private static Collection<TypeQualifierAnnotation> getApplicableScopedApplications(XMethod o, int parameter) { Set<TypeQualifierAnnotation> result = new HashSet<>(); ElementType e = ElementType.PARAMETER; getApplicableScopedApplications(result, o, e); getDirectApplications(result, o, parameter); return result; }