liquibase.ui.CompositeUIService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of liquibase-core Show documentation
Show all versions of liquibase-core Show documentation
Liquibase is a tool for managing and executing database changes.
The newest version!
package liquibase.ui;
import liquibase.AbstractExtensibleObject;
import liquibase.Beta;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* Used for handling multiple UI output services.
*/
@Beta
public class CompositeUIService extends AbstractExtensibleObject implements UIService {
public final List outputServices = new ArrayList<>();
public final UIService inputService; // Because we are only one liquibase, we can only prompt with a single service
public CompositeUIService(UIService inputService, Collection outputServices) {
this.inputService = inputService;
this.outputServices.addAll(outputServices);
}
public List getOutputServices() {
return outputServices;
}
@Override
public int getPriority() {
return PRIORITY_NOT_APPLICABLE;
}
@Override
public void sendMessage(String message) {
outputServices.forEach(service -> service.sendMessage(message));
}
@Override
public void sendErrorMessage(String message) {
outputServices.forEach(service -> service.sendErrorMessage(message));
}
@Override
public void sendErrorMessage(String message, Throwable exception) {
outputServices.forEach(service -> service.sendErrorMessage(message, exception));
}
@Override
public T prompt(String prompt, T valueIfNoEntry, InputHandler inputHandler, Class type) {
return inputService.prompt(prompt, valueIfNoEntry, inputHandler, type);
}
@Override
public void setAllowPrompt(boolean allowPrompt) throws IllegalArgumentException {
inputService.setAllowPrompt(allowPrompt);
}
@Override
public boolean getAllowPrompt() {
return inputService.getAllowPrompt();
}
}