de.smartics.properties.spi.core.constraint
Class AbstractPropertyConstraint<T>

Package class diagram package AbstractPropertyConstraint
java.lang.Object
  extended by de.smartics.properties.spi.core.constraint.AbstractPropertyConstraint<T>
Type Parameters:
T - the type of the property value.
All Implemented Interfaces:
PropertyConstraint<T>, Serializable
Direct Known Subclasses:
GenericPropertyConstraint, ListValueConstraint, PropertyRangeConstraint

public abstract class AbstractPropertyConstraint<T>
     
     
extends Object
implements PropertyConstraint<T>

Base implementation of the PropertyConstraint interface.

See Also:
Serialized Form

Constructor Summary
protected AbstractPropertyConstraint()
          Default constructor.
 
Method Summary
 String getDescription()
          Returns a description of the defined constraints.
 String getViolationMessage(Locale locale, Object actualValue)
          Returns a localized description of the violation message adding the actual value.
 boolean isMandatoryConstraint()
          Determines if the constraint is a check that evaluates if a property is present or not and fails if a value is not present.
 boolean isValid(T value)
          Checks if the given value is valid for constraints in the default group.
 String toString()
          Returns the string representation of the object.
 void validate(PropertyDescriptor propertyDescriptor, T value)
          Checks if the given value is valid for constraints in the default group.
 void validate(PropertyDescriptor propertyDescriptor, T value, Class<?> group)
          Checks if the given value is valid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.smartics.properties.api.core.domain.PropertyConstraint
getDescription, isValid
 

Constructor Detail

AbstractPropertyConstraint

protected AbstractPropertyConstraint()
Default constructor.

Method Detail

isMandatoryConstraint

public boolean isMandatoryConstraint()
Description copied from interface: PropertyConstraint
Determines if the constraint is a check that evaluates if a property is present or not and fails if a value is not present.

Specified by:
isMandatoryConstraint in interface PropertyConstraint<T>
Returns:
true if the constraint is a check for value presence, false if it is any regular constraint.

getDescription

public final String getDescription()
Description copied from interface: PropertyConstraint
Returns a description of the defined constraints.

This is not the validation message that is displayed if the validation fails. This is a description of the constraints on a value that must be met to pass the validation process successfully. The description may be displayed to a user prior to request the input of a value.

Specified by:
getDescription in interface PropertyConstraint<T>
Returns:
a description of the defined constraints.

getViolationMessage

public String getViolationMessage(Locale locale,
                                  Object actualValue)
Description copied from interface: PropertyConstraint
Returns a localized description of the violation message adding the actual value.

Specified by:
getViolationMessage in interface PropertyConstraint<T>
Parameters:
locale - the locale to use for the message.
actualValue - the value that has violated the constraint.
Returns:
a localized description of violation message.

isValid

public boolean isValid(T value)
Description copied from interface: PropertyConstraint
Checks if the given value is valid for constraints in the default group.

Specified by:
isValid in interface PropertyConstraint<T>
Parameters:
value - the value to be checked.
Returns:
true if the value is valid, false otherwise.

validate

public final void validate(PropertyDescriptor propertyDescriptor,
                           T value)
                    throws PropertyValidationException
Description copied from interface: PropertyConstraint
Checks if the given value is valid for constraints in the default group.

Specified by:
validate in interface PropertyConstraint<T>
Parameters:
propertyDescriptor - information about the name of the property to validate.
value - the value to be checked.
Throws:
PropertyValidationException - if the value is not valid.

validate

public final void validate(PropertyDescriptor propertyDescriptor,
                           T value,
                           Class<?> group)
                    throws PropertyValidationException
Description copied from interface: PropertyConstraint
Checks if the given value is valid.

Specified by:
validate in interface PropertyConstraint<T>
Parameters:
propertyDescriptor - information about the name of the property to validate.
value - the value to be checked.
group - the validation only takes place if this constraint is in this group or the argument is null.
Throws:
PropertyValidationException - if the value is not valid.

toString

public String toString()
Returns the string representation of the object.

Overrides:
toString in class Object
Returns:
the string representation of the object.


Copyright © 2012-2013 Kronseder & Reiner GmbH - smartics. All Rights Reserved.