use of com.linkedin.pegasus.generator.spec.ClassTemplateSpec in project rest.li by linkedin.
the class RequestBuilderSpecGenerator method generateFinders.
private List<RootBuilderMethodSpec> generateFinders(RootBuilderSpec rootBuilderSpec, FinderSchemaArray finderSchemas, String keyClass, String valueClass, String resourceName, List<String> pathKeys, Map<String, String> pathKeyTypes) {
List<RootBuilderMethodSpec> finderSpecList = new ArrayList<RootBuilderMethodSpec>();
if (finderSchemas != null) {
String baseBuilderClass = getBuilderBase(ResourceMethod.FINDER);
for (FinderSchema finder : finderSchemas) {
String finderName = finder.getName();
String builderName = CodeUtil.capitalize(resourceName) + "FindBy" + CodeUtil.capitalize(finderName) + getMethodBuilderSuffix();
FinderBuilderSpec finderBuilderClass = generateFinderRequestBuilder(rootBuilderSpec.getResource(), baseBuilderClass, keyClass, valueClass, builderName, rootBuilderSpec.getNamespace(), finderName, finder);
generatePathKeyBindingMethods(pathKeys, finderBuilderClass, pathKeyTypes);
if (finder.getParameters() != null) {
generateQueryParamBindingMethods(finder.getParameters(), finderBuilderClass);
}
// process custom metadata
if (finder.getMetadata() != null) {
String metadataClass = finder.getMetadata().getType();
ClassTemplateSpec metadataClassSpec = classToTemplateSpec(metadataClass);
finderBuilderClass.setMetadataType(metadataClassSpec);
}
String finderMethod = "findBy" + CodeUtil.capitalize(finderName);
RootBuilderMethodSpec methodSpec = new RootBuilderMethodSpec(finderMethod, finder.getDoc(), finderBuilderClass, rootBuilderSpec);
finderBuilderClass.setRootBuilderMethod(methodSpec);
finderSpecList.add(methodSpec);
}
}
return finderSpecList;
}
use of com.linkedin.pegasus.generator.spec.ClassTemplateSpec in project rest.li by linkedin.
the class RequestBuilderSpecGenerator method generateRestMethodRequestBuilder.
private RestMethodBuilderSpec generateRestMethodRequestBuilder(ResourceSchema resource, String baseBuilderClass, String keyClass, String valueClass, String requestBuilderName, String clientPackage, RestMethodSchema schema) {
// this method applies to REST methods
RestMethodBuilderSpec restMethodBuilderClass = new RestMethodBuilderSpec(clientPackage, requestBuilderName, baseBuilderClass, resource, schema.getMethod());
restMethodBuilderClass.setAnnotations(schema.getAnnotations() == null ? null : schema.getAnnotations().data());
final ClassTemplateSpec keyClassSpec = classToTemplateSpec(keyClass);
restMethodBuilderClass.setKeyClass(keyClassSpec);
final ClassTemplateSpec valueClassSpec = classToTemplateSpec(valueClass);
restMethodBuilderClass.setValueClass(valueClassSpec);
registerBuilderSpec(restMethodBuilderClass);
return restMethodBuilderClass;
}
Aggregations