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

org.srplib.validation.AbstractValidator Maven / Gradle / Ivy

There is a newer version: 0.9.0
Show newest version
package org.srplib.validation;

/**
 * Base abstract class for validators implementations.
 *
 * 

This base class simplifies validators creation because subclasses are responsible only for checking validity condition * and providing validation error. This class populates validatable with validation error (if any)

* * TODO: does this class make sense? Subclasses have no chance to add value validation error. * * @author Anton Pechinsky */ public abstract class AbstractValidator implements Validator { @Override public void validate(Validatable validatable) { if (!isValid(validatable)) { validatable.addError(newError()); } } /** * Subclasses should implement this method and check validatable for errors. * * @param validatable Validatable an object to validate * @return true if specified validatable is valid, false otherwise */ protected abstract boolean isValid(Validatable validatable); /** * Subclasses should implement this method and * @return */ protected abstract ValidationError newError(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy