org.springmodules.validation.util.condition.collection
Class AtLeastCollectionCondition

java.lang.Object
  extended by org.springmodules.validation.util.condition.AbstractCondition
      extended by org.springmodules.validation.util.condition.NonNullAcceptingCondition
          extended by org.springmodules.validation.util.condition.collection.AbstractCollectionCondition
              extended by org.springmodules.validation.util.condition.collection.AbstractCollectionElementCondition
                  extended by org.springmodules.validation.util.condition.collection.AtLeastCollectionCondition
All Implemented Interfaces:
Condition

public class AtLeastCollectionCondition
extends AbstractCollectionElementCondition

An AbstractCollectionCondition implementation that checks whether at least X elements in a collection or array adhere to a specific condition.

Author:
Uri Boness

Constructor Summary
AtLeastCollectionCondition(Condition elementCondition, int count)
          Constructs a new AtLeastCollectionCondition with a given element condition.
 
Method Summary
protected  boolean checkArray(Object array)
          Checks whether at least X objects in the given array adhere to the associated condition.
protected  boolean checkCollection(Collection collection)
          Checks whether at least X elements in the given collection adhere to the associated condition.
 int getCount()
          Returns how many element must adhere to the associated condition in order for this condition to "pass".
 
Methods inherited from class org.springmodules.validation.util.condition.collection.AbstractCollectionElementCondition
getElementCondition
 
Methods inherited from class org.springmodules.validation.util.condition.collection.AbstractCollectionCondition
beforeObjectChecked, doCheck
 
Methods inherited from class org.springmodules.validation.util.condition.AbstractCondition
afterObjectChecked, and, check, or
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AtLeastCollectionCondition

public AtLeastCollectionCondition(Condition elementCondition,
                                  int count)
Constructs a new AtLeastCollectionCondition with a given element condition.

Parameters:
elementCondition - The condition to be checked on the collection elements.
Method Detail

checkArray

protected boolean checkArray(Object array)
Checks whether at least X objects in the given array adhere to the associated condition. X is determined by the getCount() method call.

Specified by:
checkArray in class AbstractCollectionCondition
Parameters:
array - The array to be checked.
Returns:
true if at least X objects in the given array adhere to the associated element condition, false otherwise.

checkCollection

protected boolean checkCollection(Collection collection)
Checks whether at least X elements in the given collection adhere to the associated condition. X is determined by the getCount() method call.

Specified by:
checkCollection in class AbstractCollectionCondition
Parameters:
collection - The collection to be checked.
Returns:
true if at least X elements in the given collection adhere to the associated element condition, false otherwise.

getCount

public int getCount()
Returns how many element must adhere to the associated condition in order for this condition to "pass".

Returns:
How many element must adhere to the associated condition in order for this condition to "pass".


Copyright © 2009. All Rights Reserved.