org.srplib.validation
Class DefaultValidatable<T>

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

public class DefaultValidatable<T>
extends Object
implements Validatable<T>

An implementation of Validatable interface.

Author:
Anton Pechinsky

Constructor Summary
DefaultValidatable(T value)
           
DefaultValidatable(T value, Object context)
           
 
Method Summary
 void addError(ValidationError error)
          Adds error to this object.
 Object getContext()
          Returns a reference to component which is being validated.
 List<ValidationError> getErrors()
          Returns validation error associated with this object.
 T getValue()
          Returns value to be validated.
 boolean hasErrors()
          Tests if this object has errors or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultValidatable

public DefaultValidatable(T value,
                          Object context)

DefaultValidatable

public DefaultValidatable(T value)
Method Detail

getValue

public T getValue()
Description copied from interface: Validatable
Returns value to be validated.

Specified by:
getValue in interface Validatable<T>
Returns:
an object representing value.

hasErrors

public boolean hasErrors()
Description copied from interface: Validatable
Tests if this object has errors or not.

Specified by:
hasErrors in interface Validatable<T>
Returns:
true if object has errors, false otherwise

addError

public void addError(ValidationError error)
Description copied from interface: Validatable
Adds error to this object.

Specified by:
addError in interface Validatable<T>
Parameters:
error - ValidationError an error.

getErrors

public List<ValidationError> getErrors()
Description copied from interface: Validatable
Returns validation error associated with this object.

Specified by:
getErrors in interface Validatable<T>
Returns:
a List of validation errors. If there are errors then empty list is returned.

getContext

public Object getContext()
Description copied from interface: Validatable
Returns a reference to component which is being validated.

Specified by:
getContext in interface Validatable<T>
Returns:
Object validation context


Copyright © 2014. All Rights Reserved.