use of com.linkedin.restli.tools.clientgen.builderspec.RootBuilderMethodSpec in project rest.li by linkedin.
the class RequestBuilderSpecGenerator method generateActionMethod.
private RootBuilderMethodSpec generateActionMethod(RootBuilderSpec rootBuilderSpec, String keyClass, ActionSchema action, String resourceName, List<String> pathKeys, Map<String, String> pathKeyTypes) {
String actionName = action.getName();
String returnType = action.getReturns();
String actionBuilderClassName = CodeUtil.capitalize(resourceName) + "Do" + CodeUtil.capitalize(actionName) + getMethodBuilderSuffix();
ActionBuilderSpec actionBuilderClass = generateActionRequestBuilder(rootBuilderSpec.getResource(), getBuilderBase(ResourceMethod.ACTION), keyClass, returnType, actionBuilderClassName, rootBuilderSpec.getNamespace(), action);
if (action.hasParameters()) {
generateActionParamBindingMethods(action.getParameters(), actionBuilderClass);
}
generatePathKeyBindingMethods(pathKeys, actionBuilderClass, pathKeyTypes);
String actionMethodName = "action" + CodeUtil.capitalize(actionName);
RootBuilderMethodSpec actionMethod = new RootBuilderMethodSpec(actionMethodName, action.getDoc(), actionBuilderClass, rootBuilderSpec);
actionBuilderClass.setRootBuilderMethod(actionMethod);
return actionMethod;
}
use of com.linkedin.restli.tools.clientgen.builderspec.RootBuilderMethodSpec 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.restli.tools.clientgen.builderspec.RootBuilderMethodSpec in project rest.li by linkedin.
the class RequestBuilderSpecGenerator method generateBasicMethods.
@SuppressWarnings("deprecation")
private List<RootBuilderMethodSpec> generateBasicMethods(RootBuilderSpec rootBuilderSpec, String keyClass, String valueClass, Set<ResourceMethod> supportedMethods, RestMethodSchemaArray restMethods, String resourceName, List<String> pathKeys, Map<String, String> pathKeyTypes) {
final Map<ResourceMethod, RestMethodSchema> schemaMap = new HashMap<ResourceMethod, RestMethodSchema>();
if (restMethods != null) {
for (RestMethodSchema restMethod : restMethods) {
schemaMap.put(ResourceMethod.fromString(restMethod.getMethod()), restMethod);
}
}
List<RootBuilderMethodSpec> methodSpecList = new ArrayList<RootBuilderMethodSpec>();
for (Map.Entry<ResourceMethod, String> entry : _builderBaseMap.entrySet()) {
ResourceMethod method = entry.getKey();
if (supportedMethods.contains(method)) {
String methodName = RestLiToolsUtils.normalizeUnderscores(method.toString());
final RestMethodSchema schema = schemaMap.get(method);
RestMethodBuilderSpec requestBuilder = generateRestMethodRequestBuilder(rootBuilderSpec.getResource(), entry.getValue(), keyClass, valueClass, resourceName + RestLiToolsUtils.nameCapsCase(methodName) + getMethodBuilderSuffix(), rootBuilderSpec.getNamespace(), schema);
generatePathKeyBindingMethods(pathKeys, requestBuilder, pathKeyTypes);
if (schema != null && schema.hasParameters()) {
this.generateQueryParamBindingMethods(schema.getParameters(), requestBuilder);
}
RootBuilderMethodSpec methodSpec = new RootBuilderMethodSpec(RestLiToolsUtils.nameCamelCase(methodName), schema.getDoc(), requestBuilder, rootBuilderSpec);
requestBuilder.setRootBuilderMethod(methodSpec);
methodSpecList.add(methodSpec);
}
}
return methodSpecList;
}
Aggregations