Search in sources :

Example 1 with Serializer

use of com.palantir.dialogue.Serializer in project conjure-java by palantir.

the class DefaultStaticFactoryMethodGenerator method serializer.

private Optional<FieldSpec> serializer(EndpointName endpointName, Type type) {
    if (type.accept(TypeVisitor.IS_BINARY)) {
        return Optional.empty();
    }
    TypeName className = returnTypes.baseType(type).box();
    ParameterizedTypeName deserializerType = ParameterizedTypeName.get(ClassName.get(Serializer.class), className);
    return Optional.of(FieldSpec.builder(deserializerType, endpointName + "Serializer").addModifiers(Modifier.PRIVATE, Modifier.FINAL).initializer("$L.bodySerDe().serializer(new $T<$T>() {})", StaticFactoryMethodGenerator.RUNTIME, TypeMarker.class, className).build());
}
Also used : TypeName(com.squareup.javapoet.TypeName) ParameterizedTypeName(com.squareup.javapoet.ParameterizedTypeName) ParameterizedTypeName(com.squareup.javapoet.ParameterizedTypeName) Serializer(com.palantir.dialogue.Serializer)

Example 2 with Serializer

use of com.palantir.dialogue.Serializer in project conjure-java by palantir.

the class EteServiceBlocking method of.

/**
 * Creates a synchronous/blocking client for a EteService service.
 */
static EteServiceBlocking of(EndpointChannelFactory _endpointChannelFactory, ConjureRuntime _runtime) {
    return new EteServiceBlocking() {

        private final PlainSerDe _plainSerDe = _runtime.plainSerDe();

        private final EndpointChannel stringChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.string);

        private final Deserializer<String> stringDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<String>() {
        });

        private final EndpointChannel integerChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.integer);

        private final Deserializer<Integer> integerDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<Integer>() {
        });

        private final EndpointChannel double_Channel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.double_);

        private final Deserializer<Double> double_Deserializer = _runtime.bodySerDe().deserializer(new TypeMarker<Double>() {
        });

        private final EndpointChannel boolean_Channel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.boolean_);

        private final Deserializer<Boolean> boolean_Deserializer = _runtime.bodySerDe().deserializer(new TypeMarker<Boolean>() {
        });

        private final EndpointChannel safelongChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.safelong);

        private final Deserializer<SafeLong> safelongDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<SafeLong>() {
        });

        private final EndpointChannel ridChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.rid);

        private final Deserializer<ResourceIdentifier> ridDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<ResourceIdentifier>() {
        });

        private final EndpointChannel bearertokenChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.bearertoken);

        private final Deserializer<BearerToken> bearertokenDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<BearerToken>() {
        });

        private final EndpointChannel optionalStringChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.optionalString);

        private final Deserializer<Optional<String>> optionalStringDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<Optional<String>>() {
        });

        private final EndpointChannel optionalEmptyChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.optionalEmpty);

        private final Deserializer<Optional<String>> optionalEmptyDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<Optional<String>>() {
        });

        private final EndpointChannel datetimeChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.datetime);

        private final Deserializer<OffsetDateTime> datetimeDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<OffsetDateTime>() {
        });

        private final EndpointChannel binaryChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.binary);

        private final EndpointChannel pathChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.path);

        private final Deserializer<String> pathDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<String>() {
        });

        private final EndpointChannel externalLongPathChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.externalLongPath);

        private final Deserializer<Long> externalLongPathDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<Long>() {
        });

        private final EndpointChannel optionalExternalLongQueryChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.optionalExternalLongQuery);

        private final Deserializer<Optional<Long>> optionalExternalLongQueryDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<Optional<Long>>() {
        });

        private final Serializer<StringAliasExample> notNullBodySerializer = _runtime.bodySerDe().serializer(new TypeMarker<StringAliasExample>() {
        });

        private final EndpointChannel notNullBodyChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.notNullBody);

        private final Deserializer<StringAliasExample> notNullBodyDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<StringAliasExample>() {
        });

        private final EndpointChannel aliasOneChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.aliasOne);

        private final Deserializer<StringAliasExample> aliasOneDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<StringAliasExample>() {
        });

        private final EndpointChannel optionalAliasOneChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.optionalAliasOne);

        private final Deserializer<StringAliasExample> optionalAliasOneDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<StringAliasExample>() {
        });

        private final EndpointChannel aliasTwoChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.aliasTwo);

        private final Deserializer<NestedStringAliasExample> aliasTwoDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<NestedStringAliasExample>() {
        });

        private final Serializer<StringAliasExample> notNullBodyExternalImportSerializer = _runtime.bodySerDe().serializer(new TypeMarker<StringAliasExample>() {
        });

        private final EndpointChannel notNullBodyExternalImportChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.notNullBodyExternalImport);

        private final Deserializer<StringAliasExample> notNullBodyExternalImportDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<StringAliasExample>() {
        });

        private final Serializer<Optional<StringAliasExample>> optionalBodyExternalImportSerializer = _runtime.bodySerDe().serializer(new TypeMarker<Optional<StringAliasExample>>() {
        });

        private final EndpointChannel optionalBodyExternalImportChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.optionalBodyExternalImport);

        private final Deserializer<Optional<StringAliasExample>> optionalBodyExternalImportDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<Optional<StringAliasExample>>() {
        });

        private final EndpointChannel optionalQueryExternalImportChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.optionalQueryExternalImport);

        private final Deserializer<Optional<StringAliasExample>> optionalQueryExternalImportDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<Optional<StringAliasExample>>() {
        });

        private final EndpointChannel noReturnChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.noReturn);

        private final Deserializer<Void> noReturnDeserializer = _runtime.bodySerDe().emptyBodyDeserializer();

        private final EndpointChannel enumQueryChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.enumQuery);

        private final Deserializer<SimpleEnum> enumQueryDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<SimpleEnum>() {
        });

        private final EndpointChannel enumListQueryChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.enumListQuery);

        private final Deserializer<List<SimpleEnum>> enumListQueryDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<List<SimpleEnum>>() {
        });

        private final EndpointChannel optionalEnumQueryChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.optionalEnumQuery);

        private final Deserializer<Optional<SimpleEnum>> optionalEnumQueryDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<Optional<SimpleEnum>>() {
        });

        private final EndpointChannel enumHeaderChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.enumHeader);

        private final Deserializer<SimpleEnum> enumHeaderDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<SimpleEnum>() {
        });

        private final EndpointChannel aliasLongEndpointChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.aliasLongEndpoint);

        private final Deserializer<Optional<LongAlias>> aliasLongEndpointDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<Optional<LongAlias>>() {
        });

        private final EndpointChannel complexQueryParametersChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.complexQueryParameters);

        private final Deserializer<Void> complexQueryParametersDeserializer = _runtime.bodySerDe().emptyBodyDeserializer();

        private final Serializer<List<Optional<String>>> receiveListOfOptionalsSerializer = _runtime.bodySerDe().serializer(new TypeMarker<List<Optional<String>>>() {
        });

        private final EndpointChannel receiveListOfOptionalsChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.receiveListOfOptionals);

        private final Deserializer<Void> receiveListOfOptionalsDeserializer = _runtime.bodySerDe().emptyBodyDeserializer();

        private final Serializer<Set<Optional<String>>> receiveSetOfOptionalsSerializer = _runtime.bodySerDe().serializer(new TypeMarker<Set<Optional<String>>>() {
        });

        private final EndpointChannel receiveSetOfOptionalsChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.receiveSetOfOptionals);

        private final Deserializer<Void> receiveSetOfOptionalsDeserializer = _runtime.bodySerDe().emptyBodyDeserializer();

        private final Serializer<List<String>> receiveListOfStringsSerializer = _runtime.bodySerDe().serializer(new TypeMarker<List<String>>() {
        });

        private final EndpointChannel receiveListOfStringsChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.receiveListOfStrings);

        private final Deserializer<Void> receiveListOfStringsDeserializer = _runtime.bodySerDe().emptyBodyDeserializer();

        @Override
        public String string(AuthHeader authHeader) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            return _runtime.clients().callBlocking(stringChannel, _request.build(), stringDeserializer);
        }

        @Override
        public int integer(AuthHeader authHeader) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            return _runtime.clients().callBlocking(integerChannel, _request.build(), integerDeserializer);
        }

        @Override
        public double double_(AuthHeader authHeader) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            return _runtime.clients().callBlocking(double_Channel, _request.build(), double_Deserializer);
        }

        @Override
        public boolean boolean_(AuthHeader authHeader) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            return _runtime.clients().callBlocking(boolean_Channel, _request.build(), boolean_Deserializer);
        }

        @Override
        public SafeLong safelong(AuthHeader authHeader) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            return _runtime.clients().callBlocking(safelongChannel, _request.build(), safelongDeserializer);
        }

        @Override
        public ResourceIdentifier rid(AuthHeader authHeader) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            return _runtime.clients().callBlocking(ridChannel, _request.build(), ridDeserializer);
        }

        @Override
        public BearerToken bearertoken(AuthHeader authHeader) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            return _runtime.clients().callBlocking(bearertokenChannel, _request.build(), bearertokenDeserializer);
        }

        @Override
        public Optional<String> optionalString(AuthHeader authHeader) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            return _runtime.clients().callBlocking(optionalStringChannel, _request.build(), optionalStringDeserializer);
        }

        @Override
        public Optional<String> optionalEmpty(AuthHeader authHeader) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            return _runtime.clients().callBlocking(optionalEmptyChannel, _request.build(), optionalEmptyDeserializer);
        }

        @Override
        public OffsetDateTime datetime(AuthHeader authHeader) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            return _runtime.clients().callBlocking(datetimeChannel, _request.build(), datetimeDeserializer);
        }

        @Override
        public InputStream binary(AuthHeader authHeader) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            return _runtime.clients().callBlocking(binaryChannel, _request.build(), _runtime.bodySerDe().inputStreamDeserializer());
        }

        @Override
        public String path(AuthHeader authHeader, String param) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            _request.putPathParams("param", _plainSerDe.serializeString(param));
            return _runtime.clients().callBlocking(pathChannel, _request.build(), pathDeserializer);
        }

        @Override
        public long externalLongPath(AuthHeader authHeader, long param) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            _request.putPathParams("param", Objects.toString(param));
            return _runtime.clients().callBlocking(externalLongPathChannel, _request.build(), externalLongPathDeserializer);
        }

        @Override
        public Optional<Long> optionalExternalLongQuery(AuthHeader authHeader, Optional<Long> param) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            if (param.isPresent()) {
                _request.putQueryParams("param", Objects.toString(param.get()));
            }
            return _runtime.clients().callBlocking(optionalExternalLongQueryChannel, _request.build(), optionalExternalLongQueryDeserializer);
        }

        @Override
        public StringAliasExample notNullBody(AuthHeader authHeader, StringAliasExample notNullBody) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            _request.body(notNullBodySerializer.serialize(notNullBody));
            return _runtime.clients().callBlocking(notNullBodyChannel, _request.build(), notNullBodyDeserializer);
        }

        @Override
        public StringAliasExample aliasOne(AuthHeader authHeader, StringAliasExample queryParamName) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            _request.putQueryParams("queryParamName", _plainSerDe.serializeString(queryParamName.get()));
            return _runtime.clients().callBlocking(aliasOneChannel, _request.build(), aliasOneDeserializer);
        }

        @Override
        public StringAliasExample optionalAliasOne(AuthHeader authHeader, Optional<StringAliasExample> queryParamName) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            if (queryParamName.isPresent()) {
                _request.putQueryParams("queryParamName", _plainSerDe.serializeString(queryParamName.get().get()));
            }
            return _runtime.clients().callBlocking(optionalAliasOneChannel, _request.build(), optionalAliasOneDeserializer);
        }

        @Override
        public NestedStringAliasExample aliasTwo(AuthHeader authHeader, NestedStringAliasExample queryParamName) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            _request.putQueryParams("queryParamName", _plainSerDe.serializeString(queryParamName.get().get()));
            return _runtime.clients().callBlocking(aliasTwoChannel, _request.build(), aliasTwoDeserializer);
        }

        @Override
        public StringAliasExample notNullBodyExternalImport(AuthHeader authHeader, StringAliasExample notNullBody) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            _request.body(notNullBodyExternalImportSerializer.serialize(notNullBody));
            return _runtime.clients().callBlocking(notNullBodyExternalImportChannel, _request.build(), notNullBodyExternalImportDeserializer);
        }

        @Override
        public Optional<StringAliasExample> optionalBodyExternalImport(AuthHeader authHeader, Optional<StringAliasExample> body) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            _request.body(optionalBodyExternalImportSerializer.serialize(body));
            return _runtime.clients().callBlocking(optionalBodyExternalImportChannel, _request.build(), optionalBodyExternalImportDeserializer);
        }

        @Override
        public Optional<StringAliasExample> optionalQueryExternalImport(AuthHeader authHeader, Optional<StringAliasExample> query) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            if (query.isPresent()) {
                _request.putQueryParams("query", Objects.toString(query.get()));
            }
            return _runtime.clients().callBlocking(optionalQueryExternalImportChannel, _request.build(), optionalQueryExternalImportDeserializer);
        }

        @Override
        public void noReturn(AuthHeader authHeader) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            _runtime.clients().callBlocking(noReturnChannel, _request.build(), noReturnDeserializer);
        }

        @Override
        public SimpleEnum enumQuery(AuthHeader authHeader, SimpleEnum queryParamName) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            _request.putQueryParams("queryParamName", Objects.toString(queryParamName));
            return _runtime.clients().callBlocking(enumQueryChannel, _request.build(), enumQueryDeserializer);
        }

        @Override
        public List<SimpleEnum> enumListQuery(AuthHeader authHeader, List<SimpleEnum> queryParamName) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            for (SimpleEnum queryParamNameElement : queryParamName) {
                _request.putQueryParams("queryParamName", Objects.toString(queryParamNameElement));
            }
            return _runtime.clients().callBlocking(enumListQueryChannel, _request.build(), enumListQueryDeserializer);
        }

        @Override
        public Optional<SimpleEnum> optionalEnumQuery(AuthHeader authHeader, Optional<SimpleEnum> queryParamName) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            if (queryParamName.isPresent()) {
                _request.putQueryParams("queryParamName", Objects.toString(queryParamName.get()));
            }
            return _runtime.clients().callBlocking(optionalEnumQueryChannel, _request.build(), optionalEnumQueryDeserializer);
        }

        @Override
        public SimpleEnum enumHeader(AuthHeader authHeader, SimpleEnum headerParameter) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            _request.putHeaderParams("Custom-Header", Objects.toString(headerParameter));
            return _runtime.clients().callBlocking(enumHeaderChannel, _request.build(), enumHeaderDeserializer);
        }

        @Override
        public Optional<LongAlias> aliasLongEndpoint(AuthHeader authHeader, Optional<LongAlias> input) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            if (input.isPresent()) {
                _request.putQueryParams("input", Objects.toString(input.get().get()));
            }
            return _runtime.clients().callBlocking(aliasLongEndpointChannel, _request.build(), aliasLongEndpointDeserializer);
        }

        @Override
        public void complexQueryParameters(AuthHeader authHeader, ResourceIdentifier datasetRid, Set<StringAliasExample> strings, Set<Long> longs, Set<Integer> ints) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            _request.putPathParams("datasetRid", _plainSerDe.serializeRid(datasetRid));
            for (StringAliasExample stringsElement : strings) {
                _request.putQueryParams("strings", _plainSerDe.serializeString(stringsElement.get()));
            }
            for (long longsElement : longs) {
                _request.putQueryParams("longs", Objects.toString(longsElement));
            }
            for (int intsElement : ints) {
                _request.putQueryParams("ints", _plainSerDe.serializeInteger(intsElement));
            }
            _runtime.clients().callBlocking(complexQueryParametersChannel, _request.build(), complexQueryParametersDeserializer);
        }

        @Override
        public void receiveListOfOptionals(AuthHeader authHeader, List<Optional<String>> value) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            _request.body(receiveListOfOptionalsSerializer.serialize(value));
            _runtime.clients().callBlocking(receiveListOfOptionalsChannel, _request.build(), receiveListOfOptionalsDeserializer);
        }

        @Override
        public void receiveSetOfOptionals(AuthHeader authHeader, Set<Optional<String>> value) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            _request.body(receiveSetOfOptionalsSerializer.serialize(value));
            _runtime.clients().callBlocking(receiveSetOfOptionalsChannel, _request.build(), receiveSetOfOptionalsDeserializer);
        }

        @Override
        public void receiveListOfStrings(AuthHeader authHeader, List<String> value) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            _request.body(receiveListOfStringsSerializer.serialize(value));
            _runtime.clients().callBlocking(receiveListOfStringsChannel, _request.build(), receiveListOfStringsDeserializer);
        }

        @Override
        public String toString() {
            return "EteServiceBlocking{_endpointChannelFactory=" + _endpointChannelFactory + ", runtime=" + _runtime + '}';
        }
    };
}
Also used : AuthHeader(com.palantir.tokens.auth.AuthHeader) Set(java.util.Set) Optional(java.util.Optional) TypeMarker(com.palantir.dialogue.TypeMarker) Request(com.palantir.dialogue.Request) String(java.lang.String) ClientEndpoint(com.palantir.conjure.java.lib.internal.ClientEndpoint) Endpoint(com.palantir.dialogue.Endpoint) ResourceIdentifier(com.palantir.ri.ResourceIdentifier) Deserializer(com.palantir.dialogue.Deserializer) Long(java.lang.Long) SafeLong(com.palantir.conjure.java.lib.SafeLong) EndpointChannel(com.palantir.dialogue.EndpointChannel) List(java.util.List) PlainSerDe(com.palantir.dialogue.PlainSerDe) Serializer(com.palantir.dialogue.Serializer)

Example 3 with Serializer

use of com.palantir.dialogue.Serializer 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)

Example 4 with Serializer

use of com.palantir.dialogue.Serializer in project conjure-java by palantir.

the class DefaultStaticFactoryMethodGenerator method generate.

@Override
public MethodSpec generate(ServiceDefinition def) {
    ClassName className = getClassName(def);
    TypeSpec.Builder impl = TypeSpec.anonymousClassBuilder("").addSuperinterface(className);
    impl.addField(FieldSpec.builder(PlainSerDe.class, PLAIN_SER_DE).addModifiers(Modifier.PRIVATE, Modifier.FINAL).initializer(CodeBlock.of("$L.plainSerDe()", StaticFactoryMethodGenerator.RUNTIME)).build());
    def.getEndpoints().forEach(endpoint -> {
        endpoint.getArgs().stream().filter(arg -> arg.getParamType().accept(ParameterTypeVisitor.IS_BODY)).findAny().flatMap(body -> serializer(endpoint.getEndpointName(), body.getType())).ifPresent(impl::addField);
        impl.addField(bindEndpointChannel(def, endpoint));
        deserializer(endpoint.getEndpointName(), endpoint.getReturns()).ifPresent(impl::addField);
        impl.addMethod(clientImpl(endpoint));
    });
    impl.addMethod(DefaultStaticFactoryMethodGenerator.toStringMethod(className));
    String javadoc = methodType.switchBy("Creates a synchronous/blocking client for a $L service.", "Creates an " + "asynchronous/non-blocking client for a $L service.");
    MethodSpec method = MethodSpec.methodBuilder("of").addModifiers(Modifier.STATIC, Modifier.PUBLIC).addJavadoc(javadoc, def.getServiceName().getName()).returns(className).addParameter(EndpointChannelFactory.class, StaticFactoryMethodGenerator.ENDPOINT_CHANNEL_FACTORY).addParameter(ConjureRuntime.class, StaticFactoryMethodGenerator.RUNTIME).addCode(CodeBlock.builder().add("return $L;", impl.build()).build()).build();
    return method;
}
Also used : HeaderAuthType(com.palantir.conjure.spec.HeaderAuthType) TypeVisitor(com.palantir.conjure.visitor.TypeVisitor) Modifier(javax.lang.model.element.Modifier) SafeIllegalStateException(com.palantir.logsafe.exceptions.SafeIllegalStateException) ClassName(com.squareup.javapoet.ClassName) ServiceDefinition(com.palantir.conjure.spec.ServiceDefinition) Options(com.palantir.conjure.java.Options) ParameterTypeVisitor(com.palantir.conjure.visitor.ParameterTypeVisitor) MapType(com.palantir.conjure.spec.MapType) OptionalType(com.palantir.conjure.spec.OptionalType) ParameterSpec(com.squareup.javapoet.ParameterSpec) ImmutableMap(com.google.common.collect.ImmutableMap) AuthType(com.palantir.conjure.spec.AuthType) Deserializer(com.palantir.dialogue.Deserializer) BodyParameterType(com.palantir.conjure.spec.BodyParameterType) ParameterType(com.palantir.conjure.spec.ParameterType) Objects(java.util.Objects) List(java.util.List) TypeName(com.squareup.javapoet.TypeName) Optional(java.util.Optional) TypeMarker(com.palantir.dialogue.TypeMarker) PrimitiveType(com.palantir.conjure.spec.PrimitiveType) EndpointDefinition(com.palantir.conjure.spec.EndpointDefinition) ListType(com.palantir.conjure.spec.ListType) Auth(com.palantir.conjure.java.services.Auth) ExternalReference(com.palantir.conjure.spec.ExternalReference) FieldSpec(com.squareup.javapoet.FieldSpec) Type(com.palantir.conjure.spec.Type) PathParameterType(com.palantir.conjure.spec.PathParameterType) TypeDefinitionVisitor(com.palantir.conjure.visitor.TypeDefinitionVisitor) Serializer(com.palantir.dialogue.Serializer) PlainSerDe(com.palantir.dialogue.PlainSerDe) SafeArg(com.palantir.logsafe.SafeArg) ConjureRuntime(com.palantir.dialogue.ConjureRuntime) SetType(com.palantir.conjure.spec.SetType) Request(com.palantir.dialogue.Request) CodeBlock(com.squareup.javapoet.CodeBlock) EndpointChannelFactory(com.palantir.dialogue.EndpointChannelFactory) TypeDefinition(com.palantir.conjure.spec.TypeDefinition) MethodSpec(com.squareup.javapoet.MethodSpec) CookieAuthType(com.palantir.conjure.spec.CookieAuthType) ParameterizedTypeName(com.squareup.javapoet.ParameterizedTypeName) TypeSpec(com.squareup.javapoet.TypeSpec) EndpointName(com.palantir.conjure.spec.EndpointName) EndpointChannel(com.palantir.dialogue.EndpointChannel) QueryParameterType(com.palantir.conjure.spec.QueryParameterType) AnnotationSpec(com.squareup.javapoet.AnnotationSpec) HeaderParameterType(com.palantir.conjure.spec.HeaderParameterType) ArgumentDefinition(com.palantir.conjure.spec.ArgumentDefinition) MethodSpec(com.squareup.javapoet.MethodSpec) EndpointChannelFactory(com.palantir.dialogue.EndpointChannelFactory) ClassName(com.squareup.javapoet.ClassName) TypeSpec(com.squareup.javapoet.TypeSpec)

Example 5 with Serializer

use of com.palantir.dialogue.Serializer in project conjure-java by palantir.

the class EteServiceAsync method of.

/**
 * Creates an asynchronous/non-blocking client for a EteService service.
 */
static EteServiceAsync of(EndpointChannelFactory _endpointChannelFactory, ConjureRuntime _runtime) {
    return new EteServiceAsync() {

        private final PlainSerDe _plainSerDe = _runtime.plainSerDe();

        private final EndpointChannel stringChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.string);

        private final Deserializer<String> stringDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<String>() {
        });

        private final EndpointChannel integerChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.integer);

        private final Deserializer<Integer> integerDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<Integer>() {
        });

        private final EndpointChannel double_Channel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.double_);

        private final Deserializer<Double> double_Deserializer = _runtime.bodySerDe().deserializer(new TypeMarker<Double>() {
        });

        private final EndpointChannel boolean_Channel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.boolean_);

        private final Deserializer<Boolean> boolean_Deserializer = _runtime.bodySerDe().deserializer(new TypeMarker<Boolean>() {
        });

        private final EndpointChannel safelongChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.safelong);

        private final Deserializer<SafeLong> safelongDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<SafeLong>() {
        });

        private final EndpointChannel ridChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.rid);

        private final Deserializer<ResourceIdentifier> ridDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<ResourceIdentifier>() {
        });

        private final EndpointChannel bearertokenChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.bearertoken);

        private final Deserializer<BearerToken> bearertokenDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<BearerToken>() {
        });

        private final EndpointChannel optionalStringChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.optionalString);

        private final Deserializer<Optional<String>> optionalStringDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<Optional<String>>() {
        });

        private final EndpointChannel optionalEmptyChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.optionalEmpty);

        private final Deserializer<Optional<String>> optionalEmptyDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<Optional<String>>() {
        });

        private final EndpointChannel datetimeChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.datetime);

        private final Deserializer<OffsetDateTime> datetimeDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<OffsetDateTime>() {
        });

        private final EndpointChannel binaryChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.binary);

        private final EndpointChannel pathChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.path);

        private final Deserializer<String> pathDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<String>() {
        });

        private final EndpointChannel externalLongPathChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.externalLongPath);

        private final Deserializer<Long> externalLongPathDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<Long>() {
        });

        private final EndpointChannel optionalExternalLongQueryChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.optionalExternalLongQuery);

        private final Deserializer<Optional<Long>> optionalExternalLongQueryDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<Optional<Long>>() {
        });

        private final Serializer<StringAliasExample> notNullBodySerializer = _runtime.bodySerDe().serializer(new TypeMarker<StringAliasExample>() {
        });

        private final EndpointChannel notNullBodyChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.notNullBody);

        private final Deserializer<StringAliasExample> notNullBodyDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<StringAliasExample>() {
        });

        private final EndpointChannel aliasOneChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.aliasOne);

        private final Deserializer<StringAliasExample> aliasOneDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<StringAliasExample>() {
        });

        private final EndpointChannel optionalAliasOneChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.optionalAliasOne);

        private final Deserializer<StringAliasExample> optionalAliasOneDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<StringAliasExample>() {
        });

        private final EndpointChannel aliasTwoChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.aliasTwo);

        private final Deserializer<NestedStringAliasExample> aliasTwoDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<NestedStringAliasExample>() {
        });

        private final Serializer<StringAliasExample> notNullBodyExternalImportSerializer = _runtime.bodySerDe().serializer(new TypeMarker<StringAliasExample>() {
        });

        private final EndpointChannel notNullBodyExternalImportChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.notNullBodyExternalImport);

        private final Deserializer<StringAliasExample> notNullBodyExternalImportDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<StringAliasExample>() {
        });

        private final Serializer<Optional<StringAliasExample>> optionalBodyExternalImportSerializer = _runtime.bodySerDe().serializer(new TypeMarker<Optional<StringAliasExample>>() {
        });

        private final EndpointChannel optionalBodyExternalImportChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.optionalBodyExternalImport);

        private final Deserializer<Optional<StringAliasExample>> optionalBodyExternalImportDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<Optional<StringAliasExample>>() {
        });

        private final EndpointChannel optionalQueryExternalImportChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.optionalQueryExternalImport);

        private final Deserializer<Optional<StringAliasExample>> optionalQueryExternalImportDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<Optional<StringAliasExample>>() {
        });

        private final EndpointChannel noReturnChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.noReturn);

        private final Deserializer<Void> noReturnDeserializer = _runtime.bodySerDe().emptyBodyDeserializer();

        private final EndpointChannel enumQueryChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.enumQuery);

        private final Deserializer<SimpleEnum> enumQueryDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<SimpleEnum>() {
        });

        private final EndpointChannel enumListQueryChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.enumListQuery);

        private final Deserializer<List<SimpleEnum>> enumListQueryDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<List<SimpleEnum>>() {
        });

        private final EndpointChannel optionalEnumQueryChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.optionalEnumQuery);

        private final Deserializer<Optional<SimpleEnum>> optionalEnumQueryDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<Optional<SimpleEnum>>() {
        });

        private final EndpointChannel enumHeaderChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.enumHeader);

        private final Deserializer<SimpleEnum> enumHeaderDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<SimpleEnum>() {
        });

        private final EndpointChannel aliasLongEndpointChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.aliasLongEndpoint);

        private final Deserializer<Optional<LongAlias>> aliasLongEndpointDeserializer = _runtime.bodySerDe().deserializer(new TypeMarker<Optional<LongAlias>>() {
        });

        private final EndpointChannel complexQueryParametersChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.complexQueryParameters);

        private final Deserializer<Void> complexQueryParametersDeserializer = _runtime.bodySerDe().emptyBodyDeserializer();

        private final Serializer<List<Optional<String>>> receiveListOfOptionalsSerializer = _runtime.bodySerDe().serializer(new TypeMarker<List<Optional<String>>>() {
        });

        private final EndpointChannel receiveListOfOptionalsChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.receiveListOfOptionals);

        private final Deserializer<Void> receiveListOfOptionalsDeserializer = _runtime.bodySerDe().emptyBodyDeserializer();

        private final Serializer<Set<Optional<String>>> receiveSetOfOptionalsSerializer = _runtime.bodySerDe().serializer(new TypeMarker<Set<Optional<String>>>() {
        });

        private final EndpointChannel receiveSetOfOptionalsChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.receiveSetOfOptionals);

        private final Deserializer<Void> receiveSetOfOptionalsDeserializer = _runtime.bodySerDe().emptyBodyDeserializer();

        private final Serializer<List<String>> receiveListOfStringsSerializer = _runtime.bodySerDe().serializer(new TypeMarker<List<String>>() {
        });

        private final EndpointChannel receiveListOfStringsChannel = _endpointChannelFactory.endpoint(DialogueEteEndpoints.receiveListOfStrings);

        private final Deserializer<Void> receiveListOfStringsDeserializer = _runtime.bodySerDe().emptyBodyDeserializer();

        @Override
        public ListenableFuture<String> string(AuthHeader authHeader) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            return _runtime.clients().call(stringChannel, _request.build(), stringDeserializer);
        }

        @Override
        public ListenableFuture<Integer> integer(AuthHeader authHeader) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            return _runtime.clients().call(integerChannel, _request.build(), integerDeserializer);
        }

        @Override
        public ListenableFuture<Double> double_(AuthHeader authHeader) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            return _runtime.clients().call(double_Channel, _request.build(), double_Deserializer);
        }

        @Override
        public ListenableFuture<Boolean> boolean_(AuthHeader authHeader) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            return _runtime.clients().call(boolean_Channel, _request.build(), boolean_Deserializer);
        }

        @Override
        public ListenableFuture<SafeLong> safelong(AuthHeader authHeader) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            return _runtime.clients().call(safelongChannel, _request.build(), safelongDeserializer);
        }

        @Override
        public ListenableFuture<ResourceIdentifier> rid(AuthHeader authHeader) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            return _runtime.clients().call(ridChannel, _request.build(), ridDeserializer);
        }

        @Override
        public ListenableFuture<BearerToken> bearertoken(AuthHeader authHeader) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            return _runtime.clients().call(bearertokenChannel, _request.build(), bearertokenDeserializer);
        }

        @Override
        public ListenableFuture<Optional<String>> optionalString(AuthHeader authHeader) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            return _runtime.clients().call(optionalStringChannel, _request.build(), optionalStringDeserializer);
        }

        @Override
        public ListenableFuture<Optional<String>> optionalEmpty(AuthHeader authHeader) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            return _runtime.clients().call(optionalEmptyChannel, _request.build(), optionalEmptyDeserializer);
        }

        @Override
        public ListenableFuture<OffsetDateTime> datetime(AuthHeader authHeader) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            return _runtime.clients().call(datetimeChannel, _request.build(), datetimeDeserializer);
        }

        @Override
        public ListenableFuture<InputStream> binary(AuthHeader authHeader) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            return _runtime.clients().call(binaryChannel, _request.build(), _runtime.bodySerDe().inputStreamDeserializer());
        }

        @Override
        public ListenableFuture<String> path(AuthHeader authHeader, String param) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            _request.putPathParams("param", _plainSerDe.serializeString(param));
            return _runtime.clients().call(pathChannel, _request.build(), pathDeserializer);
        }

        @Override
        public ListenableFuture<Long> externalLongPath(AuthHeader authHeader, long param) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            _request.putPathParams("param", Objects.toString(param));
            return _runtime.clients().call(externalLongPathChannel, _request.build(), externalLongPathDeserializer);
        }

        @Override
        public ListenableFuture<Optional<Long>> optionalExternalLongQuery(AuthHeader authHeader, Optional<Long> param) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            if (param.isPresent()) {
                _request.putQueryParams("param", Objects.toString(param.get()));
            }
            return _runtime.clients().call(optionalExternalLongQueryChannel, _request.build(), optionalExternalLongQueryDeserializer);
        }

        @Override
        public ListenableFuture<StringAliasExample> notNullBody(AuthHeader authHeader, StringAliasExample notNullBody) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            _request.body(notNullBodySerializer.serialize(notNullBody));
            return _runtime.clients().call(notNullBodyChannel, _request.build(), notNullBodyDeserializer);
        }

        @Override
        public ListenableFuture<StringAliasExample> aliasOne(AuthHeader authHeader, StringAliasExample queryParamName) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            _request.putQueryParams("queryParamName", _plainSerDe.serializeString(queryParamName.get()));
            return _runtime.clients().call(aliasOneChannel, _request.build(), aliasOneDeserializer);
        }

        @Override
        public ListenableFuture<StringAliasExample> optionalAliasOne(AuthHeader authHeader, Optional<StringAliasExample> queryParamName) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            if (queryParamName.isPresent()) {
                _request.putQueryParams("queryParamName", _plainSerDe.serializeString(queryParamName.get().get()));
            }
            return _runtime.clients().call(optionalAliasOneChannel, _request.build(), optionalAliasOneDeserializer);
        }

        @Override
        public ListenableFuture<NestedStringAliasExample> aliasTwo(AuthHeader authHeader, NestedStringAliasExample queryParamName) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            _request.putQueryParams("queryParamName", _plainSerDe.serializeString(queryParamName.get().get()));
            return _runtime.clients().call(aliasTwoChannel, _request.build(), aliasTwoDeserializer);
        }

        @Override
        public ListenableFuture<StringAliasExample> notNullBodyExternalImport(AuthHeader authHeader, StringAliasExample notNullBody) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            _request.body(notNullBodyExternalImportSerializer.serialize(notNullBody));
            return _runtime.clients().call(notNullBodyExternalImportChannel, _request.build(), notNullBodyExternalImportDeserializer);
        }

        @Override
        public ListenableFuture<Optional<StringAliasExample>> optionalBodyExternalImport(AuthHeader authHeader, Optional<StringAliasExample> body) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            _request.body(optionalBodyExternalImportSerializer.serialize(body));
            return _runtime.clients().call(optionalBodyExternalImportChannel, _request.build(), optionalBodyExternalImportDeserializer);
        }

        @Override
        public ListenableFuture<Optional<StringAliasExample>> optionalQueryExternalImport(AuthHeader authHeader, Optional<StringAliasExample> query) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            if (query.isPresent()) {
                _request.putQueryParams("query", Objects.toString(query.get()));
            }
            return _runtime.clients().call(optionalQueryExternalImportChannel, _request.build(), optionalQueryExternalImportDeserializer);
        }

        @Override
        public ListenableFuture<Void> noReturn(AuthHeader authHeader) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            return _runtime.clients().call(noReturnChannel, _request.build(), noReturnDeserializer);
        }

        @Override
        public ListenableFuture<SimpleEnum> enumQuery(AuthHeader authHeader, SimpleEnum queryParamName) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            _request.putQueryParams("queryParamName", Objects.toString(queryParamName));
            return _runtime.clients().call(enumQueryChannel, _request.build(), enumQueryDeserializer);
        }

        @Override
        public ListenableFuture<List<SimpleEnum>> enumListQuery(AuthHeader authHeader, List<SimpleEnum> queryParamName) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            for (SimpleEnum queryParamNameElement : queryParamName) {
                _request.putQueryParams("queryParamName", Objects.toString(queryParamNameElement));
            }
            return _runtime.clients().call(enumListQueryChannel, _request.build(), enumListQueryDeserializer);
        }

        @Override
        public ListenableFuture<Optional<SimpleEnum>> optionalEnumQuery(AuthHeader authHeader, Optional<SimpleEnum> queryParamName) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            if (queryParamName.isPresent()) {
                _request.putQueryParams("queryParamName", Objects.toString(queryParamName.get()));
            }
            return _runtime.clients().call(optionalEnumQueryChannel, _request.build(), optionalEnumQueryDeserializer);
        }

        @Override
        public ListenableFuture<SimpleEnum> enumHeader(AuthHeader authHeader, SimpleEnum headerParameter) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            _request.putHeaderParams("Custom-Header", Objects.toString(headerParameter));
            return _runtime.clients().call(enumHeaderChannel, _request.build(), enumHeaderDeserializer);
        }

        @Override
        public ListenableFuture<Optional<LongAlias>> aliasLongEndpoint(AuthHeader authHeader, Optional<LongAlias> input) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            if (input.isPresent()) {
                _request.putQueryParams("input", Objects.toString(input.get().get()));
            }
            return _runtime.clients().call(aliasLongEndpointChannel, _request.build(), aliasLongEndpointDeserializer);
        }

        @Override
        public ListenableFuture<Void> complexQueryParameters(AuthHeader authHeader, ResourceIdentifier datasetRid, Set<StringAliasExample> strings, Set<Long> longs, Set<Integer> ints) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            _request.putPathParams("datasetRid", _plainSerDe.serializeRid(datasetRid));
            for (StringAliasExample stringsElement : strings) {
                _request.putQueryParams("strings", _plainSerDe.serializeString(stringsElement.get()));
            }
            for (long longsElement : longs) {
                _request.putQueryParams("longs", Objects.toString(longsElement));
            }
            for (int intsElement : ints) {
                _request.putQueryParams("ints", _plainSerDe.serializeInteger(intsElement));
            }
            return _runtime.clients().call(complexQueryParametersChannel, _request.build(), complexQueryParametersDeserializer);
        }

        @Override
        public ListenableFuture<Void> receiveListOfOptionals(AuthHeader authHeader, List<Optional<String>> value) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            _request.body(receiveListOfOptionalsSerializer.serialize(value));
            return _runtime.clients().call(receiveListOfOptionalsChannel, _request.build(), receiveListOfOptionalsDeserializer);
        }

        @Override
        public ListenableFuture<Void> receiveSetOfOptionals(AuthHeader authHeader, Set<Optional<String>> value) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            _request.body(receiveSetOfOptionalsSerializer.serialize(value));
            return _runtime.clients().call(receiveSetOfOptionalsChannel, _request.build(), receiveSetOfOptionalsDeserializer);
        }

        @Override
        public ListenableFuture<Void> receiveListOfStrings(AuthHeader authHeader, List<String> value) {
            Request.Builder _request = Request.builder();
            _request.putHeaderParams("Authorization", authHeader.toString());
            _request.body(receiveListOfStringsSerializer.serialize(value));
            return _runtime.clients().call(receiveListOfStringsChannel, _request.build(), receiveListOfStringsDeserializer);
        }

        @Override
        public String toString() {
            return "EteServiceAsync{_endpointChannelFactory=" + _endpointChannelFactory + ", runtime=" + _runtime + '}';
        }
    };
}
Also used : Set(java.util.Set) TypeMarker(com.palantir.dialogue.TypeMarker) String(java.lang.String) ResourceIdentifier(com.palantir.ri.ResourceIdentifier) EndpointChannel(com.palantir.dialogue.EndpointChannel) List(java.util.List) Boolean(java.lang.Boolean) Void(java.lang.Void) Serializer(com.palantir.dialogue.Serializer) AuthHeader(com.palantir.tokens.auth.AuthHeader) Optional(java.util.Optional) InputStream(java.io.InputStream) Request(com.palantir.dialogue.Request) Double(java.lang.Double) BearerToken(com.palantir.tokens.auth.BearerToken) ClientEndpoint(com.palantir.conjure.java.lib.internal.ClientEndpoint) Endpoint(com.palantir.dialogue.Endpoint) Integer(java.lang.Integer) OffsetDateTime(java.time.OffsetDateTime) Deserializer(com.palantir.dialogue.Deserializer) SafeLong(com.palantir.conjure.java.lib.SafeLong) Long(java.lang.Long) SafeLong(com.palantir.conjure.java.lib.SafeLong) PlainSerDe(com.palantir.dialogue.PlainSerDe)

Aggregations

Serializer (com.palantir.dialogue.Serializer)5 Deserializer (com.palantir.dialogue.Deserializer)4 EndpointChannel (com.palantir.dialogue.EndpointChannel)4 Request (com.palantir.dialogue.Request)4 TypeMarker (com.palantir.dialogue.TypeMarker)4 List (java.util.List)4 Optional (java.util.Optional)4 PlainSerDe (com.palantir.dialogue.PlainSerDe)3 SafeLong (com.palantir.conjure.java.lib.SafeLong)2 ClientEndpoint (com.palantir.conjure.java.lib.internal.ClientEndpoint)2 Endpoint (com.palantir.dialogue.Endpoint)2 ParameterizedTypeName (com.squareup.javapoet.ParameterizedTypeName)2 TypeName (com.squareup.javapoet.TypeName)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Options (com.palantir.conjure.java.Options)1 Auth (com.palantir.conjure.java.services.Auth)1 ArgumentDefinition (com.palantir.conjure.spec.ArgumentDefinition)1 AuthType (com.palantir.conjure.spec.AuthType)1 BodyParameterType (com.palantir.conjure.spec.BodyParameterType)1 CookieAuthType (com.palantir.conjure.spec.CookieAuthType)1