Search in sources :

Example 1 with Tags

use of com.palantir.conjure.java.util.Tags in project conjure-java by palantir.

the class UndertowServiceHandlerGenerator method addTags.

private static void addTags(EndpointDefinition endpointDefinition, TypeSpec.Builder endpointBuilder) {
    if (!endpointDefinition.getTags().isEmpty()) {
        CodeBlock arrayValues = CodeBlock.join(Collections2.transform(endpointDefinition.getTags(), value -> CodeBlock.of("$S", value)), ", ");
        endpointBuilder.addField(FieldSpec.builder(ParameterizedTypeName.get(ImmutableSet.class, String.class), "TAGS", Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL).initializer(CodeBlock.of("$T.of($L)", ImmutableSet.class, arrayValues)).build());
        endpointBuilder.addMethod(MethodSpec.methodBuilder("tags").addModifiers(Modifier.PUBLIC).addAnnotation(Override.class).returns(ParameterizedTypeName.get(Set.class, String.class)).addStatement("return TAGS").build());
    }
}
Also used : DefaultTypeVisitor(com.palantir.conjure.java.visitor.DefaultTypeVisitor) Endpoint(com.palantir.conjure.java.undertow.lib.Endpoint) HeaderAuthType(com.palantir.conjure.spec.HeaderAuthType) TypeVisitor(com.palantir.conjure.visitor.TypeVisitor) Modifier(javax.lang.model.element.Modifier) UndertowService(com.palantir.conjure.java.undertow.lib.UndertowService) HttpServerExchange(io.undertow.server.HttpServerExchange) AuthHeader(com.palantir.tokens.auth.AuthHeader) ClassName(com.squareup.javapoet.ClassName) ReturnValueWriter(com.palantir.conjure.java.undertow.lib.ReturnValueWriter) Collections2(com.google.common.collect.Collections2) ServiceDefinition(com.palantir.conjure.spec.ServiceDefinition) StringUtils(org.apache.commons.lang3.StringUtils) Options(com.palantir.conjure.java.Options) ParameterTypeVisitor(com.palantir.conjure.visitor.ParameterTypeVisitor) HttpString(io.undertow.util.HttpString) TypeMarker(com.palantir.conjure.java.undertow.lib.TypeMarker) Duration(java.time.Duration) Map(java.util.Map) CodeBlocks(com.palantir.conjure.java.types.CodeBlocks) OptionalType(com.palantir.conjure.spec.OptionalType) MoreVisitors(com.palantir.conjure.java.visitor.MoreVisitors) HumanReadableDuration(com.palantir.humanreadabletypes.HumanReadableDuration) ImmutableSet(com.google.common.collect.ImmutableSet) AuthType(com.palantir.conjure.spec.AuthType) MoreCollectors(com.google.common.collect.MoreCollectors) Collection(java.util.Collection) Set(java.util.Set) TypeMapper(com.palantir.conjure.java.types.TypeMapper) Streams(com.google.common.collect.Streams) ParameterType(com.palantir.conjure.spec.ParameterType) JavaFile(com.squareup.javapoet.JavaFile) List(java.util.List) Tags(com.palantir.conjure.java.util.Tags) UndertowRuntime(com.palantir.conjure.java.undertow.lib.UndertowRuntime) TypeName(com.squareup.javapoet.TypeName) Optional(java.util.Optional) Methods(io.undertow.util.Methods) PrimitiveType(com.palantir.conjure.spec.PrimitiveType) EndpointDefinition(com.palantir.conjure.spec.EndpointDefinition) Iterables(com.google.common.collect.Iterables) ListType(com.palantir.conjure.spec.ListType) ExternalReference(com.palantir.conjure.spec.ExternalReference) TypeFunctions(com.palantir.conjure.java.util.TypeFunctions) AuthTypeVisitor(com.palantir.conjure.visitor.AuthTypeVisitor) FieldSpec(com.squareup.javapoet.FieldSpec) Type(com.palantir.conjure.spec.Type) Deque(java.util.Deque) Function(java.util.function.Function) ArrayList(java.util.ArrayList) Lists(com.google.common.collect.Lists) BearerToken(com.palantir.tokens.auth.BearerToken) ImmutableList(com.google.common.collect.ImmutableList) ConjureTags(com.palantir.conjure.java.ConjureTags) AsyncRequestProcessingMetadata(com.palantir.conjure.java.services.UndertowTypeFunctions.AsyncRequestProcessingMetadata) SetType(com.palantir.conjure.spec.SetType) ParameterOrder(com.palantir.conjure.java.util.ParameterOrder) StatusCodes(io.undertow.util.StatusCodes) CodeBlock(com.squareup.javapoet.CodeBlock) Serializer(com.palantir.conjure.java.undertow.lib.Serializer) TypeDefinition(com.palantir.conjure.spec.TypeDefinition) MethodSpec(com.squareup.javapoet.MethodSpec) Packages(com.palantir.conjure.java.util.Packages) CookieAuthType(com.palantir.conjure.spec.CookieAuthType) JavaNameSanitizer(com.palantir.conjure.java.util.JavaNameSanitizer) ParameterizedTypeName(com.squareup.javapoet.ParameterizedTypeName) IOException(java.io.IOException) TypeSpec(com.squareup.javapoet.TypeSpec) EndpointName(com.palantir.conjure.spec.EndpointName) HttpHandler(io.undertow.server.HttpHandler) AnnotationSpec(com.squareup.javapoet.AnnotationSpec) ConjureAnnotations(com.palantir.conjure.java.ConjureAnnotations) Deserializer(com.palantir.conjure.java.undertow.lib.Deserializer) ArgumentDefinition(com.palantir.conjure.spec.ArgumentDefinition) InputStream(java.io.InputStream) ImmutableSet(com.google.common.collect.ImmutableSet) CodeBlock(com.squareup.javapoet.CodeBlock)

Aggregations

Collections2 (com.google.common.collect.Collections2)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Iterables (com.google.common.collect.Iterables)1 Lists (com.google.common.collect.Lists)1 MoreCollectors (com.google.common.collect.MoreCollectors)1 Streams (com.google.common.collect.Streams)1 ConjureAnnotations (com.palantir.conjure.java.ConjureAnnotations)1 ConjureTags (com.palantir.conjure.java.ConjureTags)1 Options (com.palantir.conjure.java.Options)1 AsyncRequestProcessingMetadata (com.palantir.conjure.java.services.UndertowTypeFunctions.AsyncRequestProcessingMetadata)1 CodeBlocks (com.palantir.conjure.java.types.CodeBlocks)1 TypeMapper (com.palantir.conjure.java.types.TypeMapper)1 Deserializer (com.palantir.conjure.java.undertow.lib.Deserializer)1 Endpoint (com.palantir.conjure.java.undertow.lib.Endpoint)1 ReturnValueWriter (com.palantir.conjure.java.undertow.lib.ReturnValueWriter)1 Serializer (com.palantir.conjure.java.undertow.lib.Serializer)1 TypeMarker (com.palantir.conjure.java.undertow.lib.TypeMarker)1 UndertowRuntime (com.palantir.conjure.java.undertow.lib.UndertowRuntime)1 UndertowService (com.palantir.conjure.java.undertow.lib.UndertowService)1