Search in sources :

Example 1 with ArgumentDefinition

use of com.palantir.dialogue.annotations.processor.data.ArgumentDefinition in project dialogue by palantir.

the class ServiceImplementationGenerator method serializer.

private FieldSpec serializer(ArgumentDefinition argumentDefinition, TypeName serializerType, String serializerFieldName) {
    TypeName className = ArgumentTypes.caseOf(argumentDefinition.argType()).primitive((javaTypeName, _parameterSerializerMethodName, _isList) -> javaTypeName).mapType(javaTypeName -> javaTypeName).customType(typeName -> typeName).otherwiseEmpty().get();
    ParameterizedTypeName deserializerType = ParameterizedTypeName.get(ClassName.get(Serializer.class), className);
    return FieldSpec.builder(deserializerType, serializerFieldName).addModifiers(Modifier.PRIVATE, Modifier.FINAL).initializer("new $T().serializerFor(new $T<$T>() {})", serializerType, TypeMarker.class, className).build();
}
Also used : OptionalType(com.palantir.dialogue.annotations.processor.data.ArgumentType.OptionalType) Modifier(javax.lang.model.element.Modifier) FieldSpec(com.squareup.javapoet.FieldSpec) ClassName(com.squareup.javapoet.ClassName) Serializer(com.palantir.dialogue.Serializer) ParameterEncoderType(com.palantir.dialogue.annotations.processor.data.ParameterEncoderType) Cases(com.palantir.dialogue.annotations.processor.data.ParameterType.Cases) ParameterSerializer(com.palantir.dialogue.annotations.ParameterSerializer) ErrorHandlingVoidDeserializer(com.palantir.dialogue.annotations.ErrorHandlingVoidDeserializer) Request(com.palantir.dialogue.Request) CodeBlock(com.squareup.javapoet.CodeBlock) DefaultParameterSerializer(com.palantir.dialogue.annotations.DefaultParameterSerializer) ParameterSpec(com.squareup.javapoet.ParameterSpec) ParameterTypes(com.palantir.dialogue.annotations.processor.data.ParameterTypes) Deserializer(com.palantir.dialogue.Deserializer) MethodSpec(com.squareup.javapoet.MethodSpec) EncoderType(com.palantir.dialogue.annotations.processor.data.ParameterEncoderType.EncoderType) ServiceDefinition(com.palantir.dialogue.annotations.processor.data.ServiceDefinition) ParameterizedTypeName(com.squareup.javapoet.ParameterizedTypeName) ReturnType(com.palantir.dialogue.annotations.processor.data.ReturnType) ArgumentTypes(com.palantir.dialogue.annotations.processor.data.ArgumentTypes) TypeSpec(com.squareup.javapoet.TypeSpec) Collectors(java.util.stream.Collectors) ErrorHandlingDeserializerFactory(com.palantir.dialogue.annotations.ErrorHandlingDeserializerFactory) EndpointChannel(com.palantir.dialogue.EndpointChannel) List(java.util.List) ArgumentType(com.palantir.dialogue.annotations.processor.data.ArgumentType) TypeName(com.squareup.javapoet.TypeName) Optional(java.util.Optional) TypeMarker(com.palantir.dialogue.TypeMarker) ArgumentDefinition(com.palantir.dialogue.annotations.processor.data.ArgumentDefinition) EndpointDefinition(com.palantir.dialogue.annotations.processor.data.EndpointDefinition) ParameterizedTypeName(com.squareup.javapoet.ParameterizedTypeName) TypeName(com.squareup.javapoet.TypeName) TypeMarker(com.palantir.dialogue.TypeMarker) ParameterizedTypeName(com.squareup.javapoet.ParameterizedTypeName) Serializer(com.palantir.dialogue.Serializer) ParameterSerializer(com.palantir.dialogue.annotations.ParameterSerializer) DefaultParameterSerializer(com.palantir.dialogue.annotations.DefaultParameterSerializer)

Aggregations

Deserializer (com.palantir.dialogue.Deserializer)1 EndpointChannel (com.palantir.dialogue.EndpointChannel)1 Request (com.palantir.dialogue.Request)1 Serializer (com.palantir.dialogue.Serializer)1 TypeMarker (com.palantir.dialogue.TypeMarker)1 DefaultParameterSerializer (com.palantir.dialogue.annotations.DefaultParameterSerializer)1 ErrorHandlingDeserializerFactory (com.palantir.dialogue.annotations.ErrorHandlingDeserializerFactory)1 ErrorHandlingVoidDeserializer (com.palantir.dialogue.annotations.ErrorHandlingVoidDeserializer)1 ParameterSerializer (com.palantir.dialogue.annotations.ParameterSerializer)1 ArgumentDefinition (com.palantir.dialogue.annotations.processor.data.ArgumentDefinition)1 ArgumentType (com.palantir.dialogue.annotations.processor.data.ArgumentType)1 OptionalType (com.palantir.dialogue.annotations.processor.data.ArgumentType.OptionalType)1 ArgumentTypes (com.palantir.dialogue.annotations.processor.data.ArgumentTypes)1 EndpointDefinition (com.palantir.dialogue.annotations.processor.data.EndpointDefinition)1 ParameterEncoderType (com.palantir.dialogue.annotations.processor.data.ParameterEncoderType)1 EncoderType (com.palantir.dialogue.annotations.processor.data.ParameterEncoderType.EncoderType)1 Cases (com.palantir.dialogue.annotations.processor.data.ParameterType.Cases)1 ParameterTypes (com.palantir.dialogue.annotations.processor.data.ParameterTypes)1 ReturnType (com.palantir.dialogue.annotations.processor.data.ReturnType)1 ServiceDefinition (com.palantir.dialogue.annotations.processor.data.ServiceDefinition)1