/** * Returns a stream that delivers all the locators of this service, including the ones declared in base services. */ public Stream<Locator> locators() { Stream<Locator> result = declaredLocators(); if (base != null) { result = concat(base.locators(), result); } return result; }
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; }
Deque<List<Locator>> pending = root.locators() .map(Collections::singletonList) .collect(toCollection(ArrayDeque::new)); int size = current.size(); Service service = current.get(size - 1).getService(); service.locators().forEach(locator -> { List<Locator> next = new ArrayList<>(current); next.add(locator);
/** * 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 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(); }