Example usage for java.lang.annotation ElementType TYPE

List of usage examples for java.lang.annotation ElementType TYPE

Introduction

In this page you can find the example usage for java.lang.annotation ElementType TYPE.

Prototype

ElementType TYPE

To view the source code for java.lang.annotation ElementType TYPE.

Click Source Link

Document

Class, interface (including annotation type), or enum declaration

Usage

From source file:de.knightsoftnet.validators.rebind.GwtSpecificValidatorCreator.java

private void writeFields(final SourceWriter sw) throws UnableToCompleteException {

    // Create a static array of all valid property names.
    BeanInfo beanInfo;//w  ww  .  ja  va 2  s. c  o  m
    try {
        beanInfo = Introspector.getBeanInfo(this.beanHelper.getClazz());
    } catch (final IntrospectionException e) {
        throw error(this.logger, e);
    }

    // private static final java.util.List<String> ALL_PROPERTY_NAMES =
    sw.println("private static final java.util.List<String> ALL_PROPERTY_NAMES = ");
    sw.indent();
    sw.indent();

    // Collections.<String>unmodifiableList(
    sw.println("java.util.Collections.<String>unmodifiableList(");
    sw.indent();
    sw.indent();

    // java.util.Arrays.<String>asList(
    sw.print("java.util.Arrays.<String>asList(");

    // "foo","bar" );
    sw.print(Joiner.on(",").join(Iterables.transform(ImmutableList.copyOf(beanInfo.getPropertyDescriptors()),
            Functions.compose(TO_LITERAL, PROPERTY_DESCRIPTOR_TO_NAME))));
    sw.println("));");
    sw.outdent();
    sw.outdent();
    sw.outdent();
    sw.outdent();

    // Write the metadata for the bean
    this.writeBeanMetadata(sw);
    sw.println();

    // Create a variable for each constraint of each property
    for (final PropertyDescriptor p : this.beanHelper.getBeanDescriptor().getConstrainedProperties()) {
        int count = 0;
        for (final ConstraintDescriptor<?> constraint : p.getConstraintDescriptors()) {
            final org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl<?> constraintHibernate = (org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl<?>) constraint;
            if (this.areConstraintDescriptorGroupsValid(constraint)) {
                this.writeConstraintDescriptor(sw, constraint, constraintHibernate.getElementType(),
                        convertConstraintOriginEnum(constraintHibernate.getDefinedOn()),
                        this.constraintDescriptorVar(p.getPropertyName(), count++));
            }
        }
        this.writePropertyDescriptor(sw, p);
        if (p.isCascaded()) {
            this.beansToValidate.add(isIterableOrMap(p.getElementClass())
                    ? this.createBeanHelper(this.beanHelper.getAssociationType(p, true))
                    : this.createBeanHelper(p.getElementClass()));
        }
    }

    // Create a variable for each constraint of this class.
    int count = 0;
    for (final ConstraintDescriptor<?> constraint : this.beanHelper.getBeanDescriptor()
            .getConstraintDescriptors()) {
        final org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl<?> constraintHibernate = (org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl<?>) constraint;
        if (this.areConstraintDescriptorGroupsValid(constraint)) {
            this.writeConstraintDescriptor(sw, constraint, ElementType.TYPE,
                    convertConstraintOriginEnum(constraintHibernate.getDefinedOn()),
                    this.constraintDescriptorVar("this", count++));
        }
    }

    // Now write the BeanDescriptor after we already have the
    // PropertyDescriptors and class constraints
    this.writeBeanDescriptor(sw);
    sw.println();
}

From source file:org.androidannotations.annotations.HttpsClient.java

    @see RestClientSupport
- * @see RestClientRootUrl//www.j  a  v a 2 s.c  o  m
- * @see RestClientHeaders
+ * @see org.androidannotations.api.rest.RestClientSupport
+ * @see org.androidannotations.api.rest.RestClientRootUrl
+ * @see org.androidannotations.api.rest.RestClientHeaders
  */
 @Retention(RetentionPolicy.CLASS)
 @Target(ElementType.TYPE)
@@ -211,5 +207,6 @@
    Class<?>[] converters();

From source file:org.bonitasoft.engine.bdm.CodeGenerator.java

protected void checkAnnotationTarget(final JAnnotatable annotable,
        final Class<? extends Annotation> annotationType, final Set<ElementType> supportedElementTypes) {
    if (annotable instanceof JClass && !supportedElementTypes.isEmpty()
            && !supportedElementTypes.contains(ElementType.TYPE)) {
        throw new IllegalArgumentException(annotationType.getName() + " is not supported for " + annotable);
    }// w  ww .j  a v a  2  s . com
    if (annotable instanceof JFieldVar && !supportedElementTypes.isEmpty()
            && !supportedElementTypes.contains(ElementType.FIELD)) {
        throw new IllegalArgumentException(annotationType.getName() + " is not supported for " + annotable);
    }
    if (annotable instanceof JMethod && !supportedElementTypes.isEmpty()
            && !supportedElementTypes.contains(ElementType.METHOD)) {
        throw new IllegalArgumentException(annotationType.getName() + " is not supported for " + annotable);
    }
}

From source file:org.jgentleframework.utils.ReflectUtils.java

/**
 * Phng thc s kim tra xem <code>annotation</code> ch nh c
 * {@link Target} tng ng hp l vi i tng <code>object</code> hay
 * khng (i tng <code>object</code> c th l bt k thc th ch nh
 * no cho php annotate annotation nh/*from   ww w.  j ava 2s . c  o m*/
 * <code>Class, Interface, Annotation, Enum, Method, Field, Constructor, ...</code>
 * )
 * 
 * @param annotation
 *            i tng <code>annotation</code> cn kim tra.
 * @param obj
 *            i tng <code>object</code> cn kim tra
 * @return tr v? <b>true</b> nu c, nu khng tr v? <b>false</b>.
 */
public static boolean isValidTarget(Annotation annotation, Object obj) {

    if (annotation.annotationType().isAnnotationPresent(Target.class)) {
        Target target = annotation.annotationType().getAnnotation(Target.class);
        if (obj.getClass().isAnnotation()) {
            if (!Arrays.asList(target.value()).contains(ElementType.TYPE)
                    || !Arrays.asList(target.value()).contains(ElementType.ANNOTATION_TYPE)) {
                return false;
            }
        } else if (ReflectUtils.isCast(Constructor.class, obj)) {
            if (!Arrays.asList(target.value()).contains(ElementType.CONSTRUCTOR)) {
                return false;
            }
        } else if (ReflectUtils.isField(obj)) {
            if (!Arrays.asList(target.value()).contains(ElementType.FIELD)) {
                return false;
            }
        } else if (ReflectUtils.isMethod(obj)) {
            if (!Arrays.asList(target.value()).contains(ElementType.METHOD)) {
                return false;
            }
        } else if (ReflectUtils.isClass(obj) || ReflectUtils.isInterface(obj)) {
            if (!Arrays.asList(target.value()).contains(ElementType.TYPE)) {
                return false;
            }
        } else {
            if (!obj.getClass().isAnnotation() && !ReflectUtils.isCast(Constructor.class, obj)
                    && !ReflectUtils.isField(obj) && !ReflectUtils.isMethod(obj.getClass())
                    && !ReflectUtils.isClass(obj) && !ReflectUtils.isInterface(obj)) {
                return false;
            }
        }
    }
    return true;
}

From source file:org.mule.config.processors.DecoratingAnnotatedServiceProcessor.java

protected void processReply(Class componentFactoryClass, org.mule.api.service.Service service)
        throws MuleException {

    InboundEndpoint inboundEndpoint;//w w w  .j  a v a  2s.  c om
    for (int i = 0; i < componentFactoryClass.getAnnotations().length; i++) {
        Annotation annotation = componentFactoryClass.getAnnotations()[i];
        inboundEndpoint = tryInboundEndpointAnnotation(
                new AnnotationMetaData(componentFactoryClass, null, ElementType.TYPE, annotation),
                ChannelType.Reply);
        if (inboundEndpoint != null) {
            service.getAsyncReplyMessageSource().addSource(inboundEndpoint);
        }
    }

    //Lets process the reply routers
    processReplyRouters(componentFactoryClass, service);
}