Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   * JBoss, Home of Professional Open Source
   * Copyright 2011, 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
  * 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.metadata.aggregated;
 import java.util.Set;
 import static org.hibernate.validator.internal.util.CollectionHelper.newHashSet;

Builds ConstraintMetaData instances for the org.hibernate.validator.internal.metadata.raw.ConstrainedElement objects representing one method or property in a type's inheritance hierarchy.

Gunnar Morling
 public abstract class MetaDataBuilder {
 	protected final ConstraintHelper constraintHelper;
 	protected MetaDataBuilder(ConstraintHelper constraintHelper) {
 		this. = constraintHelper;

Whether this builder allows to add the given element or not. This is the case if the specified element relates to the same property or method with which this builder was instantiated.

constrainedElement The element to check.
true if the given element can be added to this builder, false otherwise.
 	public abstract boolean accepts(ConstrainedElement constrainedElement);

Adds the given element to this builder. It must be checked with accepts(org.hibernate.validator.internal.metadata.raw.ConstrainedElement) before, whether this is allowed or not.

constrainedElement The element to add.
 	public abstract void add(ConstrainedElement constrainedElement);

Creates a new, read-only ConstraintMetaData object with all constraint information related to the method or property represented by this builder.

A ConstraintMetaData object.
 	public abstract ConstraintMetaData build();

Adapts the given constraints to the given bean type. In case a constraint is defined locally at the bean class the original constraint will be returned without any modifications. If a constraint is defined in the hierarchy (interface or super class) a new constraint will be returned with an origin of org.hibernate.validator.internal.metadata.core.ConstraintOrigin.DEFINED_IN_HIERARCHY. If a constraint is defined on an interface, the interface type will additionally be part of the constraint's groups (implicit grouping).

beanClass The bean type to which the constraint shall be adapted.
constraints The constraints that shall be adapted. The constraints themselves will not be altered.
A constraint adapted to the given bean type.
 	protected Set<MetaConstraint<?>> adaptOriginsAndImplicitGroups(Class<?> beanClass,
 																   Set<MetaConstraint<?>> constraints) {
 		Set<MetaConstraint<?>> adaptedConstraints = newHashSet();
 		for ( MetaConstraint<?> oneConstraint : constraints ) {
		return adaptedConstraints;
			Class<?> beanClassMetaConstraint<A> constraint) {
		ConstraintOrigin definedIn = definedInbeanClassconstraint.getLocation().getBeanClass() );
		if ( definedIn == . ) {
			return constraint;
		Class<?> constraintClass = constraint.getLocation().getBeanClass();
				constraintClass.isInterface() ? constraintClass : null,
		return new MetaConstraint<A>(

rootClass The root class. That is the class for which we currently create a BeanMetaData
hierarchyClass The class on which the current constraint is defined on
Returns ConstraintOrigin.DEFINED_LOCALLY if the constraint was defined on the root bean, ConstraintOrigin.DEFINED_IN_HIERARCHY otherwise.
	private ConstraintOrigin definedIn(Class<?> rootClassClass<?> hierarchyClass) {
		if ( hierarchyClass.equalsrootClass ) ) {
		else {
New to GrepCode? Check out our FAQ X