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

com.codepoetics.fluvius.describers.BranchFlowDescription Maven / Gradle / Ivy

There is a newer version: 1.10
Show newest version
package com.codepoetics.fluvius.describers;

import com.codepoetics.fluvius.api.description.DescriptionWriter;
import com.codepoetics.fluvius.api.description.FlowDescription;

import java.util.List;
import java.util.Map;

final class BranchFlowDescription implements FlowDescription {
    private final List requiredKeyNames;
    private final String providedKeyName;
    private final FlowDescription defaultBranchDescription;
    private final Map branchDescriptions;

    BranchFlowDescription(List requiredKeyNames, String providedKeyName, FlowDescription defaultBranchDescription, Map branchDescriptions) {
        this.requiredKeyNames = requiredKeyNames;
        this.providedKeyName = providedKeyName;
        this.defaultBranchDescription = defaultBranchDescription;
        this.branchDescriptions = branchDescriptions;
    }

    @Override
    public void writeTo(DescriptionWriter descriptionWriter) {
        descriptionWriter.writeStartBranch(requiredKeyNames, providedKeyName);
        char branchIndex = 'a';
        for (Map.Entry branchEntry : branchDescriptions.entrySet()) {
            descriptionWriter.writeStartBranchOption(branchIndex++, branchEntry.getKey())
                    .writeDescription(branchEntry.getValue())
                    .writeEndBranchOption();
        }
        descriptionWriter.writeStartDefaultBranch(branchIndex)
                .writeDescription(defaultBranchDescription)
                .writeEndBranchOption()
                .writeEndBranch();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy