private void writeServiceMethod(Method method) { writer.writeStartElement("method"); writeCommon(method); method.parameters().forEach(this::writeParameter); writer.writeEndElement(); }
/** * Counts the total items that can be potentially documented in a concept. For example, in a struct type with two * attributes there are three items: the type itself and the two attributes. */ private int countItems(Concept concept) { int count = 1; if (concept instanceof StructType) { StructType type = (StructType) concept; count += type.attributes().mapToInt(this::countItems).sum(); count += type.links().mapToInt(this::countItems).sum(); } else if (concept instanceof EnumType) { EnumType type = (EnumType) concept; count += type.values().mapToInt(this::countItems).sum(); } else if (concept instanceof Service) { Service service = (Service) concept; count += service.methods().mapToInt(this::countItems).sum(); count += service.locators().mapToInt(this::countItems).sum(); } else if (concept instanceof Method) { Method method = (Method) concept; count += method.parameters().mapToInt(this::countItems).sum(); } return count; }
/** * Counts the number of items in a concept tha are documented. */ private int countDocuments(Concept concept) { int count = 0; if (concept.getDoc() != null) { count++; } if (concept instanceof StructType) { StructType type = (StructType) concept; count += type.attributes().mapToInt(this::countDocuments).sum(); count += type.links().mapToInt(this::countDocuments).sum(); } else if (concept instanceof EnumType) { EnumType type = (EnumType) concept; count += type.values().mapToInt(this::countDocuments).sum(); } else if (concept instanceof Service) { Service service = (Service) concept; count += service.methods().mapToInt(this::countDocuments).sum(); count += service.locators().mapToInt(this::countDocuments).sum(); } else if (concept instanceof Method) { Method method = (Method) concept; count += method.parameters().mapToInt(this::countDocuments).sum(); } return count; }
private void writeServiceMethod(Method method) { writer.writeStartObject(); writeCommon(method); writer.writeStartArray("parameters"); method.parameters().forEach(this::writeParameter); writer.writeEnd(); writer.writeEnd(); }
private void generateRemoveMethod(Method method) { // Generate the imports: javaBuffer.addImport(DELETE.class); javaBuffer.addImport(Response.class); // The remove methods that have structured parameters (currently only the method that removes a set of Gluster // bricks) need to receive an "Action" to carry those parameters. // TODO: Fix this renaming that method to "RemoveBricks" or something similar. boolean needsAction = method.parameters() .map(Parameter::getType) .anyMatch(x -> x instanceof StructType || x instanceof ListType); generateDoc(method); javaBuffer.addLine("@DELETE"); if (needsAction) { javaBuffer.addImport(javaPackages.getXjcPackageName(), "Action"); addResponseReturnMethod("remove(Action action)"); } else { addResponseReturnMethod("remove()"); } javaBuffer.addLine(); }