Example usage for org.springframework.data.mapping PersistentProperty isAnnotationPresent

List of usage examples for org.springframework.data.mapping PersistentProperty isAnnotationPresent

Introduction

In this page you can find the example usage for org.springframework.data.mapping PersistentProperty isAnnotationPresent.

Prototype

boolean isAnnotationPresent(Class<? extends Annotation> annotationType);

Source Link

Document

Returns whether the PersistentProperty has an annotation of the given type.

Usage

From source file:org.lightadmin.core.persistence.metamodel.PersistentPropertyType.java

public static boolean isOfFileReferenceType(PersistentProperty persistentProperty) {
    if (forType(persistentProperty.getType()) == STRING
            && persistentProperty.isAnnotationPresent(FileReference.class)) {
        return true;
    }/*from w ww.j av  a  2 s . c o m*/
    return false;
}

From source file:org.lightadmin.core.persistence.metamodel.PersistentPropertyType.java

public static PersistentPropertyType forPersistentProperty(PersistentProperty persistentProperty) {
    final Class<?> attrType = persistentProperty.getType();

    if (persistentProperty.isAnnotationPresent(Embedded.class)
            || persistentProperty.isAnnotationPresent(EmbeddedId.class)) {
        return PersistentPropertyType.EMBEDDED;
    }//from   w  w w  . j ava2s.  c o m

    if (persistentProperty.isAssociation()) {
        if (persistentProperty.isCollectionLike()) {
            return PersistentPropertyType.ASSOC_MULTI;
        }
        return PersistentPropertyType.ASSOC;
    }

    if (persistentProperty.isMap()) {
        return PersistentPropertyType.MAP;
    }

    if (ClassUtils.isAssignable(Enum.class, attrType)) {
        return ENUM;
    }

    if (forType(attrType) == STRING && persistentProperty.isAnnotationPresent(FileReference.class)) {
        return PersistentPropertyType.FILE;
    }

    if (isOfDateType(persistentProperty)) {
        return DATE;
    }

    if (isOfTimeType(persistentProperty)) {
        return TIME;
    }

    if (isOfDateTimeType(persistentProperty)) {
        return DATE_TIME;
    }

    return forType(attrType);
}