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 org.hibernate.validator.internal.engine;
 
 
An instance of this class is used to collect all the relevant information for validating a single class, property or method invocation.

Author(s):
Hardy Ferentschik
Gunnar Morling
 
 public class ValueContext<T, V> {
The current bean which gets validated. This is the bean hosting the constraints which get validated.
 
 	private final T currentBean;

The class of the current bean.
 
 	private final Class<T> currentBeanType;

The index of the currently validated parameter if this context is used for a method parameter validation, null in all other cases (standard bean validation, return value validation).
 
 	private Integer parameterIndex;

The name of the currently validated parameter if this context is used for a method parameter validation, null in all other cases (standard bean validation, return value validation).
 
 	private String parameterName;

The current property path we are validating.
 
 	private PathImpl propertyPath;

The current group we are validating.
 
 	private Class<?> currentGroup;

The value which gets currently evaluated.
 
 	private V currentValue;

The ElementType the constraint was defined on
 
 	private ElementType elementType;

The type of annotated element.
 
 
 	public static <T, V> ValueContext<T, V> getLocalExecutionContext(T valuePathImpl propertyPath) {
 		@SuppressWarnings("unchecked")
 		Class<T> rootBeanClass = (Class<T>) value.getClass();
 		return new ValueContext<T, V>( valuerootBeanClasspropertyPath );
 	}
 
 	public static <T, V> ValueContext<T, V> getLocalExecutionContext(T valuePathImpl propertyPathint parameterIndexString parameterName) {
 		@SuppressWarnings("unchecked")
 		Class<T> rootBeanClass = (Class<T>) value.getClass();
 		return new ValueContext<T, V>( valuerootBeanClasspropertyPathparameterIndexparameterName );
 	}
 
 	public static <T, V> ValueContext<T, V> getLocalExecutionContext(Class<T> typePathImpl propertyPath) {
 		return new ValueContext<T, V>( nulltypepropertyPath );
 	}
 
 	protected ValueContext(T currentBeanClass<T> currentBeanTypePathImpl propertyPath) {
 		this. = currentBean;
 		this. = currentBeanType;
 		this. = propertyPath;
	}
	private ValueContext(T currentBeanClass<T> currentBeanTypePathImpl propertyPathint parameterIndexString parameterName) {
		this. = currentBean;
		this. = currentBeanType;
		this. = propertyPath;
		this. = parameterIndex;
		this. = parameterName;
	}

Returns:
returns the current path.
	public final PathImpl getPropertyPath() {
		return ;
	}
	public final Class<?> getCurrentGroup() {
		return ;
	}
	public final T getCurrentBean() {
		return ;
	}
	public final Class<T> getCurrentBeanType() {
	}
	}
	public void setParameterIndex(int parameterIndex) {
		this. = parameterIndex;
	}
	}
	public void setParameterName(String parameterName) {
		this. = parameterName;
	}
	public final V getCurrentValidatedValue() {
		return ;
	}

Sets the property path to the match the currently validated value. To avoid side effects a copy of the provided path is stored.

Parameters:
propertyPath Sets the new property path.
	public final void setPropertyPath(PathImpl propertyPath) {
		this. = propertyPath;
	}

Adds a new node with the specified name to the current property path.

Parameters:
node the name of the new node. Cannot be null.
	public final void appendNode(String node) {
		Contracts.assertValueNotNullnode"node" );
	}
	public final void markCurrentPropertyAsIterable() {
	}
	public final void setKey(Object key) {
	}
	public final void setIndex(Integer index) {
	}
	public final void setCurrentGroup(Class<?> currentGroup) {
		this. = currentGroup;
	}
	public final void setCurrentValidatedValue(V currentValue) {
		this. = currentValue;
	}
	public final boolean validatingDefault() {
		return getCurrentGroup() != null && getCurrentGroup().getName().equalsDefault.class.getName() );
	}
	public final ElementType getElementType() {
		return ;
	}
	public final void setElementType(ElementType elementType) {
		this. = elementType;
	}
	public final Type getTypeOfAnnotatedElement() {
	}
	public final void setTypeOfAnnotatedElement(Type typeOfAnnotatedElement) {
		this. = typeOfAnnotatedElement;
	}
	public String toString() {
		return "ValueContext [currentBean=" + 
", currentBeanType=" +  + ", parameterIndex="
 + ", parameterName=" + 
", propertyPath=" +  + ", currentGroup="
 + ", currentValue=" + 
", elementType=" +  + ", typeOfAnnotatedElement="
	}
New to GrepCode? Check out our FAQ X