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

liquibase.command.CommandResults Maven / Gradle / Ivy

There is a newer version: 4.30.0
Show newest version
package liquibase.command;

import java.util.Collections;
import java.util.SortedMap;
import java.util.TreeMap;

/**
 * The results of {@link CommandScope#execute()}.
 */
public class CommandResults {

    private final SortedMap resultValues = new TreeMap<>();
    private final CommandScope commandScope;

    protected CommandResults(SortedMap resultValues, CommandScope commandScope) {
        this.resultValues.putAll(resultValues);
        this.commandScope = commandScope;
    }

    /**
     * The {@link CommandScope} that was executed to produce this result.
     */
    public CommandScope getCommandScope() {
        return commandScope;
    }

    /**
     * Return the value for the given {@link CommandResultDefinition}, or the default value if not set.
     */
    public  DataType getResult(CommandResultDefinition definition) {
        return (DataType) resultValues.get(definition.getName());
    }

    /**
     * Return the result value for the given key.
     */
    public Object getResult(String key) {
        return resultValues.get(key);
    }

    /**
     * Returns all the results for this command.
     */
    public SortedMap getResults() {
        return Collections.unmodifiableSortedMap(resultValues);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy