Example usage for java.lang.reflect AnnotatedElement isAnnotationPresent

List of usage examples for java.lang.reflect AnnotatedElement isAnnotationPresent

Introduction

In this page you can find the example usage for java.lang.reflect AnnotatedElement isAnnotationPresent.

Prototype

default boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) 

Source Link

Document

Returns true if an annotation for the specified type is present on this element, else false.

Usage

From source file:org.castor.cpa.jpa.processors.classprocessors.JPANamedNativeQueryProcessor.java

public final <I extends BaseNature, A extends Annotation> boolean processAnnotation(final I info,
        final A annotation, final AnnotatedElement target) throws AnnotationTargetException {
    if ((info instanceof JPAClassNature) && (annotation instanceof NamedNativeQuery)
            && (target instanceof Class<?>) && (target.isAnnotationPresent(NamedNativeQuery.class))) {
        LOG.debug("Processing class annotation " + annotation.toString());

        final JPAClassNature jpaClassNature = (JPAClassNature) info;
        final NamedNativeQuery namedNativeQuery = (NamedNativeQuery) annotation;
        final Map<String, String> namedNativeQueryMap = new HashMap<String, String>();
        namedNativeQueryMap.put(namedNativeQuery.name(), namedNativeQuery.query());
        jpaClassNature.setNamedNativeQuery(namedNativeQueryMap);
        return true;
    }/*  www  .j a  v  a2  s .com*/
    return false;
}

From source file:org.castor.cpa.jpa.processors.classprocessors.JPANamedQueriesProcessor.java

/**
 * {@inheritDoc}/*  w  ww.  j  ava 2s  .c om*/
 * 
 * @see org.castor.core.annotationprocessing.TargetAwareAnnotationProcessor#
 *      processAnnotation(BaseNature, Annotation, AnnotatedElement)
 */
public <I extends BaseNature, A extends Annotation> boolean processAnnotation(final I info, final A annotation,
        final AnnotatedElement target) throws AnnotationTargetException {

    if ((info instanceof JPAClassNature) && (annotation instanceof NamedQueries) && (target instanceof Class<?>)
            && (target.isAnnotationPresent(NamedQueries.class))) {
        _log.debug("Processing class annotation " + annotation.toString());
        final JPAClassNature jpaClassNature = (JPAClassNature) info;
        final NamedQueries namedQueries = (NamedQueries) annotation;
        final Map<String, String> namedQueryMap = new HashMap<String, String>();
        NamedQuery[] namedQueriesValues = namedQueries.value();
        if (namedQueriesValues != null && namedQueriesValues.length > 0) {
            for (NamedQuery namedQuery : namedQueriesValues) {
                namedQueryMap.put(namedQuery.name(), namedQuery.query());
            }
        }
        jpaClassNature.setNamedQuery(namedQueryMap);
        return true;
    }
    return false;
}

From source file:org.castor.cpa.jpa.processors.classprocessors.JPASequenceGeneratorClassProcessor.java

private <A> boolean verifyArguments(final A annotation, final AnnotatedElement target) {
    if (!(annotation instanceof SequenceGenerator) || (!target.isAnnotationPresent(SequenceGenerator.class))
            || (!target.isAnnotationPresent(Entity.class))) {

        return false;
    }//from w  w w  .  j  a  va  2 s .c o m
    return true;

}

From source file:org.castor.cpa.jpa.processors.classprocessors.JPATableGeneratorClassProcessor.java

private <A> boolean verifyArguments(final A annotation, final AnnotatedElement target) {
    if (!(annotation instanceof TableGenerator) || (!target.isAnnotationPresent(TableGenerator.class))
            || (!target.isAnnotationPresent(Entity.class))) {

        return false;
    }//from   w w w .j  a va 2s  . c o m
    return true;

}

From source file:org.castor.cpa.jpa.processors.fieldprocessors.JPAEnumeratedProcessor.java

public <I extends BaseNature, A extends Annotation> boolean processAnnotation(final I info, final A annotation,
        final AnnotatedElement target) throws AnnotationTargetException {
    if ((info instanceof JPAFieldNature) && (annotation instanceof Enumerated)
            && target.isAnnotationPresent(Enumerated.class)) {
        _log.debug("processing field annotation " + annotation.toString());

        final JPAFieldNature jpaFieldNature = (JPAFieldNature) info;
        if (((Enumerated) annotation).value() == EnumType.STRING) {
            jpaFieldNature.setStringEnumType(true);
        }/* ww  w  . j  a v a  2  s.  c om*/
        return true;
    }
    return false;
}

From source file:org.castor.cpa.jpa.processors.fieldprocessors.JPAGeneratedValueProcessor.java

private <I, A> boolean verifyArguments(final I info, final A annotation, final AnnotatedElement target) {
    if (!(annotation instanceof GeneratedValue) || (!target.isAnnotationPresent(GeneratedValue.class))
            || (!target.isAnnotationPresent(Id.class)) || !(info instanceof JPAFieldNature)) {
        return false;
    }//  www .j a  va2s.com
    return true;
}

From source file:org.castor.cpa.jpa.processors.fieldprocessors.JPALobProcessor.java

public <I extends BaseNature, A extends Annotation> boolean processAnnotation(final I info, final A annotation,
        final AnnotatedElement target) throws AnnotationTargetException {
    if ((info instanceof JPAFieldNature) && (annotation instanceof Lob)
            && target.isAnnotationPresent(Lob.class)) {
        _log.debug("processing field annotation " + annotation.toString());

        final JPAFieldNature jpaFieldNature = (JPAFieldNature) info;
        jpaFieldNature.setLob(true);//w w  w.ja va2s  .  com
        return true;
    }
    return false;
}

From source file:org.castor.cpa.jpa.processors.fieldprocessors.JPASequenceGeneratorFieldProcessor.java

/**
 * Checks whether all required annotations (as per specification) are present.
 * /*  ww  w .java 2  s .c  o m*/
 * @param <A> 
 * @param annotation The actual annotation.
 * @param target The target of the given annotation.
 * @return True if all requirements are satisfied.
 */
private <A> boolean verifyArguments(final A annotation, final AnnotatedElement target) {
    if (!(annotation instanceof SequenceGenerator) || (!target.isAnnotationPresent(SequenceGenerator.class))
            || (!target.isAnnotationPresent(Id.class))) {
        return false;
    }
    return true;
}

From source file:org.castor.cpa.jpa.processors.fieldprocessors.JPATableGeneratorFieldProcessor.java

private <A> boolean verifyArguments(final A annotation, final AnnotatedElement target) {
    if (!(annotation instanceof TableGenerator) || (!target.isAnnotationPresent(TableGenerator.class))
            || (!target.isAnnotationPresent(Id.class))) {

        return false;
    }/*  w  w  w  .jav a  2 s .  co  m*/
    return true;

}

From source file:org.castor.cpa.jpa.processors.fieldprocessors.JPATemporalProcessor.java

public <I extends BaseNature, A extends Annotation> boolean processAnnotation(final I info, final A annotation,
        final AnnotatedElement target) throws AnnotationTargetException {
    if ((info instanceof JPAFieldNature) && (annotation instanceof Temporal)
            && target.isAnnotationPresent(Temporal.class)) {
        _log.debug("processing field annotation " + annotation.toString());

        final JPAFieldNature jpaFieldNature = (JPAFieldNature) info;
        final Temporal temporal = (Temporal) annotation;
        jpaFieldNature.setTemporalType(temporal.value());
        return true;
    }/*from   w  w  w . j  a v a  2s  .  c om*/
    return false;
}