/** * Returns a stream that delivers all the methods of this service, including the ones declared in base services. */ public Stream<Method> methods() { Stream<Method> result = declaredMethods(); if (base != null) { result = concat(base.methods(), result); } return result; }
/** * Checks if this service or any of its base services have a method with the given name. * * @param name the name of the method to check * @return {@code true} if the method exists, {@code false} otherwise */ public boolean hasMethod(Name name) { return methods().anyMatch(named(name)); }
private void writeService(Service service) { writer.writeStartElement("service"); writeCommon(service); service.methods().forEach(this::writeServiceMethod); service.locators().forEach(this::writeServiceLocator); 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; }
if (size > 0) { Service service = path.get(size -1).getService(); service.methods() .filter(method -> method.getBase() == null) .forEach(method -> {
private void generateRows(Concept concept) { csvBuffer.addRow( getKind(concept), getName(concept), String.valueOf(countItems(concept)), String.valueOf(countDocuments(concept)), getAnnotation(concept, AREA), getAnnotation(concept, AUTHOR), getAnnotation(concept, DATE), getAnnotation(concept, STATUS) ); if (concept instanceof StructType) { StructType type = (StructType) concept; type.attributes().sorted().forEach(this::generateRows); } else if (concept instanceof Service) { Service service = (Service) concept; service.methods().sorted().forEach(this::generateRows); } }
private void writeService(Service service) { writer.writeStartObject(); writeCommon(service); writer.writeStartArray("methods"); service.methods().forEach(this::writeServiceMethod); writer.writeEnd(); writer.writeStartArray("locators"); service.locators().forEach(this::writeServiceLocator); writer.writeEnd(); writer.writeEnd(); }
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)); }