All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.validator.internal.engine.valuecontext.ValueContexts Maven / Gradle / Ivy

There is a newer version: 8.0.1.Final
Show newest version
/*
 * Hibernate Validator, declare and validate application constraints
 *
 * License: Apache License, Version 2.0
 * See the license.txt file in the root directory or .
 */
package org.hibernate.validator.internal.engine.valuecontext;

import org.hibernate.validator.internal.engine.path.PathImpl;
import org.hibernate.validator.internal.metadata.aggregated.BeanMetaData;
import org.hibernate.validator.internal.metadata.facets.Validatable;
import org.hibernate.validator.internal.util.ExecutableParameterNameProvider;

/**
 * @author Marko Bekhta
 */
public final class ValueContexts {

	private ValueContexts() {
	}

	/**
	 * Creates a value context for validating an executable. Can be applied to both parameter and
	 * return value validation. Does not require a bean metadata information.
	 */
	public static  ValueContext getLocalExecutionContextForExecutable(
			ExecutableParameterNameProvider parameterNameProvider,
			T value,
			Validatable validatable,
			PathImpl propertyPath) {
		return new ValueContext<>( parameterNameProvider, value, validatable, propertyPath );
	}

	@SuppressWarnings("unchecked")
	public static  BeanValueContext getLocalExecutionContextForBean(
			ExecutableParameterNameProvider parameterNameProvider,
			T value,
			BeanMetaData currentBeanMetaData,
			PathImpl propertyPath) {
		return new BeanValueContext<>( parameterNameProvider, value, (BeanMetaData) currentBeanMetaData, propertyPath );
	}

	@SuppressWarnings("unchecked")
	public static  BeanValueContext getLocalExecutionContextForValueValidation(
			ExecutableParameterNameProvider parameterNameProvider,
			BeanMetaData currentBeanMetaData,
			PathImpl propertyPath) {
		return new BeanValueContext<>( parameterNameProvider, null, (BeanMetaData) currentBeanMetaData, propertyPath );
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy