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

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

Introduction

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

Prototype

public abstract Class<?> getRawType();

Source Link

Usage

From source file:net.nullschool.grains.jackson.datatype.GrainsAnnotationIntrospector.java

/**
 * Returns the contents of the {@link PublicInterfaceRef} annotation on the specified annotated object, or null
 * if it does not exist.//from w ww.j  a v a 2s  .c o  m
 */
private static Class<?> publicInterfaceOf(Annotated annotated) {
    return Grain.class.isAssignableFrom(annotated.getRawType())
            ? valueOf(annotated.getAnnotation(PublicInterfaceRef.class))
            : null;
}

From source file:net.nullschool.grains.jackson.datatype.GrainsAnnotationIntrospector.java

@Override
public Object findSerializer(Annotated annotated) {
    Class<?> clazz = annotated.getRawType();

    if (Grain.class.isAssignableFrom(clazz)) {
        JsonSerializer serializer = serializerMemos.get(clazz);
        if (serializer == null) {
            // No serializer found, so try finding one using the "public interface" of the grain.
            Class<?> grainClass = TypeTools.publicInterfaceOf(clazz);
            serializer = serializerMemos.get(grainClass);
            if (serializer == null) {
                // No serializer found for public interface either, so make a new one.
                serializer = new GrainSerializer(grainClass.asSubclass(Grain.class));
            }//from  ww  w  . j  a  v  a 2 s . c o m
            synchronized (this) {
                // It's okay to have a race condition where two threads create the same serializer twice. We
                // simply want to avoid serializer construction upon every invocation of findSerializer.
                serializerMemos = new HashMap<>(serializerMemos);
                serializerMemos.put(grainClass, serializer);
                serializerMemos.put(clazz, serializer);
            }
        }
        return serializer;
    }

    return null;
}

From source file:com.addthis.codec.jackson.CodecIntrospector.java

/** report all non-alias plugin types */
@Override//from   w w w. j ava 2  s  . co  m
public List<NamedType> findSubtypes(Annotated a) {
    Pluggable pluggable = a.getAnnotation(Pluggable.class);
    PluginMap pluginMap;
    if (pluggable != null) {
        pluginMap = pluginRegistry.byCategory().get(pluggable.value());
    } else if (pluginRegistry.byClass().containsKey(a.getRawType())) {
        pluginMap = pluginRegistry.byClass().get(a.getRawType());
    } else {
        return null;
    }
    List<NamedType> result = new ArrayList<>(pluginMap.asBiMap().size());
    for (Map.Entry<String, Class<?>> type : pluginMap.asBiMap().entrySet()) {
        result.add(new NamedType(type.getValue(), type.getKey()));
    }
    return result;
}

From source file:com.google.api.server.spi.config.annotationreader.ApiAnnotationIntrospector.java

@Nullable
private Transformer<?, ?> findSerializerInstance(Annotated a) {
    if (a instanceof AnnotatedClass) {
        AnnotatedClass clazz = (AnnotatedClass) a;
        List<Class<? extends Transformer<?, ?>>> serializerClasses = Serializers
                .getSerializerClasses(clazz.getRawType(), config);
        if (!serializerClasses.isEmpty()) {
            return Serializers.instantiate(serializerClasses.get(0), TypeToken.of(a.getRawType()));
        }/*from   ww w  . j a v a  2 s . co m*/
    }
    return null;
}

From source file:com.addthis.codec.jackson.CodecIntrospector.java

public TypeResolverBuilder<?> _findTypeResolver(MapperConfig<?> config, Annotated ac, JavaType baseType) {
    Pluggable pluggable = ac.getAnnotation(Pluggable.class);
    if (pluggable != null) {
        PluginMap pluginMap = pluginRegistry.byCategory().get(pluggable.value());
        if (pluginMap != null) {
            return new CodecTypeResolverBuilder(pluginMap, config.getTypeFactory(), pluginRegistry);
        } else {/*from   www  . j a va  2  s .c o m*/
            log.warn("missing plugin map for {}, reached from {}", pluggable.value(), ac.getRawType());
        }
    }
    return null;
}

From source file:io.swagger.v3.core.util.AnnotationsUtils.java

public static io.swagger.v3.oas.annotations.media.Schema getSchemaDeclaredAnnotation(Annotated a) {
    if (a == null) {
        return null;
    }//from w  w  w . j a va2s. com
    io.swagger.v3.oas.annotations.media.ArraySchema arraySchema = a.getRawType()
            .getDeclaredAnnotation(io.swagger.v3.oas.annotations.media.ArraySchema.class);
    if (arraySchema != null) {
        return arraySchema.schema();
    } else {
        return a.getRawType().getDeclaredAnnotation(io.swagger.v3.oas.annotations.media.Schema.class);
    }
}