/** * We want to warn the user about any annotations from ImageBundle or the old * incubator code. */ private static void checkForDeprecatedAnnotations(TreeLogger logger, JMethod method) { for (Class<? extends Annotation> annotationClass : DEPRECATED_ANNOTATION_CLASSES) { if (method.isAnnotationPresent(annotationClass)) { logger.log(TreeLogger.WARN, "Deprecated annotation used; expecting " + Source.class.getCanonicalName() + " but found " + annotationClass.getName() + " instead. It is likely " + "that undesired operation will occur."); } } }
@Override public boolean isAnnotationPresent(Class<? extends Annotation> annotClass) { return method.isAnnotationPresent(annotClass); }
@Override public boolean isAnnotationPresent(Class<? extends Annotation> annotClass) { return method.isAnnotationPresent(annotClass); }
/** * We want to warn the user about any annotations from ImageBundle or the old * incubator code. */ private static void checkForDeprecatedAnnotations(TreeLogger logger, JMethod method) { for (Class<? extends Annotation> annotationClass : DEPRECATED_ANNOTATION_CLASSES) { if (method.isAnnotationPresent(annotationClass)) { logger.log(TreeLogger.WARN, "Deprecated annotation used; expecting " + Source.class.getCanonicalName() + " but found " + annotationClass.getName() + " instead. It is likely " + "that undesired operation will occur."); } } }
/** * We want to warn the user about any annotations from ImageBundle or the old * incubator code. */ private static void checkForDeprecatedAnnotations(TreeLogger logger, JMethod method) { for (Class<? extends Annotation> annotationClass : DEPRECATED_ANNOTATION_CLASSES) { if (method.isAnnotationPresent(annotationClass)) { logger.log(TreeLogger.WARN, "Deprecated annotation used; expecting " + Source.class.getCanonicalName() + " but found " + annotationClass.getName() + " instead. It is likely " + "that undesired operation will occur."); } } }
protected String toSimpleName(final JMethod method) { if (method.isAnnotationPresent(Named.class)) { return method.getAnnotation(Named.class).value(); } final String name = method.getName(); if (name.startsWith("get") || name.startsWith("has")) { if (name.length() > 3 && Character.isUpperCase(name.charAt(3))) { return Character.toLowerCase(name.charAt(3)) + (name.length() > 4 ? name.substring(4) : ""); } } else if (name.startsWith("is")) { if (name.length() > 2 && Character.isUpperCase(name.charAt(2))) { return Character.toLowerCase(name.charAt(2)) + (name.length() > 3 ? name.substring(3) : ""); } } return name; }
private List<JMethod> getUiHandlers(JClassType ownerClass) { List<JMethod> uiHandlerMethods = new ArrayList<JMethod>(); JMethod[] methods = ownerClass.getMethods(); for (JMethod method : methods) { if(method.isAnnotationPresent(GxtUiHandler.class)) { uiHandlerMethods.add(method); } } JClassType superclass = ownerClass.getSuperclass(); if (superclass != null) { uiHandlerMethods.addAll(getUiHandlers(superclass)); } return uiHandlerMethods; } }
protected String getValueMethod(JClassType classType) { String method = "name"; for (JMethod jm : classType.isEnum().getMethods()) { if (jm.isAnnotationPresent(JsonValue.class)) { method = jm.getName(); break; } } return method; }
protected String getValueMethod(JClassType classType) { String method = "name"; for (JMethod jm : classType.isEnum().getMethods()) { if (jm.isAnnotationPresent(JsonValue.class)) { method = jm.getName(); break; } } return method; }
protected String getValueMethod(JClassType classType) { String method = "name"; for (JMethod jm : classType.isEnum().getMethods()) { if (jm.isAnnotationPresent(JsonValue.class)) { method = jm.getName(); break; } } return method; }
protected String getValueMethod(JClassType classType) { String method = "name"; for (JMethod jm : classType.isEnum().getMethods()) { if (jm.isAnnotationPresent(JsonValue.class)) { method = jm.getName(); break; } } return method; }
/** * Scans the owner class to find all methods annotated with @UiHandler, and * adds them to their respective fields. * * @param ownerType the type of the owner class */ private void findUiHandlers(JClassType ownerType) { JMethod[] methods = ownerType.getMethods(); for (JMethod method : methods) { if (method.isAnnotationPresent(UiHandler.class)) { uiHandlers.add(method); } } // Recurse to superclass JClassType superclass = ownerType.getSuperclass(); if (superclass != null) { findUiHandlers(superclass); } } }
/** * Scans the owner class to find all methods annotated with @UiHandler, and * adds them to their respective fields. * * @param ownerType the type of the owner class */ private void findUiHandlers(JClassType ownerType) { JMethod[] methods = ownerType.getMethods(); for (JMethod method : methods) { if (method.isAnnotationPresent(UiHandler.class)) { uiHandlers.add(method); } } // Recurse to superclass JClassType superclass = ownerType.getSuperclass(); if (superclass != null) { findUiHandlers(superclass); } } }
private StorageKeyProviderMethod buildKeyMethod(JMethod method) throws UnableToCompleteException { logger.branch(TreeLogger.Type.DEBUG, "buildKeyMethod with method=" + method.getReadableDeclaration()); StorageKeyProviderMethod.Builder builder = new StorageKeyProviderMethod.Builder(); builder.setMethod(method); if(method.isAnnotationPresent(KEY_ANNOTATION)) { builder.setKeyAnnotation(method.getAnnotation(KEY_ANNOTATION)); } return builder.build(); }
private static void parseMethods( TreeLogger logger, JClassType type, Map<String, PropertyAccessorsBuilder> propertiesMap, boolean mixin ) { for ( JMethod method : type.getMethods() ) { if ( null != method.isConstructor() || method.isStatic() || (type.getQualifiedSourceName() .equals( "java.lang.Object" ) && method.getName().equals( "getClass" )) ) { continue; } if ( method.getParameters().length == 0 ) { // might be a getter String fieldName = extractFieldNameFromGetterSetterMethodName( method.getName(), true ); PropertyAccessorsBuilder property = propertiesMap.get( fieldName ); if ( null == property ) { property = new PropertyAccessorsBuilder( fieldName ); propertiesMap.put( fieldName, property ); } property.addGetter( method, mixin ); } else if ( method.getParameters().length == 1 || (method.getParameters().length == 2 && method.isAnnotationPresent( JsonAnySetter.class )) ) { // might be a setter String fieldName = extractFieldNameFromGetterSetterMethodName( method.getName(), false ); PropertyAccessorsBuilder property = propertiesMap.get( fieldName ); if ( null == property ) { property = new PropertyAccessorsBuilder( fieldName ); propertiesMap.put( fieldName, property ); } property.addSetter( method, mixin ); } } }
JMethod[] methods = ownerType.getMethods(); for (JMethod method : methods) { if (method.isAnnotationPresent(UiFactory.class)) { JClassType factoryType = method.getReturnType().isClassOrInterface();
JMethod[] methods = ownerType.getMethods(); for (JMethod method : methods) { if (method.isAnnotationPresent(UiFactory.class)) { JClassType factoryType = method.getReturnType().isClassOrInterface();
private boolean isPropertyConstrained(PropertyDescriptor p, boolean useField) { // cascaded counts as constrained // we must know if the @Valid annotation is on a field or a getter JClassType jClass = beanHelper.getJClass(); if (useField && jClass.findField(p.getPropertyName()).isAnnotationPresent(Valid.class)) { return true; } else if (!useField && jClass.findMethod(asGetter(p),NO_ARGS).isAnnotationPresent(Valid.class)) { return true; } // for non-cascaded properties for (ConstraintDescriptor<?> constraint : p.getConstraintDescriptors()) { org.hibernate.validator.metadata.ConstraintDescriptorImpl<?> constraintHibernate = (org.hibernate.validator.metadata.ConstraintDescriptorImpl<?>) constraint; if (constraintHibernate.getElementType() == (useField ? ElementType.FIELD : ElementType.METHOD)) { return true; } } return false; }
private boolean isPropertyConstrained(PropertyDescriptor p, boolean useField) { // cascaded counts as constrained // we must know if the @Valid annotation is on a field or a getter JClassType jClass = beanHelper.getJClass(); if (useField && jClass.findField(p.getPropertyName()).isAnnotationPresent(Valid.class)) { return true; } else if (!useField && jClass.findMethod(asGetter(p),NO_ARGS).isAnnotationPresent(Valid.class)) { return true; } // for non-cascaded properties for (ConstraintDescriptor<?> constraint : p.getConstraintDescriptors()) { org.hibernate.validator.metadata.ConstraintDescriptorImpl<?> constraintHibernate = (org.hibernate.validator.metadata.ConstraintDescriptorImpl<?>) constraint; if (constraintHibernate.getElementType() == (useField ? ElementType.FIELD : ElementType.METHOD)) { return true; } } return false; }
private boolean isPropertyConstrained(final PropertyDescriptor ppropertyDescription, final boolean useField) { // cascaded counts as constrained // we must know if the @Valid annotation is on a field or a getter final JClassType jClass = beanHelper.getJClass(); if (useField && jClass.findField(ppropertyDescription.getPropertyName()) .isAnnotationPresent(Valid.class)) { return true; } else if (!useField && jClass.findMethod(asGetter(ppropertyDescription), NO_ARGS) .isAnnotationPresent(Valid.class)) { return true; } // for non-cascaded properties for (final ConstraintDescriptor<?> constraint : ppropertyDescription .getConstraintDescriptors()) { final org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl<?> constraintHibernate = (org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl<?>) constraint; if (constraintHibernate .getElementType() == (useField ? ElementType.FIELD : ElementType.METHOD)) { return true; } } return false; }