Package org.hibernate.validator.metadata

Examples of org.hibernate.validator.metadata.MethodMetaData


        byMethod()
    );

    for ( Entry<Method, List<ConfiguredConstraint<?, MethodConstraintLocation>>> oneMethod : constraintsByMethod.entrySet() ) {

      MethodMetaData methodMetaData = createMethodMetaData(
          oneMethod.getKey(), oneMethod.getValue(), rootClass, hierarchyClass
      );
      addMetaDataToBuilder( methodMetaData, builders );
    }
  }
View Full Code Here


    }
  }

  private void addProgrammaticConfiguredMethodCascade(List<MethodConstraintLocation> methodCascades, Set<AggregatedMethodMetaData.Builder> builders) {
    for ( MethodConstraintLocation cascadeDef : methodCascades ) {
      MethodMetaData methodMetaData = createMethodMetaData( cascadeDef );
      addMetaDataToBuilder( methodMetaData, builders );
    }
  }
View Full Code Here

      i++;
    }

    boolean isCascading = cascadeDef.getParameterIndex() == null;
    return new MethodMetaData( method, parameterMetaDatas, returnConstraints, isCascading );
  }
View Full Code Here

    List<MethodMetaConstraint<?>> returnValueConstraints = convertToMethodConstraints(
        constraintsByIndex.get( null ), rootClass, hierarchyClass
    );

    return new MethodMetaData(
        method, allParameterMetaData, returnValueConstraints, false
    );
  }
View Full Code Here

    BeanMetaData<?> beanMetaData = getBeanMetaData( method.getDeclaringClass() );
    Map<Class<?>, MethodMetaData> methodMetaDataByType = beanMetaData.getMetaDataForMethod( method );

    //used for retrieval of parameter names; we'll take the names from the lowest method in the hierarchy
    MethodMetaData methodMetaDataOfDeclaringType = methodMetaDataByType.get( method.getDeclaringClass() );

    // TODO GM: define behavior with respect to redefined default sequences. Should only the
    // sequence from the validated bean be honored or also default sequence definitions up in
    // the inheritance tree?
    // For now a redefined default sequence will only be considered if specified at the bean
    // hosting the validated itself, but no other default sequence from parent types

    List<Class<?>> groupList;
    if ( group.isDefaultGroup() ) {
      groupList = beanMetaData.getDefaultGroupSequence();
    }
    else {
      groupList = Arrays.<Class<?>>asList( group.getGroup() );
    }

    //the only case where we can have multiple groups here is a redefined default group sequence
    for ( Class<?> oneGroup : groupList ) {

      int numberOfViolationsOfCurrentGroup = 0;

      for ( Entry<Class<?>, MethodMetaData> constraintsOfOneClass : methodMetaDataByType.entrySet() ) {

        for ( int i = 0; i < parameterValues.length; i++ ) {

          //ignore this parameter if this validation is for a single parameter and this is not the right one
          if ( validationContext.getParameterIndex() != null && !validationContext.getParameterIndex()
              .equals( i ) ) {
            continue;
          }

          Object value = parameterValues[i];
          String parameterName = methodMetaDataOfDeclaringType.getParameterMetaData( i ).getParameterName();

          // validate constraints at parameter itself
          ValueContext<T, Object> valueContext = ValueContext.getLocalExecutionContext(
              object, PathImpl.createPathForMethodParameter( method, parameterName ), i, parameterName
          );
          valueContext.setCurrentValidatedValue( value );
          valueContext.setCurrentGroup( oneGroup );

          ParameterMetaData parameterMetaData = constraintsOfOneClass.getValue()
              .getParameterMetaData( valueContext.getParameterIndex() );

          numberOfViolationsOfCurrentGroup += validateParameterForGroup(
              validationContext, valueContext, parameterMetaData
          );
        }
      }

      //stop processing after first group with errors occurred
      if ( numberOfViolationsOfCurrentGroup > 0 ) {
        break;
      }
    }

    // validate parameter beans annotated with @Valid if required
    for ( int i = 0; i < parameterValues.length; i++ ) {

      //ignore this parameter if this validation is for a single parameter and this is not the right one
      if ( validationContext.getParameterIndex() != null && !validationContext.getParameterIndex().equals( i ) ) {
        continue;
      }

      Object value = parameterValues[i];
      String parameterName = methodMetaDataOfDeclaringType.getParameterMetaData( i ).getParameterName();

      if ( isCascadeRequired( method, i ) && value != null ) {

        ValueContext<Object, ?> cascadingvalueContext = ValueContext.getLocalExecutionContext(
            value, PathImpl.createPathForMethodParameter( method, parameterName ), i, parameterName
View Full Code Here

TOP

Related Classes of org.hibernate.validator.metadata.MethodMetaData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.