use of com.palantir.conjure.java.types.ClassNameVisitor in project conjure-java by palantir.
the class JerseyServiceGenerator method generate.
@Override
public Stream<JavaFile> generate(ConjureDefinition conjureDefinition) {
ClassName binaryReturnType = options.jerseyBinaryAsResponse() ? BINARY_RETURN_TYPE_RESPONSE : BINARY_RETURN_TYPE_OUTPUT;
TypeName optionalBinaryReturnType = options.jerseyBinaryAsResponse() ? BINARY_RETURN_TYPE_RESPONSE : OPTIONAL_BINARY_RETURN_TYPE;
Map<com.palantir.conjure.spec.TypeName, TypeDefinition> types = TypeFunctions.toTypesMap(conjureDefinition);
ClassNameVisitor defaultVisitor = new DefaultClassNameVisitor(types.keySet(), options);
TypeMapper returnTypeMapper = new TypeMapper(types, new SpecializeBinaryClassNameVisitor(defaultVisitor, types, binaryReturnType, optionalBinaryReturnType));
TypeMapper argumentTypeMapper = new TypeMapper(types, new SpecializeBinaryClassNameVisitor(defaultVisitor, types, BINARY_ARGUMENT_TYPE));
return conjureDefinition.getServices().stream().map(serviceDef -> generateService(serviceDef, returnTypeMapper, argumentTypeMapper));
}
use of com.palantir.conjure.java.types.ClassNameVisitor in project conjure-java by palantir.
the class Retrofit2ServiceGenerator method generate.
@Override
public Stream<JavaFile> generate(ConjureDefinition conjureDefinition) {
Map<com.palantir.conjure.spec.TypeName, TypeDefinition> types = TypeFunctions.toTypesMap(conjureDefinition);
ClassNameVisitor defaultVisitor = new DefaultClassNameVisitor(types.keySet(), options);
TypeMapper returnTypeMapper = new TypeMapper(types, new SpecializeBinaryClassNameVisitor(defaultVisitor, types, BINARY_RETURN_TYPE, OPTIONAL_BINARY_RETURN_TYPE));
TypeMapper argumentTypeMapper = new TypeMapper(types, new SpecializeBinaryClassNameVisitor(defaultVisitor, types, BINARY_ARGUMENT_TYPE));
return conjureDefinition.getServices().stream().map(serviceDef -> generateService(serviceDef, returnTypeMapper, argumentTypeMapper));
}
use of com.palantir.conjure.java.types.ClassNameVisitor in project conjure-java by palantir.
the class UndertowServiceGenerator method generate.
@Override
public Stream<JavaFile> generate(ConjureDefinition conjureDefinition) {
Map<TypeName, TypeDefinition> types = TypeFunctions.toTypesMap(conjureDefinition);
ClassNameVisitor defaultVisitor = new DefaultClassNameVisitor(types.keySet(), options);
TypeMapper typeMapper = new TypeMapper(types, new SpecializeBinaryClassNameVisitor(defaultVisitor, types, ClassName.get(InputStream.class)));
TypeMapper returnTypeMapper = new TypeMapper(types, new SpecializeBinaryClassNameVisitor(defaultVisitor, types, ClassName.get(BinaryResponseBody.class)));
UndertowServiceInterfaceGenerator interfaceGenerator = new UndertowServiceInterfaceGenerator(options);
UndertowServiceHandlerGenerator handlerGenerator = new UndertowServiceHandlerGenerator(options);
return conjureDefinition.getServices().stream().flatMap(serviceDef -> Stream.of(interfaceGenerator.generateServiceInterface(serviceDef, typeMapper, returnTypeMapper), handlerGenerator.generateServiceHandler(serviceDef, types, typeMapper, returnTypeMapper)));
}
Aggregations