org.srplib.validation
Class AbstractValidator<T>

java.lang.Object
  extended by org.srplib.validation.AbstractValidator<T>
All Implemented Interfaces:
Validator<T>

public abstract class AbstractValidator<T>
extends Object
implements Validator<T>

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

Constructor Summary
AbstractValidator()
           
 
Method Summary
protected abstract  boolean isValid(Validatable<T> validatable)
          Subclasses should implement this method and check validatable for errors.
protected abstract  ValidationError newError()
          Subclasses should implement this method and
 void validate(Validatable<T> validatable)
          Validates provided validatable object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractValidator

public AbstractValidator()
Method Detail

validate

public void validate(Validatable<T> validatable)
Description copied from interface: Validator
Validates provided validatable object. Implementation should validate value from validatable object and set validation error if value isn't valid.

Specified by:
validate in interface Validator<T>
Parameters:
validatable - Validadable object to validate.
See Also:
Validatable

isValid

protected abstract boolean isValid(Validatable<T> validatable)
Subclasses should implement this method and check validatable for errors.

Parameters:
validatable - Validatable an object to validate
Returns:
true if specified validatable is valid, false otherwise

newError

protected abstract ValidationError newError()
Subclasses should implement this method and

Returns:


Copyright © 2014. All Rights Reserved.