@Test public void buildResponseClassnameWithTwoURIParam() throws Exception { when(method.resource()).thenReturn(resource); when(resource.resourcePath()).thenReturn("/songs/{songId}/{songId}"); when(uriParameter.name()).thenReturn("songId"); when(resource.uriParameters()).thenReturn(Arrays.asList(uriParameter, uriParameter)); when(method.method()).thenReturn("get"); assertEquals("GetSongsBySongIdAndSongIdResponse", Names.responseClassName(resource, method)); }
public static String responseClassName(GResource resource, GMethod method) { List<GParameter> parameters = ResourceUtils.accumulateUriParameters(resource); if (parameters.size() == 0) { return Names.typeName(method.method(), resource.resourcePath().replaceAll(PATH_REPLACEMENT_TEMPLATE, ""), "Response"); } else { List<String> elements = new ArrayList<>(); elements.add(method.method()); elements.add(resource.resourcePath().replaceAll("\\{[^}]+\\}", "")); elements.add("By"); List<String> uriparam = Lists.transform(parameters, new Function<GParameter, String>() { @Nullable @Override public String apply(@Nullable GParameter input) { return input.name(); } }); for (int i = 0; i < uriparam.size(); i++) { elements.add(uriparam.get(i)); if (i < uriparam.size() - 1) { elements.add("and"); } } elements.add("Response"); return Names.typeName(elements.toArray(new String[elements.size()])); } }
Names { public static String responseClassName(GResource resource, GMethod method) { List<GParameter> parameters = ResourceUtils.accumulateUriParameters(resource); if (parameters.size() == 0) { return Names.typeName(method.method(), resource.resourcePath().replaceAll(PATH_REPLACEMENT_TEMPLATE, ""), "Response"); } else { List<String> elements = new ArrayList<>(); elements.add(method.method()); elements.add(resource.resourcePath().replaceAll("\\{[^}]+\\}", "")); elements.add("By"); List<String> uriparam = Lists.transform(parameters, new Function<GParameter, String>() { @Nullable @Override public String apply(@Nullable GParameter input) { return input.name(); } }); for (int i = 0; i < uriparam.size(); i++) { elements.add(uriparam.get(i)); if (i < uriparam.size() - 1) { elements.add("and"); } } elements.add("Response"); return Names.typeName(elements.toArray(new String[elements.size()])); } } }
Names { public static String responseClassName(GResource resource, GMethod method) { List<GParameter> parameters = ResourceUtils.accumulateUriParameters(resource); if (parameters.size() == 0) { return Names.typeName(method.method(), resource.resourcePath().replaceAll(PATH_REPLACEMENT_TEMPLATE, ""), "Response"); } else { List<String> elements = new ArrayList<>(); elements.add(method.method()); elements.add(resource.resourcePath().replaceAll("\\{[^}]+\\}", "")); elements.add("By"); List<String> uriparam = Lists.transform(parameters, new Function<GParameter, String>() { @Nullable @Override public String apply(@Nullable GParameter input) { return input.name(); } }); for (int i = 0; i < uriparam.size(); i++) { elements.add(uriparam.get(i)); if (i < uriparam.size() - 1) { elements.add("and"); } } elements.add("Response"); return Names.typeName(elements.toArray(new String[elements.size()])); } } private  Names(); }
Names { public static String responseClassName(GResource resource, GMethod method) { List<GParameter> parameters = ResourceUtils.accumulateUriParameters(resource); if (parameters.size() == 0) { return Names.typeName(method.method(), resource.resourcePath().replaceAll(PATH_REPLACEMENT_TEMPLATE, ""), "Response"); } else { List<String> elements = new ArrayList<>(); elements.add(method.method()); elements.add(resource.resourcePath().replaceAll("\\{[^}]+\\}", "")); elements.add("By"); List<String> uriparam = Lists.transform(parameters, new Function<GParameter, String>() { @Nullable @Override public String apply(@Nullable GParameter input) { return input.name(); } }); for (int i = 0; i < uriparam.size(); i++) { elements.add(uriparam.get(i)); if (i < uriparam.size() - 1) { elements.add("and"); } } elements.add("Response"); return Names.typeName(elements.toArray(new String[elements.size()])); } } private  Names(); static String typeName(String... name); static String methodName(String... name); static String variableName(String... name); static String resourceMethodName(GResource resource, GMethod method); static String responseClassName(GResource resource, GMethod method); static String javaTypeName(Resource resource, TypeDeclaration declaration); static String javaTypeName(Resource resource, Method method, TypeDeclaration declaration); static String ramlTypeName(Resource resource, Method method, TypeDeclaration declaration); static String ramlTypeName(Resource resource, TypeDeclaration declaration); static String javaTypeName(Resource resource, Method method, Response response,
                                    TypeDeclaration declaration); static String ramlTypeName(Resource resource, Method method, Response response,
                                    TypeDeclaration declaration); static String ramlTypeName(org.raml.v2.api.model.v08.resources.Resource resource,
                                    org.raml.v2.api.model.v08.methods.Method method, BodyLike typeDeclaration); static String ramlTypeName(org.raml.v2.api.model.v08.resources.Resource resource,
                                    org.raml.v2.api.model.v08.methods.Method method,
                                    org.raml.v2.api.model.v08.bodies.Response response, BodyLike typeDeclaration); static String javaTypeName(org.raml.v2.api.model.v08.resources.Resource resource,
                                    org.raml.v2.api.model.v08.methods.Method method, BodyLike typeDeclaration); static String javaTypeName(org.raml.v2.api.model.v08.resources.Resource resource,
                                    org.raml.v2.api.model.v08.methods.Method method,
                                    org.raml.v2.api.model.v08.bodies.Response response, BodyLike typeDeclaration); }
Names { public static String responseClassName(GResource resource, GMethod method) { List<GParameter> parameters = ResourceUtils.accumulateUriParameters(resource); if (parameters.size() == 0) { return Names.typeName(method.method(), resource.resourcePath().replaceAll(PATH_REPLACEMENT_TEMPLATE, ""), "Response"); } else { List<String> elements = new ArrayList<>(); elements.add(method.method()); elements.add(resource.resourcePath().replaceAll("\\{[^}]+\\}", "")); elements.add("By"); List<String> uriparam = Lists.transform(parameters, new Function<GParameter, String>() { @Nullable @Override public String apply(@Nullable GParameter input) { return input.name(); } }); for (int i = 0; i < uriparam.size(); i++) { elements.add(uriparam.get(i)); if (i < uriparam.size() - 1) { elements.add("and"); } } elements.add("Response"); return Names.typeName(elements.toArray(new String[elements.size()])); } } private  Names(); static String typeName(String... name); static String methodName(String... name); static String variableName(String... name); static String resourceMethodName(GResource resource, GMethod method); static String responseClassName(GResource resource, GMethod method); static String javaTypeName(Resource resource, TypeDeclaration declaration); static String javaTypeName(Resource resource, Method method, TypeDeclaration declaration); static String ramlTypeName(Resource resource, Method method, TypeDeclaration declaration); static String ramlTypeName(Resource resource, TypeDeclaration declaration); static String javaTypeName(Resource resource, Method method, Response response,
                                    TypeDeclaration declaration); static String ramlTypeName(Resource resource, Method method, Response response,
                                    TypeDeclaration declaration); static String ramlTypeName(org.raml.v2.api.model.v08.resources.Resource resource,
                                    org.raml.v2.api.model.v08.methods.Method method, BodyLike typeDeclaration); static String ramlTypeName(org.raml.v2.api.model.v08.resources.Resource resource,
                                    org.raml.v2.api.model.v08.methods.Method method,
                                    org.raml.v2.api.model.v08.bodies.Response response, BodyLike typeDeclaration); static String javaTypeName(org.raml.v2.api.model.v08.resources.Resource resource,
                                    org.raml.v2.api.model.v08.methods.Method method, BodyLike typeDeclaration); static String javaTypeName(org.raml.v2.api.model.v08.resources.Resource resource,
                                    org.raml.v2.api.model.v08.methods.Method method,
                                    org.raml.v2.api.model.v08.bodies.Response response, BodyLike typeDeclaration);  }