com.lotaris.jee.validation.preprocessing.PreprocessingChain Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jee-validation Show documentation
Show all versions of jee-validation Show documentation
This library offers components that facilitate validation of arbitrary objects and how they are serialized towards a client.
It focuses on the wiring of the proposed patterns and does not contain any concrete validator implementations.
package com.lotaris.jee.validation.preprocessing;
import java.util.ArrayList;
import java.util.List;
/**
* Chain of {@link IPreprocessor} processes to apply to an object. You can add a preprocessor to the
* chain with add. The chain runs all preprocessors in the order they were added. It stops
* if any of the preprocessors indicates failure.
*
* @author Simon Oulevay ([email protected])
* @see DefaultPreprocessingChain
*/
public class PreprocessingChain implements IPreprocessor {
private List processors;
public PreprocessingChain() {
processors = new ArrayList<>();
}
/**
* Adds a preprocessor to be run at the end of the chain.
*
* @param processor the preprocessor to add
* @return this updated chain
*/
public PreprocessingChain add(IPreprocessor processor) {
processors.add(processor);
return this;
}
@Override
public boolean process(Object object, IPreprocessingConfig config) {
for (IPreprocessor processor : processors) {
if (!processor.process(object, config)) {
return false;
}
}
return true;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy