Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  * Copyright (C) 2012 FoxLabs
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License.
package org.foxlabs.validation.constraint;
This class provides ConstraintAggregation implementation that is disjunction of the encapsulated constraints. In other words this class represents logical OR operator.

public final class ConstraintDisjunction<V> extends ConstraintAggregation<V> {
Constructs a new ConstraintDisjunction with the specified value type and array of constraints.

type The type of value to be validated.
constraints Array of constraints to be used for validation of a value.
java.lang.IllegalArgumentException if the specified type is null or the specified array of constraints is null or empty or contains null elements.
    ConstraintDisjunction(Class<?> type, Constraint<? super V>[] constraints) {
Checks whether the specified value conforms at least one of the encapsulated constraints.

value Value to be validated.
context Validation context.
Possibly modified value if the specified value conforms to one of the encapsulated constraint and that constraint can modify value.
ConstraintViolationException if the specified value not conforms to all of the encapsulated constraints.
    public <T> V validate(V valueValidationContext<T> context) {
        for (Constraint<? super V> constraint : ) {
            try {
                return (V) constraint.validate(valuecontext);
            } catch (ConstraintViolationException e) {}
        throw new ConstraintViolationException(thiscontextvalue);
New to GrepCode? Check out our FAQ X