Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * 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
 * http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
 package javax.validation;
 
 import java.util.Set;
Validates bean instances. Implementations of this interface must be thread-safe.

Author(s):
Emmanuel Bernard
Hardy Ferentschik
Gunnar Morling
 
 public interface Validator {
Validates all constraints on object.

Parameters:
object object to validate
groups The group or list of groups targeted for validation (defaults to javax.validation.groups.Default).
Returns:
constraint violations or an empty set if none
Throws:
java.lang.IllegalArgumentException if object is null or if null is passed to the varargs groups
ValidationException if a non recoverable error happens during the validation process
 
 	<T> Set<ConstraintViolation<T>> validate(T objectClass<?>... groups);

Validates all constraints placed on the property of object named propertyName.

Parameters:
object object to validate
propertyName property to validate (i.e. field and getter constraints)
groups The group or list of groups targeted for validation (defaults to javax.validation.groups.Default).
Returns:
constraint violations or an empty set if none
Throws:
java.lang.IllegalArgumentException if object is null, if propertyName is null, empty or not a valid object property or if null is passed to the varargs groups
ValidationException if a non recoverable error happens during the validation process
 
 													 String propertyName,
 													 Class<?>... groups);

Validates all constraints placed on the property named propertyName of the class beanType would the property value be value.

ConstraintViolation objects return null for ConstraintViolation.getRootBean() and ConstraintViolation.getLeafBean()

Parameters:
beanType the bean type
propertyName property to validate
value property value to validate
groups The group or list of groups targeted for validation (defaults to javax.validation.groups.Default).
Returns:
constraint violations or an empty set if none
Throws:
java.lang.IllegalArgumentException if beanType is null, if propertyName is null, empty or not a valid object property or if null is passed to the varargs groups
ValidationException if a non recoverable error happens during the validation process
 
 	<T> Set<ConstraintViolation<T>> validateValue(Class<T> beanType,
 												  String propertyName,
 												  Object value,
 												  Class<?>... groups);

Return the descriptor object describing bean constraints. The returned object (and associated objects including ConstraintDescriptors) are immutable.

Parameters:
clazz class or interface type evaluated
Returns:
the bean descriptor for the specified class.
Throws:
java.lang.IllegalArgumentException if clazz is null
ValidationException if a non recoverable error happens during the metadata discovery or if some constraints are invalid.
Return an instance of the specified type allowing access to provider-specific APIs. If the Bean Validation provider implementation does not support the specified class, ValidationException is thrown.

Parameters:
type the class of the object to be returned.
Returns:
an instance of the specified class
Throws:
ValidationException if the provider does not support the call.
	<T> T unwrap(Class<T> type);

Returns a delegate for validating parameters and return values of methods respectively constructors.

Returns:
A delegate for method and constructor validation.
Since:
1.1
New to GrepCode? Check out our FAQ X