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());
}
}
Aggregations