colesico.framework.dslvalidator.builder.ValidationProgramBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of colesico-validation Show documentation
Show all versions of colesico-validation Show documentation
Colesico framework data bean validation assistant and simple dsl validator
package colesico.framework.dslvalidator.builder;
import colesico.framework.dslvalidator.Chain;
import colesico.framework.dslvalidator.Command;
import java.util.Deque;
public class ValidationProgramBuilder {
private Deque stack;
public Deque getStack() {
return stack;
}
public void setStack(Deque stack) {
this.stack = stack;
}
/**
* Starts new nested chain.
*
* @param chain
* @return
*/
public final void begin(final Chain chain) {
Chain parentChain = stack.peek();
stack.push(chain);
if (parentChain != null) {
parentChain.getCommands().add(chain);
}
}
/**
* Ends current chain and returns to the parent one.
*/
public final void end() {
stack.pop();
if (stack.isEmpty()) {
throw new RuntimeException("Validation tree is empty");
}
}
/**
* Adds comman to current chain
*
* @return
*/
public final void add(Command command) {
stack.peek().getCommands().add(command);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy