- void forAllModules(TObjectProcedure<String> procedure);
- String getDocumentation(String documentationName);
- void forAllDocumentations(TObjectProcedure<String> procedure);
- void checkUpdates();
- void clear();
+
+ /**
+ * Returns all documentation names governed by this repository. Some implementations
+ * may return empty collection, even if the contain documentation.
+ */
+ default Collection<String> getDocumentationNames() {
+ return Collections.emptyList();
+ }
+
+ /**
+ * Calls the given procedure with all documentation names eturned by {@link #getDocumentationNames}
+ */
+ default void forAllDocumentations(TObjectProcedure<String> procedure) {
+ for(String module : getDocumentationNames())
+ if(!procedure.execute(module))
+ return;
+ }
+
+ /**
+ * Returns original markdown text for the given documentation name or null
+ * if the documentation does not exist.
+ */
+ default String getDocumentation(String documentationName) {
+ return null;
+ }
+
+ /**
+ * Triggers repository to check if module contents have been changed. Some repositories listen
+ * changes and report them to update listeners even without manual triggering.
+ */
+ default void checkUpdates() {
+ }
+
+ /**
+ * Resets the repository and removes listeners. This is only used during regression testing and shouldn't be called during normal operation.
+ */
+ default void clear() {
+ }
+
+ default String getPossibleSourceText(String moduleName) throws IOException {
+ ModuleSource moduleSource = getModuleSource(moduleName, null);
+ if(moduleSource == null)
+ return null;
+ if(!(moduleSource instanceof TextualModuleSource))
+ return null;
+ return ((TextualModuleSource)moduleSource).getSourceText(null);
+ }