Search in sources :

Example 1 with ApiTransformer

use of com.google.api.server.spi.config.ApiTransformer in project endpoints-java by cloudendpoints.

the class Serializers method getSerializerClasses.

public static List<Class<? extends Transformer<?, ?>>> getSerializerClasses(TypeToken<?> type, @Nullable final ApiSerializationConfig config) {
    if (type == null) {
        return Collections.emptyList();
    }
    List<Class<? extends Transformer<?, ?>>> allParentSerializers = Lists.newArrayList();
    List<TypeToken<?>> serializedTypes = Lists.newArrayList();
    for (TypeToken<?> typeToken : type.getTypes()) {
        ApiTransformer apiSerialization = typeToken.getRawType().getAnnotation(ApiTransformer.class);
        if (isSupertypeOf(typeToken, serializedTypes)) {
            continue;
        }
        if (apiSerialization != null) {
            allParentSerializers.add(apiSerialization.value());
            serializedTypes.add(typeToken);
        } else if (config != null) {
            ApiSerializationConfig.SerializerConfig serializerConfig = config.getSerializerConfig(typeToken);
            if (serializerConfig != null) {
                allParentSerializers.add(serializerConfig.getSerializer());
                serializedTypes.add(typeToken);
            }
        }
    }
    return allParentSerializers;
}
Also used : ApiTransformer(com.google.api.server.spi.config.ApiTransformer) Transformer(com.google.api.server.spi.config.Transformer) ApiTransformer(com.google.api.server.spi.config.ApiTransformer) TypeToken(com.google.common.reflect.TypeToken)

Aggregations

ApiTransformer (com.google.api.server.spi.config.ApiTransformer)1 Transformer (com.google.api.server.spi.config.Transformer)1 TypeToken (com.google.common.reflect.TypeToken)1