Example usage for java.lang.reflect Field isAnnotationPresent

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

Introduction

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

Prototype

@Override
public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) 

Source Link

Usage

From source file:adalid.core.AbstractDataArtifact.java

private void annotateNameProperty(Field field) {
    Class<? extends Annotation> annotationClass = NameProperty.class;
    boolean log = depth() == 0;
    boolean aye = field.isAnnotationPresent(annotationClass)
            && XS1.checkKeyPropertyFieldAnnotation(log, field, KeyProperty.NAME);
    /**///  w w  w  .ja v a  2s  .  co  m
    if (aye) {
        Field previous = getDeclaringArtifact().put(annotationClass, field);
        if (previous == null) {
            _annotatedWithNameProperty = true;
        } else if (log) {
            XS1.logDuplicateAnnotation(field, annotationClass, previous);
        }
    }
}

From source file:adalid.core.AbstractDataArtifact.java

private void annotateUrlProperty(Field field) {
    Class<? extends Annotation> annotationClass = UrlProperty.class;
    boolean log = depth() == 0;
    boolean aye = field.isAnnotationPresent(annotationClass)
            && XS1.checkKeyPropertyFieldAnnotation(log, field, KeyProperty.URL);
    /**///  www  . ja v a 2 s.c  o m
    if (aye) {
        Field previous = getDeclaringArtifact().put(annotationClass, field);
        if (previous == null) {
            UrlProperty annotation = field.getAnnotation(UrlProperty.class);
            _urlType = annotation.urlType();
            _urlDisplayType = annotation.urlDisplayType();
            _annotatedWithUrlProperty = true;
        } else if (log) {
            XS1.logDuplicateAnnotation(field, annotationClass, previous);
        }
    }
}

From source file:adalid.core.AbstractDataArtifact.java

private void annotateVersionProperty(Field field) {
    Class<? extends Annotation> annotationClass = VersionProperty.class;
    boolean log = depth() == 0;
    boolean aye = field.isAnnotationPresent(annotationClass)
            && XS1.checkKeyPropertyFieldAnnotation(log, field, KeyProperty.VERSION);
    /**//*from   w  w w.ja v  a2s .  co m*/
    if (aye) {
        Field previous = getDeclaringArtifact().put(annotationClass, field);
        if (previous == null) {
            _annotatedWithVersionProperty = true;
        } else if (log) {
            XS1.logDuplicateAnnotation(field, annotationClass, previous);
        }
    }
}

From source file:adalid.core.AbstractDataArtifact.java

private void annotateSegmentProperty(Field field) {
    Class<? extends Annotation> annotationClass = SegmentProperty.class;
    boolean log = depth() == 1;
    boolean aye = field.isAnnotationPresent(annotationClass)
            && XS1.checkKeyPropertyFieldAnnotation(log, field, KeyProperty.SEGMENT);
    /**/// w w  w.  j a v a 2  s .  c  o  m
    if (aye) {
        Field previous = getDeclaringArtifact().put(annotationClass, field);
        if (previous == null) {
            _annotatedWithSegmentProperty = true;
        } else if (log) {
            XS1.logDuplicateAnnotation(field, annotationClass, previous);
        }
    }
}

From source file:adalid.core.AbstractDataArtifact.java

private void annotateInactiveIndicator(Field field) {
    Class<? extends Annotation> annotationClass = InactiveIndicator.class;
    boolean log = depth() == 0;
    boolean aye = field.isAnnotationPresent(annotationClass)
            && XS1.checkKeyPropertyFieldAnnotation(log, field, KeyProperty.INACTIVE_INDICATOR);
    /**//* w ww .ja va  2 s . c  o  m*/
    if (aye) {
        Field previous = getDeclaringArtifact().put(annotationClass, field);
        if (previous == null) {
            _annotatedWithInactiveIndicator = true;
        } else if (log) {
            XS1.logDuplicateAnnotation(field, annotationClass, previous);
        }
    }
}

From source file:adalid.core.AbstractDataArtifact.java

private void annotateDescriptionProperty(Field field) {
    Class<? extends Annotation> annotationClass = DescriptionProperty.class;
    boolean log = depth() == 0;
    boolean aye = field.isAnnotationPresent(annotationClass)
            && XS1.checkKeyPropertyFieldAnnotation(log, field, KeyProperty.DESCRIPTION);
    /**///from  w  w w  .  j  av a 2s  .  c o  m
    if (aye) {
        Field previous = getDeclaringArtifact().put(annotationClass, field);
        if (previous == null) {
            _annotatedWithDescriptionProperty = true;
        } else if (log) {
            XS1.logDuplicateAnnotation(field, annotationClass, previous);
        }
    }
}

From source file:adalid.core.AbstractDataArtifact.java

private void annotateOwnerProperty(Field field) {
    Class<? extends Annotation> annotationClass = OwnerProperty.class;
    boolean log = depth() == 1;
    boolean aye = field.isAnnotationPresent(annotationClass)
            && XS1.checkKeyPropertyFieldAnnotation(log, field, KeyProperty.OWNER);
    /**//*  w  w w .j  a  va2s  .c o  m*/
    if (aye) {
        Class<?> fieldType = field.getType();
        Class<? extends Entity> userEntityClass = TLC.getProject().getUserEntityClass();
        if (userEntityClass != null && userEntityClass.isAssignableFrom(fieldType)) {
            Field previous = getDeclaringArtifact().put(annotationClass, field);
            if (previous == null) {
                _annotatedWithOwnerProperty = true;
            } else if (log) {
                XS1.logDuplicateAnnotation(field, annotationClass, previous);
            }
        } else if (log) {
            String message = userEntityClass + " is not assignable from " + fieldType;
            XS1.logFieldAnnotationErrorMessage(field, annotationClass, message);
        }
    }
}

From source file:adalid.core.AbstractDataArtifact.java

private void annotateUniqueKey(Field field) {
    Class<? extends Annotation> annotationClass = UniqueKey.class;
    boolean log = this instanceof Entity ? depth() == 1 : depth() == 0;
    _annotatedWithUniqueKey = field.isAnnotationPresent(annotationClass)
            && XS1.checkKeyPropertyFieldAnnotation(log, field, KeyProperty.UNIQUE_KEY);
}

From source file:adalid.core.AbstractDataArtifact.java

private void annotateDiscriminatorColumn(Field field) {
    Class<? extends Annotation> annotationClass = DiscriminatorColumn.class;
    boolean log = this instanceof Entity ? depth() == 1 : depth() == 0;
    boolean aye = field.isAnnotationPresent(annotationClass)
            && XS1.checkKeyPropertyFieldAnnotation(log, field, KeyProperty.DISCRIMINATOR);
    /**//*from   w  w  w  . j av  a 2  s  .  c o  m*/
    if (aye) {
        Field previous = getDeclaringArtifact().put(annotationClass, field);
        if (previous == null) {
            _annotatedWithDiscriminatorColumn = true;
        } else if (log) {
            XS1.logDuplicateAnnotation(field, annotationClass, previous);
        }
    }
}

From source file:adalid.core.AbstractDataArtifact.java

private void annotateBooleanDataGen(Field field) {
    Class<? extends Annotation> annotationClass = BooleanDataGen.class;
    Class<?>[] validTypes = new Class<?>[] { BooleanProperty.class };
    boolean log = depth() == 0;
    boolean annotated = field.isAnnotationPresent(annotationClass)
            && XS1.checkFieldAnnotation(log, field, annotationClass, validTypes);
    /**//*from   w  w  w .j  a va 2s .co m*/
    if (annotated) {
        BooleanDataGen annotation = field.getAnnotation(BooleanDataGen.class);
        _dataGenType = annotation.type();
        _dataGenFunction = StringUtils.trimToNull(annotation.function());
        _dataGenNullable = Math.min(100, Math.max(0, annotation.nullable()));
        _dataGenTrueable = Math.min(100, Math.max(0, annotation.trueable()));
        if (_dataGenNullable + _dataGenTrueable > 100) {
            _dataGenNullable = 100 - _dataGenTrueable;
        }
        _annotatedWithDataGen = true;
    }
}