Example usage for com.fasterxml.jackson.databind.introspect Annotated hasAnnotation

List of usage examples for com.fasterxml.jackson.databind.introspect Annotated hasAnnotation

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind.introspect Annotated hasAnnotation.

Prototype

public final <A extends Annotation> boolean hasAnnotation(Class<A> paramClass) 

Source Link

Usage

From source file:org.jongo.marshall.jackson.JongoAnnotationIntrospector.java

private static boolean hasMongoId(Annotated a) {
    return a.hasAnnotation(MongoId.class) || a.hasAnnotation(Id.class);
}

From source file:org.jongo.marshall.jackson.JongoAnnotationIntrospector.java

private static boolean hasMongoObjectId(Annotated a) {
    return a.hasAnnotation(MongoObjectId.class) || a.hasAnnotation(ObjectId.class);
}

From source file:org.mongojack.internal.MongoAnnotationIntrospector.java

@Override
public Object findSerializer(Annotated am) {
    if (am.hasAnnotation(ObjectId.class)) {
        return ObjectIdSerializer.class;
    }/*from  w ww. ja  v  a  2s .  c  o m*/
    return null;
}

From source file:org.mongojack.internal.MongoAnnotationIntrospector.java

@Override
public Object findDeserializer(Annotated am) {
    if (am.hasAnnotation(ObjectId.class)) {
        return findObjectIdDeserializer(typeFactory.constructType(am.getGenericType()));
    }/*from   w  ww.  jav a  2  s.  c  om*/
    return null;
}

From source file:org.mongojack.internal.MongoAnnotationIntrospector.java

@Override
public JsonDeserializer findContentDeserializer(Annotated am) {
    if (am.hasAnnotation(ObjectId.class)) {
        JavaType type = typeFactory.constructType(am.getGenericType());
        if (type.isCollectionLikeType()) {
            return findObjectIdDeserializer(type.containedType(0));
        } else if (type.isMapLikeType()) {
            return findObjectIdDeserializer(type.containedType(1));
        }/*from   ww  w .  jav a 2s .  co m*/
    }
    return null;
}

From source file:org.mongojack.internal.MongoAnnotationIntrospector.java

private String findPropertyName(Annotated annotated) {

    if (annotated.hasAnnotation(Id.class) || annotated.hasAnnotation(javax.persistence.Id.class)) {
        return "_id";
    }//  www . j av  a 2s.  c om
    return null;
}

From source file:org.usrz.libs.riak.introspection.RiakAnnotationIntrospector.java

@Override
public PropertyName findNameForSerialization(Annotated a) {
    System.err.println("FindNameForSerialization " + a);

    if (a.hasAnnotation(RiakKey.class))
        return NAME_KEY;

    if (a.hasAnnotation(RiakLink.class)) {
        final String tag = a.getAnnotation(RiakLink.class).value();
        return NAME_LINKS_BASE.withSimpleName((!tag.isEmpty()) ? tag
                : (a instanceof AnnotatedField) ? a.getName()
                        : (a instanceof AnnotatedMethod) ? okNameForGetter((AnnotatedMethod) a) : null);
    }//from  w ww . j  a  v  a 2  s.  co  m

    if (a.hasAnnotation(RiakMetadata.class)) {
        final String field = a.getAnnotation(RiakMetadata.class).value();
        return NAME_METADATA_BASE.withSimpleName((!field.isEmpty()) ? field
                : (a instanceof AnnotatedField) ? a.getName()
                        : (a instanceof AnnotatedMethod) ? okNameForGetter((AnnotatedMethod) a) : null);
    }

    if (a.hasAnnotation(RiakIndex.class)) {
        final RiakIndex annotation = a.getAnnotation(RiakIndex.class);
        return propertyNameForIndex(annotation, a.getGenericType(), (!annotation.name().isEmpty())
                ? annotation.name()
                : (!annotation.value().isEmpty()) ? annotation.value()
                        : (a instanceof AnnotatedField) ? a.getName()
                                : (a instanceof AnnotatedMethod) ? okNameForGetter((AnnotatedMethod) a) : null);
    }

    return null;
}

From source file:org.usrz.libs.riak.introspection.RiakAnnotationIntrospector.java

@Override
public PropertyName findNameForDeserialization(Annotated a) {
    System.err.println("FindNameForDeserialization " + a);

    if (a.hasAnnotation(RiakKey.class))
        return NAME_KEY;

    if (a.hasAnnotation(RiakLink.class)) {
        final String tag = a.getAnnotation(RiakLink.class).value();
        return NAME_LINKS_BASE.withSimpleName((!tag.isEmpty()) ? tag
                : (a instanceof AnnotatedField) ? a.getName()
                        : (a instanceof AnnotatedMethod) ? okNameForGetter((AnnotatedMethod) a) : null);
    }//from   w w  w  . ja  v a  2  s .  c o  m

    if (a.hasAnnotation(RiakMetadata.class)) {
        final String field = a.getAnnotation(RiakMetadata.class).value();
        return NAME_METADATA_BASE.withSimpleName((!field.isEmpty()) ? field
                : (a instanceof AnnotatedField) ? a.getName()
                        : (a instanceof AnnotatedMethod) ? okNameForGetter((AnnotatedMethod) a) : null);
    }

    if (a.hasAnnotation(RiakIndex.class)) {
        final RiakIndex annotation = a.getAnnotation(RiakIndex.class);

        final Type genericType = a instanceof AnnotatedField ? a.getGenericType()
                : a instanceof AnnotatedMethod ? ((AnnotatedMethod) a).getGenericParameterType(0) : null;

        return propertyNameForIndex(annotation, genericType, (!annotation.name().isEmpty()) ? annotation.name()
                : (!annotation.value().isEmpty()) ? annotation.value()
                        : (a instanceof AnnotatedField) ? a.getName()
                                : (a instanceof AnnotatedMethod) ? okNameForGetter((AnnotatedMethod) a) : null);
    }

    return null;
}