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

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

Introduction

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

Prototype

public abstract Type getGenericType();

Source Link

Usage

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));
        }//  w  ww. j  a va2s . 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()));
    }/*  w  w  w.java2s.  com*/
    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 ww w.ja  v  a  2s . 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);
        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  www .j av a 2s . 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;
}