@@ -16,13 +16,13 @@
*/
package org.hibernate.validator.metadata;

import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import org.hibernate.validator.metadata.location.ConstraintLocation;
import org.hibernate.validator.metadata.location.MethodConstraintLocation;
import org.hibernate.validator.util.ReflectionHelper;

@@ -92,11 +92,16 @@ public ConstrainedMethod(
);
}

this.location = new MethodConstraintLocation(method);
this.location = new MethodConstraintLocation( method );
this.parameterMetaData = Collections.unmodifiableList( parameterMetaData );
this.returnValueConstraints = Collections.unmodifiableSet( returnValueConstraints );
this.isCascading = isCascading;
this.hasParameterConstraints = hasParameterConstraints( parameterMetaData );

Member member = location.getMember();
if ( isConstrained() ) {
ReflectionHelper.setAccessibility( member );
}
}

private boolean hasParameterConstraints(List<ConstrainedParameter> parameterMetaData) {
@@ -113,7 +118,7 @@ private boolean hasParameterConstraints(List<ConstrainedParameter> parameterMeta
public ConstrainedElementKind getConstrainedElementKind() {
return ConstrainedElementKind.METHOD;
}

public MethodConstraintLocation getLocation() {
return location;
}
@@ -224,12 +229,17 @@ public ConstrainedMethod merge(ConstrainedMethod otherMetaData) {
)
);
}
return new ConstrainedMethod( location.getMethod(), mergedParameterMetaData, mergedReturnValueConstraints, isCascading );
return new ConstrainedMethod(
location.getMethod(),
mergedParameterMetaData,
mergedReturnValueConstraints,
isCascading
);
}

@Override
public String toString() {
return "MethodMetaData [location=" + location + ", parameterMetaData="
return "ConstrainedMethod [location=" + location + ", parameterMetaData="
+ parameterMetaData + ", returnValueConstraints="
+ returnValueConstraints + ", isCascading=" + isCascading
+ ", hasParameterConstraints=" + hasParameterConstraints + "]";
@@ -239,49 +249,63 @@ public String toString() {
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (hasParameterConstraints ? 1231 : 1237);
result = prime * result + (isCascading ? 1231 : 1237);
result = prime * result + ( hasParameterConstraints ? 1231 : 1237 );
result = prime * result + ( isCascading ? 1231 : 1237 );
result = prime * result
+ ((location == null) ? 0 : location.hashCode());
+ ( ( location == null ) ? 0 : location.hashCode() );
result = prime
* result
+ ((parameterMetaData == null) ? 0 : parameterMetaData
.hashCode());
+ ( ( parameterMetaData == null ) ? 0 : parameterMetaData
.hashCode() );
result = prime
* result
+ ((returnValueConstraints == null) ? 0
: returnValueConstraints.hashCode());
+ ( ( returnValueConstraints == null ) ? 0
: returnValueConstraints.hashCode() );
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj)
if ( this == obj ) {
return true;
if (obj == null)
}
if ( obj == null ) {
return false;
if (getClass() != obj.getClass())
}
if ( getClass() != obj.getClass() ) {
return false;
}
ConstrainedMethod other = (ConstrainedMethod) obj;
if (hasParameterConstraints != other.hasParameterConstraints)
if ( hasParameterConstraints != other.hasParameterConstraints ) {
return false;
if (isCascading != other.isCascading)
}
if ( isCascading != other.isCascading ) {
return false;
if (location == null) {
if (other.location != null)
}
if ( location == null ) {
if ( other.location != null ) {
return false;
} else if (!location.equals(other.location))
}
}
else if ( !location.equals( other.location ) ) {
return false;
if (parameterMetaData == null) {
if (other.parameterMetaData != null)
}
if ( parameterMetaData == null ) {
if ( other.parameterMetaData != null ) {
return false;
} else if (!parameterMetaData.equals(other.parameterMetaData))
}
}
else if ( !parameterMetaData.equals( other.parameterMetaData ) ) {
return false;
if (returnValueConstraints == null) {
if (other.returnValueConstraints != null)
}
if ( returnValueConstraints == null ) {
if ( other.returnValueConstraints != null ) {
return false;
} else if (!returnValueConstraints.equals(other.returnValueConstraints))
}
}
else if ( !returnValueConstraints.equals( other.returnValueConstraints ) ) {
return false;
}
return true;
}

@@ -16,23 +16,22 @@
*/
package org.hibernate.validator.metadata;

import static org.hibernate.validator.util.CollectionHelper.newHashMap;
import static org.hibernate.validator.util.CollectionHelper.newHashSet;

import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.validation.ConstraintDeclarationException;
import javax.validation.Valid;

import org.hibernate.validator.metadata.ConstrainedElement.ConstrainedElementKind;
import org.hibernate.validator.metadata.location.MethodConstraintLocation;
import org.hibernate.validator.util.ReflectionHelper;

import static org.hibernate.validator.util.CollectionHelper.newHashMap;
import static org.hibernate.validator.util.CollectionHelper.newHashSet;

/**
* <p>
* An aggregated view of the constraint related meta data for a given method and
@@ -74,8 +73,8 @@ private MethodMetaData(
List<ConstrainedParameter> parameterMetaData,
ConstraintDeclarationException parameterConstraintDeclarationException) {

super(returnValueConstraints, ConstraintMetaDataKind.METHOD);
super( returnValueConstraints, ConstraintMetaDataKind.METHOD );

location = builder.location;
metaDataByDefiningType = Collections.unmodifiableMap( builder.metaDataByDefiningType );
isCascading = builder.isCascading;
@@ -101,6 +100,8 @@ public static class Builder extends BeanMetaDataManager.Builder {

private boolean isConstrained;

private final String propertyName;

/**
* Creates a new builder based on the given method meta data.
*
@@ -113,6 +114,16 @@ public Builder(ConstrainedMethod metaData) {
metaDataByDefiningType.put( location.getMethod().getDeclaringClass(), metaData );
isCascading = metaData.isCascading();
isConstrained = metaData.isConstrained();
if ( metaData.isGetterMethod() ) {
propertyName = ReflectionHelper.getPropertyName( metaData.getLocation().getMember() );
}
else {
propertyName = null;
}
}

public Builder(String propertyName) {
this.propertyName = propertyName;
}

/**
@@ -127,9 +138,19 @@ public Builder(ConstrainedMethod metaData) {
* builder, <code>false</code> otherwise.
*/
public boolean accepts(ConstrainedElement metaData) {
return
metaData.getConstrainedElementKind() == ConstrainedElementKind.METHOD &&
ReflectionHelper.haveSameSignature( location.getMethod(), ((ConstrainedMethod)metaData).getLocation().getMethod() );

if ( metaData.getConstrainedElementKind() != ConstrainedElementKind.METHOD ) {
return false;
}

if ( propertyName != null ) {
return propertyName.equals( ReflectionHelper.getPropertyName( metaData.getLocation().getMember() ) );
}

return ReflectionHelper.haveSameSignature(
location.getMethod(),
( (ConstrainedMethod) metaData ).getLocation().getMethod()
);
}

/**
@@ -141,8 +162,8 @@ public boolean accepts(ConstrainedElement metaData) {
*/
public void add(ConstrainedElement constrainedElement) {

ConstrainedMethod metaData = (ConstrainedMethod)constrainedElement;
ConstrainedMethod metaData = (ConstrainedMethod) constrainedElement;

ConstrainedMethod existingMetaData =
metaDataByDefiningType.get( metaData.getLocation().getMethod().getDeclaringClass() );

@@ -151,7 +172,10 @@ public void add(ConstrainedElement constrainedElement) {
}

//use the lowest method found in the hierarchy for this aggregation
if ( location.getMethod().getDeclaringClass().isAssignableFrom( metaData.getLocation().getMethod().getDeclaringClass() ) ) {
if ( location == null ||
location.getMethod()
.getDeclaringClass()
.isAssignableFrom( metaData.getLocation().getMethod().getDeclaringClass() ) ) {
location = metaData.getLocation();
}

@@ -167,9 +191,15 @@ public void add(ConstrainedElement constrainedElement) {
* @return An {@code AggregatedMethodMetaData} object
*/
public MethodMetaData build() {
return new MethodMetaData(
this, collectReturnValueConstraints(), findParameterMetaData(), checkParameterConstraints()
);
return
location != null ?
new MethodMetaData(
this,
collectReturnValueConstraints(),
findParameterMetaData(),
checkParameterConstraints()
)
: null;
}

/**
@@ -274,7 +304,7 @@ private Set<ConstrainedMethod> getMethodsWithParameterConstraints(Iterable<Const
}

}

/**
* <p>
* Checks the parameter constraints of this method for correctness.
@@ -373,19 +403,20 @@ public Iterable<ConstrainedMethod> getAllMethodMetaData() {
public MethodConstraintLocation getLocation() {
return location;
}

@Override
public String toString() {
return "AggregatedMethodMetaData [location=" + location
return "MethodMetaData [location=" + location
+ ", isCascading=" + isCascading() + ", isConstrained="
+ isConstrained() + "]";
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ( ( location == null ) ? 0 : location.hashCode() );
int result = super.hashCode();
result = prime * result
+ ( ( location == null ) ? 0 : location.hashCode() );
return result;
}

@@ -394,7 +425,7 @@ public boolean equals(Object obj) {
if ( this == obj ) {
return true;
}
if ( obj == null ) {
if ( !super.equals( obj ) ) {
return false;
}
if ( getClass() != obj.getClass() ) {
@@ -16,22 +16,21 @@
*/
package org.hibernate.validator.metadata;

import static org.hibernate.validator.util.CollectionHelper.asSet;
import static org.hibernate.validator.util.CollectionHelper.newHashSet;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

import javax.validation.metadata.PropertyDescriptor;

import org.hibernate.validator.metadata.ConstrainedElement.ConstrainedElementKind;
import org.hibernate.validator.util.ReflectionHelper;

import static org.hibernate.validator.util.CollectionHelper.asSet;
import static org.hibernate.validator.util.CollectionHelper.newHashSet;

/**
* @author Gunnar Morling
*/
@@ -46,7 +45,7 @@ public class PropertyMetaData extends AbstractConstraintMetaData {
private final boolean isConstrained;

private PropertyMetaData(Class<?> type, String propertyName, Set<MetaConstraint<?>> constraints, Set<Member> cascadingMembers) {
super(constraints, ConstraintMetaDataKind.PROPERTY);
super( constraints, ConstraintMetaDataKind.PROPERTY );
this.type = type;
this.propertyName = propertyName;
this.cascadingMembers = cascadingMembers;
@@ -90,48 +89,73 @@ public int hashCode() {
int result = super.hashCode();
result = prime
* result
+ ((cascadingMembers == null) ? 0 : cascadingMembers.hashCode());
result = prime * result + (isConstrained ? 1231 : 1237);
+ ( ( cascadingMembers == null ) ? 0 : cascadingMembers.hashCode() );
result = prime * result + ( isConstrained ? 1231 : 1237 );
result = prime * result
+ ((propertyName == null) ? 0 : propertyName.hashCode());
result = prime * result + ((type == null) ? 0 : type.hashCode());
+ ( ( propertyName == null ) ? 0 : propertyName.hashCode() );
result = prime * result + ( ( type == null ) ? 0 : type.hashCode() );
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj)
if ( this == obj ) {
return true;
if (!super.equals(obj))
}
if ( !super.equals( obj ) ) {
return false;
if (getClass() != obj.getClass())
}
if ( getClass() != obj.getClass() ) {
return false;
}
PropertyMetaData other = (PropertyMetaData) obj;
if (cascadingMembers == null) {
if (other.cascadingMembers != null)
if ( cascadingMembers == null ) {
if ( other.cascadingMembers != null ) {
return false;
} else if (!cascadingMembers.equals(other.cascadingMembers))
}
}
else if ( !cascadingMembers.equals( other.cascadingMembers ) ) {
return false;
if (isConstrained != other.isConstrained)
}
if ( isConstrained != other.isConstrained ) {
return false;
if (propertyName == null) {
if (other.propertyName != null)
}
if ( propertyName == null ) {
if ( other.propertyName != null ) {
return false;
} else if (!propertyName.equals(other.propertyName))
}
}
else if ( !propertyName.equals( other.propertyName ) ) {
return false;
if (type == null) {
if (other.type != null)
}
if ( type == null ) {
if ( other.type != null ) {
return false;
} else if (!type.equals(other.type))
}
}
else if ( !type.equals( other.type ) ) {
return false;
}
return true;
}

@Override
public String toString() {
return "AggregatedPropertyMetaData [type=" + type + ", propertyName="
+ propertyName + ", cascadingMembers=" + cascadingMembers
+ ", isConstrained=" + isConstrained + "]";

StringBuilder cascadingMembers = new StringBuilder();

for ( Member oneCascadingMember : this.cascadingMembers ) {
cascadingMembers.append( oneCascadingMember.getName() );
cascadingMembers.append( ", " );
}

if ( cascadingMembers.length() > 0 ) {
cascadingMembers.subSequence( 0, cascadingMembers.length() - 2 );
}

return "PropertyMetaData [type=" + type.getSimpleName() + ", propertyName="
+ propertyName + ", cascadingMembers=[" + cascadingMembers
+ "], isConstrained=" + isConstrained + "]";
}

public static class Builder extends BeanMetaDataManager.Builder {
@@ -144,55 +168,63 @@ public static class Builder extends BeanMetaDataManager.Builder {

private final Set<Member> cascadingMembers;

public Builder( ConstrainedField constrainedField, ConstraintHelper constraintHelper) {
public Builder(ConstrainedField constrainedField, ConstraintHelper constraintHelper) {
this.constraintHelper = constraintHelper;
this.root = constrainedField;
this.constraints = newHashSet(constrainedField);
this.cascadingMembers = constrainedField.isCascading() ? asSet(constrainedField.getLocation().getMember()) : new HashSet<Member>();
this.constraints = newHashSet( constrainedField );
this.cascadingMembers = constrainedField.isCascading() ? asSet(
constrainedField.getLocation()
.getMember()
) : new HashSet<Member>();
}

public Builder( ConstrainedType constrainedType, ConstraintHelper constraintHelper) {
public Builder(ConstrainedType constrainedType, ConstraintHelper constraintHelper) {
this.constraintHelper = constraintHelper;
this.root = constrainedType;
this.constraints = newHashSet(constrainedType);
this.constraints = newHashSet( constrainedType );
this.cascadingMembers = Collections.<Member>emptySet();
}

public Builder( ConstrainedMethod constrainedMethod, ConstraintHelper constraintHelper) {
public Builder(ConstrainedMethod constrainedMethod, ConstraintHelper constraintHelper) {
this.constraintHelper = constraintHelper;
this.root = constrainedMethod;
this.constraints = newHashSet(constrainedMethod);
this.cascadingMembers = constrainedMethod.isCascading() ? asSet((Member)constrainedMethod.getLocation().getMethod()) : new HashSet<Member>();
this.constraints = newHashSet( constrainedMethod );
this.cascadingMembers = constrainedMethod.isCascading() ? asSet(
(Member) constrainedMethod.getLocation()
.getMethod()
) : new HashSet<Member>();
}

public boolean accepts(ConstrainedElement constrainedElement) {

if( constrainedElement.getConstrainedElementKind() != ConstrainedElementKind.TYPE &&
constrainedElement.getConstrainedElementKind() != ConstrainedElementKind.FIELD &&
constrainedElement.getConstrainedElementKind() != ConstrainedElementKind.METHOD ) {
if ( constrainedElement.getConstrainedElementKind() != ConstrainedElementKind.TYPE &&
constrainedElement.getConstrainedElementKind() != ConstrainedElementKind.FIELD &&
constrainedElement.getConstrainedElementKind() != ConstrainedElementKind.METHOD ) {
return false;
}
if( constrainedElement.getConstrainedElementKind() == ConstrainedElementKind.METHOD &&
!((ConstrainedMethod)constrainedElement).isGetterMethod()) {

if ( constrainedElement.getConstrainedElementKind() == ConstrainedElementKind.METHOD &&
!( (ConstrainedMethod) constrainedElement ).isGetterMethod() ) {
return false;
}

String propertyName1 = ReflectionHelper.getPropertyName( constrainedElement.getLocation().getMember() );
String propertyName2 = ReflectionHelper.getPropertyName( root.getLocation().getMember() );

return
constrainedElement.getLocation().getBeanClass().isAssignableFrom( root.getLocation().getBeanClass() )
constrainedElement.getLocation()
.getBeanClass()
.isAssignableFrom( root.getLocation().getBeanClass() )
&& ( ( propertyName1 != null && propertyName1.equals( propertyName2 ) ) ||
propertyName1 == null && propertyName2 == null );
}

public void add(ConstrainedElement constrainedElement) {
for(MetaConstraint<?> oneConstraint : constrainedElement) {
constraints.add(oneConstraint);

for ( MetaConstraint<?> oneConstraint : constrainedElement ) {
constraints.add( oneConstraint );
}

if ( constrainedElement.isCascading() ) {
cascadingMembers.add( constrainedElement.getLocation().getMember() );
}
@@ -150,12 +150,7 @@ public int hashCode() {

@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append( "BeanConstraintLocation" );
sb.append( "{beanClass=" ).append( beanClass.getSimpleName() );
sb.append( ", propertyName='" ).append( propertyName ).append( '\'' );
sb.append( '}' );
return sb.toString();
return "BeanConstraintLocation [" + beanClass.getSimpleName() + "#" + propertyName + " (" + elementType + ")]";
}

}
@@ -81,11 +81,11 @@ public Type typeOfAnnotatedElement() {
public Method getMember() {
return method;
}

public Method getMethod() {
return method;
}

public ElementType getElementType() {
return parameterIndex != null ? ElementType.PARAMETER : ElementType.METHOD;
}
@@ -100,8 +100,53 @@ public Integer getParameterIndex() {

@Override
public String toString() {
return "MethodConstraintLocation [method=" + method
+ ", parameterIndex=" + parameterIndex + "]";
return String.format(
"%s#%s(%s)",
method.getDeclaringClass().getSimpleName(),
method.getName(),
parameterIndex != null ? parameterIndex : ""
);
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ( ( method == null ) ? 0 : method.hashCode() );
result = prime * result
+ ( ( parameterIndex == null ) ? 0 : parameterIndex.hashCode() );
return result;
}

@Override
public boolean equals(Object obj) {
if ( this == obj ) {
return true;
}
if ( obj == null ) {
return false;
}
if ( getClass() != obj.getClass() ) {
return false;
}
MethodConstraintLocation other = (MethodConstraintLocation) obj;
if ( method == null ) {
if ( other.method != null ) {
return false;
}
}
else if ( !method.equals( other.method ) ) {
return false;
}
if ( parameterIndex == null ) {
if ( other.parameterIndex != null ) {
return false;
}
}
else if ( !parameterIndex.equals( other.parameterIndex ) ) {
return false;
}
return true;
}

}
@@ -34,16 +34,16 @@
import org.hibernate.validator.group.DefaultGroupSequenceProvider;
import org.hibernate.validator.group.GroupSequenceProvider;
import org.hibernate.validator.metadata.AnnotationIgnores;
import org.hibernate.validator.metadata.BeanConfiguration.ConfigurationSource;
import org.hibernate.validator.metadata.ConstrainedElement;
import org.hibernate.validator.metadata.ConstrainedField;
import org.hibernate.validator.metadata.ConstrainedMethod;
import org.hibernate.validator.metadata.ConstrainedParameter;
import org.hibernate.validator.metadata.ConstrainedType;
import org.hibernate.validator.metadata.MetaConstraint;
import org.hibernate.validator.metadata.ConstraintDescriptorImpl;
import org.hibernate.validator.metadata.ConstraintHelper;
import org.hibernate.validator.metadata.ConstraintOrigin;
import org.hibernate.validator.metadata.MetaConstraint;
import org.hibernate.validator.metadata.ConstrainedMethod;
import org.hibernate.validator.metadata.ConstrainedParameter;
import org.hibernate.validator.metadata.ConstrainedField;
import org.hibernate.validator.metadata.location.BeanConstraintLocation;
import org.hibernate.validator.metadata.location.MethodConstraintLocation;
import org.hibernate.validator.util.ReflectionHelper;
@@ -60,7 +60,7 @@ public class AnnotationMetaDataProvider extends MetaDataProviderImplBase {

public AnnotationMetaDataProvider(ConstraintHelper constraintHelper, Class<?> beanClass, AnnotationIgnores annotationIgnores) {

super( constraintHelper );
super( ConfigurationSource.ANNOTATION, constraintHelper );

this.annotationIgnores = annotationIgnores;

@@ -78,10 +78,6 @@ public AnnotationIgnores getAnnotationIgnores() {
*/
private void retrieveBeanMetaData(Class<?> beanClass) {

// if(beanClass.equals(Object.class)) {
// return;
// }

Set<ConstrainedElement> propertyMetaData = getPropertyMetaData( beanClass );
propertyMetaData.addAll( getMethodMetaData( beanClass ) );

@@ -272,7 +268,10 @@ private List<ConstrainedParameter> getParameterMetaData(Method method) {

metaData.add(
new ConstrainedParameter(
new MethodConstraintLocation(method, i), parameterName, constraintsOfOneParameter, parameterIsCascading
new MethodConstraintLocation( method, i ),
parameterName,
constraintsOfOneParameter,
parameterIsCascading
)
);
i++;
@@ -16,9 +16,6 @@
*/
package org.hibernate.validator.metadata.provider;

import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -27,18 +24,13 @@
import org.hibernate.validator.cfg.context.impl.ConfiguredConstraint;
import org.hibernate.validator.group.DefaultGroupSequenceProvider;
import org.hibernate.validator.metadata.BeanConfiguration;
import org.hibernate.validator.metadata.BeanConfiguration.ConfigurationSource;
import org.hibernate.validator.metadata.ConstrainedElement;
import org.hibernate.validator.metadata.MetaConstraint;
import org.hibernate.validator.metadata.ConstraintHelper;
import org.hibernate.validator.metadata.MetaConstraint;
import org.hibernate.validator.metadata.ConstrainedMethod;
import org.hibernate.validator.metadata.ConstrainedField;
import org.hibernate.validator.metadata.location.BeanConstraintLocation;
import org.hibernate.validator.metadata.location.MethodConstraintLocation;
import org.hibernate.validator.util.CollectionHelper.Partitioner;

import static org.hibernate.validator.util.CollectionHelper.newHashMap;
import static org.hibernate.validator.util.CollectionHelper.newHashSet;

/**
* @author Gunnar Morling
@@ -49,16 +41,19 @@ public abstract class MetaDataProviderImplBase implements MetaDataProvider {
* Used as prefix for parameter names, if no explicit names are given.
*/
protected static final String DEFAULT_PARAMETER_NAME_PREFIX = "arg";

protected final Map<Class<?>, BeanConfiguration<?>> configuredBeans;

protected final ConstraintHelper constraintHelper;

public MetaDataProviderImplBase(ConstraintHelper constraintHelper) {
private final ConfigurationSource configurationSource;

configuredBeans = newHashMap();
public MetaDataProviderImplBase(ConfigurationSource configurationSource, ConstraintHelper constraintHelper) {

this.configurationSource = configurationSource;
this.constraintHelper = constraintHelper;

configuredBeans = newHashMap();
}

public Set<BeanConfiguration<?>> getAllBeanConfigurations() {
@@ -68,6 +63,7 @@ public Set<BeanConfiguration<?>> getAllBeanConfigurations() {
protected <T> BeanConfiguration<T> createBeanConfiguration(Class<T> beanClass, Set<? extends ConstrainedElement> constrainableElements, List<Class<?>> defaultGroupSequence, Class<? extends DefaultGroupSequenceProvider<?>> defaultGroupSequenceProvider) {

return new BeanConfiguration<T>(
configurationSource,
beanClass,
constrainableElements,
defaultGroupSequence,
@@ -17,7 +17,6 @@
package org.hibernate.validator.metadata.provider;

import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.HashSet;
@@ -29,14 +28,15 @@
import org.hibernate.validator.cfg.context.impl.ConfiguredConstraint;
import org.hibernate.validator.cfg.context.impl.ConstraintMappingContext;
import org.hibernate.validator.metadata.AnnotationIgnores;
import org.hibernate.validator.metadata.BeanConfiguration.ConfigurationSource;
import org.hibernate.validator.metadata.ConstrainedElement;
import org.hibernate.validator.metadata.MetaConstraint;
import org.hibernate.validator.metadata.ConstrainedField;
import org.hibernate.validator.metadata.ConstrainedMethod;
import org.hibernate.validator.metadata.ConstrainedParameter;
import org.hibernate.validator.metadata.ConstraintDescriptorImpl;
import org.hibernate.validator.metadata.ConstraintHelper;
import org.hibernate.validator.metadata.ConstraintOrigin;
import org.hibernate.validator.metadata.ConstrainedMethod;
import org.hibernate.validator.metadata.ConstrainedParameter;
import org.hibernate.validator.metadata.ConstrainedField;
import org.hibernate.validator.metadata.MetaConstraint;
import org.hibernate.validator.metadata.location.BeanConstraintLocation;
import org.hibernate.validator.metadata.location.ConstraintLocation;
import org.hibernate.validator.metadata.location.MethodConstraintLocation;
@@ -55,7 +55,7 @@ public class ProgrammaticMappingMetaDataProvider extends MetaDataProviderImplBas

public ProgrammaticMappingMetaDataProvider(ConstraintHelper constraintHelper, ConstraintMapping mapping) {

super( constraintHelper );
super( ConfigurationSource.API, constraintHelper );

initProgrammaticConfiguration( mapping );
}
@@ -87,8 +87,8 @@ private <T> void initProgrammaticConfiguration(ConstraintMapping mapping) {
context.getMethodConstraintConfig().get( clazz )
);

constrainedElements.addAll(methodMetaData);
constrainedElements.addAll( methodMetaData );

configuredBeans.put(
clazz,
createBeanConfiguration(
@@ -162,7 +162,7 @@ methodConstraints, constraintsByMethod()

parameterMetaDatas.add(
new ConstrainedParameter(
new MethodConstraintLocation(oneMethod, i),
new MethodConstraintLocation( oneMethod, i ),
parameterName,
asMetaConstraints( constraintsByParameter.get( i ) ),
isCascading
@@ -184,7 +184,7 @@ methodConstraints, constraintsByMethod()
}

private Set<MetaConstraint<?>> asMetaConstraints(Set<? extends ConfiguredConstraint<?, ?>> constraints) {

if ( constraints == null ) {
return Collections.emptySet();
}
@@ -23,9 +23,10 @@
import java.util.Set;

import org.hibernate.validator.metadata.AnnotationIgnores;
import org.hibernate.validator.metadata.MetaConstraint;
import org.hibernate.validator.metadata.ConstraintHelper;
import org.hibernate.validator.metadata.BeanConfiguration.ConfigurationSource;
import org.hibernate.validator.metadata.ConstrainedField;
import org.hibernate.validator.metadata.ConstraintHelper;
import org.hibernate.validator.metadata.MetaConstraint;
import org.hibernate.validator.metadata.location.BeanConstraintLocation;
import org.hibernate.validator.metadata.location.ConstraintLocation;
import org.hibernate.validator.util.CollectionHelper.Partitioner;
@@ -49,7 +50,7 @@ public class XmlConfigurationMetaDataProvider extends MetaDataProviderImplBase {
*/
public XmlConfigurationMetaDataProvider(ConstraintHelper constraintHelper, Set<InputStream> mappingStreams) {

super( constraintHelper );
super( ConfigurationSource.XML, constraintHelper );

XmlMappingParser mappingParser = new XmlMappingParser( constraintHelper );
mappingParser.parse( mappingStreams );