de.smartics.properties.spi.core.constraints
Class ListValueConstraint

Package class diagram package ListValueConstraint
java.lang.Object
  extended by de.smartics.properties.spi.core.constraint.AbstractPropertyConstraint<List<?>>
      extended by de.smartics.properties.spi.core.constraints.ListValueConstraint
All Implemented Interfaces:
PropertyConstraint< List<?>>, Serializable

@ThreadSafe
public final class ListValueConstraint
     
     
extends AbstractPropertyConstraint< List<?>>

A constraint that requires a value to be a list.

See Also:
Serialized Form

Constructor Summary
ListValueConstraint()
          Convenience constructor for elements of type String without any constraints.
ListValueConstraint(Class<?> elementType)
          Convenience constructor if there are no constraints, neither on the number of list elements nor any other.
ListValueConstraint(Class<?> elementType, Integer minOccurs, Integer maxOccurs)
          Convenience constructor if there are no constraints.
ListValueConstraint(Class<?> elementType, Integer minOccurs, Integer maxOccurs, List<? extends PropertyConstraint<?>> elementConstraints)
          Default constructor.
ListValueConstraint(Class<?> elementType, Integer minOccurs, Integer maxOccurs, PropertyConstraint<?> elementConstraints)
          Convenience constructor using varargs for constraints.
ListValueConstraint(Class<?> elementType, List<? extends PropertyConstraint<?>> elementConstraints)
          Convenience constructor if there are no constraints on the number of list elements.
 
Method Summary
 String getDescription(Locale locale)
          Returns a localized description of the defined constraints.
 List<? extends PropertyConstraint<?>> getElementConstraints()
          Returns the constraints on the individual elements of the list.
 Class<?> getElementType()
          Returns the type of the list elements.
 Integer getMaxOccurs()
          Returns the maximum number of elements in the list.
 Integer getMinOccurs()
          Returns the minimum number of elements in the list.
 boolean isValid(List<?> value, Class<?> group)
          Checks if the given value is valid only if the constraint is in the given group.
 
Methods inherited from class de.smartics.properties.spi.core.constraint.AbstractPropertyConstraint
getDescription, getViolationMessage, isMandatoryConstraint, isValid, toString, validate, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ListValueConstraint

public ListValueConstraint()
Convenience constructor for elements of type String without any constraints.


ListValueConstraint

public ListValueConstraint(Class<?> elementType)
Convenience constructor if there are no constraints, neither on the number of list elements nor any other.

Parameters:
elementType - the type of the list elements.

ListValueConstraint

public ListValueConstraint(Class<?> elementType,
                           List<? extends PropertyConstraint<?>> elementConstraints)
Convenience constructor if there are no constraints on the number of list elements.

Parameters:
elementType - the type of the list elements.
elementConstraints - the constraints on the individual elements of the

ListValueConstraint

public ListValueConstraint(Class<?> elementType,
                           Integer minOccurs,
                           Integer maxOccurs)
Convenience constructor if there are no constraints.

Parameters:
elementType - the type of the list elements.
minOccurs - the minimum number of elements in the list.
maxOccurs - the maximum number of elements in the list.

ListValueConstraint

public ListValueConstraint(Class<?> elementType,
                           Integer minOccurs,
                           Integer maxOccurs,
                           PropertyConstraint<?> elementConstraints)
Convenience constructor using varargs for constraints.

Parameters:
elementType - the type of the list elements.
minOccurs - the minimum number of elements in the list.
maxOccurs - the maximum number of elements in the list.
elementConstraints - the constraints on the individual elements of the list.

ListValueConstraint

public ListValueConstraint(Class<?> elementType,
                           Integer minOccurs,
                           Integer maxOccurs,
                           List<? extends PropertyConstraint<?>> elementConstraints)
Default constructor.

Parameters:
elementType - the type of the list elements.
minOccurs - the minimum number of elements in the list.
maxOccurs - the maximum number of elements in the list.
elementConstraints - the constraints on the individual elements of the list.
Method Detail

getElementType

public Class<?> getElementType()
Returns the type of the list elements.

Returns:
the type of the list elements.

getMinOccurs

public Integer getMinOccurs()
Returns the minimum number of elements in the list. May be null if there is no constraint on the minimum number of elements.

Returns:
the minimum number of elements in the list.

getMaxOccurs

public Integer getMaxOccurs()
Returns the maximum number of elements in the list. May be null if there is no constraint on the maximum number of elements.

Returns:
the maximum number of elements in the list.

getElementConstraints

public List<? extends PropertyConstraint<?>> getElementConstraints()
Returns the constraints on the individual elements of the list. May be empty, but is never null.

Returns:
the constraints on the individual elements of the list.

getDescription

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

Parameters:
locale - the locale to use to fetch a localized description.
Returns:
a localized description of the defined constraints.

isValid

public boolean isValid(List<?> value,
                       Class<?> group)
Description copied from interface: PropertyConstraint
Checks if the given value is valid only if the constraint is in the given group.

Parameters:
value - the value to be checked.
group - the validation only takes place if this constraint is in this group or the argument is null.
Returns:
true if the value is valid, false otherwise.


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