/** * Return true if this method has any 'action' (e.g: install) as its base. * Methods which have a base method represent 'signatures' of the same method. */ public boolean isActionSignature(Method method) { return method.getBase()!=null && !method.getBase().getName().equals(ADD) && !method.getBase().getName().equals(UPDATE); }
Service service = path.get(size -1).getService(); service.methods() .filter(method -> method.getBase() == null) .forEach(method -> { Point point = new Point();
public boolean isContained(Method method, Method method2) { if (method.getName().equals(method2.getName())) { return false; //same method } if (method.getBase()==null || method2.getBase()==null) { return false; //no parent, containment irrelevant } if (!method.getBase().getName().equals(method2.getBase().getName())) { return false; //different parents, containment irrelevant. } return isParametersContained(method.getMandatoryParameters(), method2.getMandatoryParameters()) && isAttributesContained(method.getMandatoryAttributes(), method2.getMandatoryAttributes()); }
private void documentService(Service service) { // General description: docBuffer.addId(getId(service)); docBuffer.addLine("=== %s", getName(service)); docBuffer.addLine(); addDoc(service); // Table of methods: List<Method> methods = service.methods() .filter(method -> method.getBase() == null) .sorted() .collect(Collectors.toList()); if (!methods.isEmpty()) { docBuffer.addLine(".Methods summary"); docBuffer.addLine("[cols=\"20,80\"]"); docBuffer.addLine("|==="); docBuffer.addLine("|Name |Summary"); docBuffer.addLine(); methods.forEach(method -> { docBuffer.addLine("|`%s`", getName(method)); docBuffer.addLine("|%s", getSummary(method)); docBuffer.addLine(); }); docBuffer.addLine("|==="); docBuffer.addLine(); } // Methods detail: methods.forEach(method -> documentMethod(service, method)); }
private void generateUpdateSignature(Method method) { generateDoc(method); // Find the main parameter of the method, as this is the only one that appears in the JAX-RS interfaces, the // rest of the methods are extracted explicitly by the implementation: Parameter mainParameter = jaxrsGeneratorUtils.getMainUpdateParameter(method); if (mainParameter == null) { throw new IllegalStateException("Method \"" + method + "\" doesn't have any struct parameter"); } // Calculate the Java type of the main parameter: Type mainType = mainParameter.getType(); JavaTypeReference mainTypeReference = schemaNames.getXjcTypeReference(mainType); String methodName = javaNames.getJavaMemberStyleName(names.concatenate(method.getBase().getName(), method.getName())); javaBuffer.addLine( "default public %s " + methodName + "(%s %s) {", mainTypeReference.getText(), mainTypeReference.getText(), javaNames.getJavaMemberStyleName(mainParameter.getName())); javaBuffer.addLine("throw new UnsupportedOperationException();"); javaBuffer.addLine("}"); }
private void generateActionSignature(Method method) { generateDoc(method); javaBuffer.addImport(Response.class); javaBuffer.addImport(javaPackages.getXjcPackageName(), "Action"); Name methodName = new Name(method.getBase().getName()); methodName.addWords(method.getName().getWords()); javaBuffer.addLine("default public Response %s(Action action) {", jaxrsNames.getMethodName(methodName)); javaBuffer.addLine("throw new UnsupportedOperationException();"); javaBuffer.addLine("}"); }
private void generateAddSignature(Method method) { generateDoc(method); // Find the main parameter of the method, as this is the only one that appears in the JAX-RS interfaces, the // rest of the methods are extracted explicitly by the implementation: Parameter mainParameter = jaxrsGeneratorUtils.getMainAddParameter(method); if (mainParameter == null) { throw new IllegalStateException("Method \"" + method + "\" doesn't have any struct parameter"); } // Calculate the Java type of the main parameter: Type mainType = mainParameter.getType(); JavaTypeReference mainTypeReference = schemaNames.getXjcTypeReference(mainType); javaBuffer.addImports(mainTypeReference.getImports()); String parameterName = javaNames.getJavaMemberStyleName(mainParameter.getName()); String methodName = javaNames.getJavaMemberStyleName(names.concatenate(method.getBase().getName(), method.getName())); javaBuffer.addLine("default public Response %s(%s %s) {", methodName, mainTypeReference.getText(), parameterName); javaBuffer.addLine("throw new UnsupportedOperationException();"); javaBuffer.addLine("}"); javaBuffer.addLine(); }