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

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

Introduction

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

Prototype

public abstract String getName();

Source Link

Usage

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 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 w w 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);

        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;
}