List of usage examples for com.google.gwt.core.ext.typeinfo HasAnnotations isAnnotationPresent
boolean isAnnotationPresent(Class<? extends Annotation> annotationClass);
true if this item has an annotation of the specified type. From source file:cc.alcina.framework.entity.gwtsynth.ClientReflectionGenerator.java
License:Apache License
private List<Annotation> getVisibleAnnotations(HasAnnotations ha, List<Class<? extends Annotation>> annotationClasses) { List<Annotation> result = new ArrayList<Annotation>(); for (Class<? extends Annotation> a : annotationClasses) { if (ha.isAnnotationPresent(a)) { result.add(ha.getAnnotation(a)); }/* ww w . j ava2s .c o m*/ } return result; }
From source file:com.github.nmorel.gwtjackson.rebind.CreatorUtils.java
License:Apache License
/** * Returns true when one of the type has the specified annotation * * @param annotation the annotation// w w w .jav a 2 s.c om * @param hasAnnotationsList the types * @param <T> Type of the annotation * * @return true if one the type has the annotation */ public static <T extends Annotation> boolean isAnnotationPresent(Class<T> annotation, List<? extends HasAnnotations> hasAnnotationsList) { for (HasAnnotations accessor : hasAnnotationsList) { if (accessor.isAnnotationPresent(annotation)) { return true; } } return false; }
From source file:com.github.nmorel.gwtjackson.rebind.CreatorUtils.java
License:Apache License
/** * Returns the first occurence of the annotation found on the types * * @param annotation the annotation/* w w w . j a v a 2 s . c om*/ * @param hasAnnotationsList the types * @param <T> Type of the annotation * * @return the first occurence of the annotation found on the types */ public static <T extends Annotation> Optional<T> getAnnotation(Class<T> annotation, List<? extends HasAnnotations> hasAnnotationsList) { for (HasAnnotations accessor : hasAnnotationsList) { if (accessor.isAnnotationPresent(annotation)) { return Optional.of(accessor.getAnnotation(annotation)); } } return Optional.absent(); }
From source file:com.gwtplatform.dispatch.rest.processors.details.HttpVerb.java
License:Apache License
public static boolean isHttpMethod(HasAnnotations hasAnnotations) { for (HttpVerb type : values()) { if (hasAnnotations.isAnnotationPresent(type.getAnnotationClass())) { return true; }/*w w w . j a va 2 s .co m*/ } return false; }
From source file:com.gwtplatform.dispatch.rest.rebind.parameter.HttpParameterType.java
License:Apache License
public static boolean isHttpParameter(HasAnnotations hasAnnotations) { for (HttpParameterType type : values()) { if (hasAnnotations.isAnnotationPresent(type.getAnnotationClass())) { return true; }// w ww . j a v a2 s . c om } return false; }
From source file:com.gwtplatform.dispatch.rest.rebind.utils.PathResolver.java
License:Apache License
public static String resolve(HasAnnotations type) { String path = ""; if (type.isAnnotationPresent(Path.class)) { path = type.getAnnotation(Path.class).value(); }//from ww w. j ava 2 s . c om return normalize(path); }
From source file:fr.onevu.gwt.uibinder.rebind.JClassTypeAdapter.java
License:Apache License
/** * Adds expectations for getting annotations from elements (methods, classes, * parameters, etc.).//from w w w. j a v a 2 s . c o m * * @param realElement the java element which contains annotations * @param element the mock GWT element which contains annotations */ @SuppressWarnings("unchecked") private void addAnnotationBehaviour(final AnnotatedElement realElement, final HasAnnotations element) { expect(element.isAnnotationPresent(isA(Class.class))).andStubAnswer(new IAnswer<Boolean>() { public Boolean answer() throws Throwable { Class<? extends Annotation> annotationClass = (Class<? extends Annotation>) EasyMock .getCurrentArguments()[0]; return realElement.isAnnotationPresent(annotationClass); } }); expect(element.getAnnotation(isA(Class.class))).andStubAnswer(new IAnswer<Annotation>() { public Annotation answer() throws Throwable { Class<? extends Annotation> annotationClass = (Class<? extends Annotation>) EasyMock .getCurrentArguments()[0]; return realElement.getAnnotation(annotationClass); } }); }