org.hibernate.validator.internal.constraintvalidators

## Class SizeValidatorForCollection

- java.lang.Object
- - org.hibernate.validator.internal.constraintvalidators.SizeValidatorForCollection

- All Implemented Interfaces:
    ConstraintValidator<Size,Collection<?>>

      public class SizeValidatorForCollection
      extends Object
      implements ConstraintValidator<Size,Collection<?>>

  Check that a collection's size is between min and max.
  Author:
    Hardy Ferentschik

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SizeValidatorForCollection()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `initialize(Size parameters)`
    `boolean` | `isValid(Collection<?> collection, ConstraintValidatorContext constraintValidatorContext)` Checks the number of entries in a collection.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SizeValidatorForCollection

          public SizeValidatorForCollection()

  - ### Method Detail

    - #### initialize

          public void initialize(Size parameters)

      Specified by:
        `initialize` in interface `ConstraintValidator<Size,Collection<?>>`

    - #### isValid

          public boolean isValid(Collection<?> collection,
                        ConstraintValidatorContext constraintValidatorContext)

      Checks the number of entries in a collection.
      Specified by:
        `isValid` in interface `ConstraintValidator<Size,Collection<?>>`
      Parameters:
        `collection` - the collection to validate
        `constraintValidatorContext` - context in which the constraint is evaluated
      Returns:
        `true` if the collection is `null` or the number of entries in `collection` is between the specified `min` and `max` values (inclusive), `false` otherwise.

Copyright © 2007-2014 Red Hat, Inc. All Rights Reserved