io.bdeploy.common.cli.data.DataResultBase Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of api Show documentation
Show all versions of api Show documentation
Public API including dependencies, ready to be used for integrations and plugins.
package io.bdeploy.common.cli.data;
import java.io.PrintStream;
import java.util.LinkedHashMap;
import java.util.Map;
public abstract class DataResultBase implements DataResult {
private String message;
private ExitCode exitCode = ExitCode.OK;
private Throwable throwable;
private final Map fields = new LinkedHashMap<>(); // preserve order.
private final PrintStream output;
protected DataResultBase(PrintStream output) {
this.output = output;
}
protected PrintStream out() {
return output;
}
@Override
public String getMessage() {
return message;
}
@Override
public Map getFields() {
return fields;
}
protected Throwable getThrowable() {
return throwable;
}
@Override
public DataResult setMessage(String message) {
this.message = message;
return this;
}
@Override
public DataResult setException(Throwable t) {
this.throwable = t;
return this;
}
@Override
public DataResult addField(String name, Object value) {
fields.put(name, value.toString());
return this;
}
@Override
public DataResult setExitCode(ExitCode exitCode) {
this.exitCode = exitCode;
return this;
}
@Override
public ExitCode getExitCode() {
return this.exitCode;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy