All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.nosqlbench.nb.api.markdown.aggregator.CompositeMarkdownInfo Maven / Gradle / Ivy

Go to download

The top level API module for NoSQLBench. This module should have no internal module dependencies other than the mvn-default module. All modules within NoSQLBench can safely depend on this module with circular dependencies. This module provides cross-cutting code infrastracture, such as path utilities and ways of describing services used between modules. It is also the transitive aggregation point for system-wide library dependencies for logging and testing or similar needs.

There is a newer version: 5.17.0
Show newest version
package io.nosqlbench.nb.api.markdown.aggregator;

import io.nosqlbench.nb.api.markdown.types.FrontMatterInfo;
import io.nosqlbench.nb.api.markdown.types.MarkdownInfo;

import java.nio.file.Path;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

public class CompositeMarkdownInfo implements MarkdownInfo {
    private List elements = new LinkedList<>();
    private boolean isSorted=false;

    @Override
    public Path getPath() {
        return elements.get(0).getPath();
    }

    @Override
    public String getBody() {
        StringBuilder sb = new StringBuilder();
        if (!isSorted) {
            Collections.sort(elements);
            isSorted=true;
        }
        for (MarkdownInfo element : elements) {
            sb.append(element.getBody());
        }
        return sb.toString();
    }

    @Override
    public FrontMatterInfo getFrontmatter() {
        return elements.get(0).getFrontmatter();
    }

    @Override
    public boolean hasAggregations() {
        return false;
    }

    @Override
    public CompositeMarkdownInfo withTopics(List assigning) {
        MarkdownInfo leader = elements.get(0);
        leader = leader.withTopics(assigning);
        elements.set(0,leader);
        return this;
    }

    public CompositeMarkdownInfo withIncluded(List included) {
        MarkdownInfo leader = elements.get(0);
        leader = leader.withIncluded(included);
        elements.set(0,leader);
        return this;
    }

    public  CompositeMarkdownInfo add(T element) {
        elements.add(element);
        isSorted=false;
        return this;
    }

    @Override
    public String toString() {
        return "CompositeMarkdownInfo{" +
                "elements=" + elements +
                ", isSorted=" + isSorted +
                '}';
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy