Package org.hibernate.validator.internal.metadata.aggregated

Examples of org.hibernate.validator.internal.metadata.aggregated.ParameterMetaData$Builder


      if ( validationContext.getParameterIndex() != null && !validationContext.getParameterIndex().equals( i ) ) {
        continue;
      }

      Object value = parameterValues[i];
      ParameterMetaData parameterMetaData = methodMetaData.getParameterMetaData( i );
      String parameterName = parameterMetaData.getName();

      if ( parameterMetaData.isCascading() && value != null ) {

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


      if ( validationContext.getParameterIndex() != null && !validationContext.getParameterIndex().equals( i ) ) {
        continue;
      }

      Object value = parameterValues[i];
      ParameterMetaData parameterMetaData = methodMetaData.getParameterMetaData( i );
      String parameterName = parameterMetaData.getName();

      if ( parameterMetaData.isCascading() && value != null ) {

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

      if ( validationContext.getParameterIndex() != null && !validationContext.getParameterIndex().equals( i ) ) {
        continue;
      }

      Object value = parameterValues[i];
      ParameterMetaData parameterMetaData = methodMetaData.getParameterMetaData( i );
      String parameterName = parameterMetaData.getName();

      if ( parameterMetaData.isCascading() && value != null ) {

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

      // 2. validate parameter constraints
      for ( int i = 0; i < parameterValues.length; i++ ) {
        PathImpl originalPath = valueContext.getPropertyPath();

        ParameterMetaData parameterMetaData = executableMetaData.getParameterMetaData( i );
        Object value = parameterValues[i];

        if ( value != null ) {
          Class<?> valueType = value.getClass();
          if ( parameterMetaData.getType() instanceof Class && ( (Class<?>) parameterMetaData.getType() ).isPrimitive() ) {
            valueType = ReflectionHelper.unBoxedType( valueType );
          }
          if ( !TypeHelper.isAssignable( parameterMetaData.getType(), valueType ) ) {
            throw log.getParameterTypesDoNotMatchException(
                valueType.getName(),
                parameterMetaData.getType().toString(),
                i,
                validationContext.getExecutable().getMember()
            );
          }
        }
View Full Code Here

      // 2. validate parameter constraints
      for ( int i = 0; i < parameterValues.length; i++ ) {
        PathImpl originalPath = valueContext.getPropertyPath();

        ParameterMetaData parameterMetaData = executableMetaData.getParameterMetaData( i );
        Object value = parameterValues[i];

        if ( value != null ) {
          Class<?> valueType = value.getClass();
          if ( parameterMetaData.getType() instanceof Class && ( (Class<?>) parameterMetaData.getType() ).isPrimitive() ) {
            valueType = ReflectionHelper.unBoxedType( valueType );
          }
          if ( !TypeHelper.isAssignable(
              TypeHelper.getErasedType( parameterMetaData.getType() ),
              valueType
          ) ) {
            throw log.getParameterTypesDoNotMatchException(
                valueType.getName(),
                parameterMetaData.getType().toString(),
                i,
                validationContext.getExecutable().getMember()
            );
          }
        }

        valueContext.appendNode( parameterMetaData );
        valueContext.setUnwrapMode( parameterMetaData.unwrapMode() );
        valueContext.setCurrentValidatedValue( value );

        numberOfViolationsOfCurrentGroup += validateConstraintsForGroup(
            validationContext, valueContext, parameterMetaData
        );
        if ( shouldFailFast( validationContext ) ) {
          return validationContext.getFailingConstraints().size() - numberOfViolationsBefore;
        }

        if ( !parameterMetaData.isCascading() ) {
          numberOfViolationsOfCurrentGroup += validateConstraintsForGroup(
              validationContext, valueContext, parameterMetaData.getTypeArgumentsConstraints()
          );
          if ( shouldFailFast( validationContext ) ) {
            return validationContext.getFailingConstraints().size() - numberOfViolationsBefore;
          }
        }
View Full Code Here

      if ( validationContext.getParameterIndex() != null && !validationContext.getParameterIndex().equals( i ) ) {
        continue;
      }

      Object value = parameterValues[i];
      ParameterMetaData parameterMetaData = methodMetaData.getParameterMetaData( i );
      String parameterName = parameterMetaData.getName();

      if ( parameterMetaData.isCascading() && value != null ) {

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

      // 2. validate parameter constraints
      for ( int i = 0; i < parameterValues.length; i++ ) {
        PathImpl originalPath = valueContext.getPropertyPath();

        ParameterMetaData parameterMetaData = executableMetaData.getParameterMetaData( i );
        Object value = parameterValues[i];

        if ( value != null ) {
          Class<?> valueType = value.getClass();
          if ( parameterMetaData.getType() instanceof Class && ( (Class<?>) parameterMetaData.getType() ).isPrimitive() ) {
            valueType = ReflectionHelper.unBoxedType( valueType );
          }
          if ( !TypeHelper.isAssignable( TypeHelper.getErasedType( parameterMetaData.getType() ), valueType ) ) {
            throw log.getParameterTypesDoNotMatchException(
                valueType.getName(),
                parameterMetaData.getType().toString(),
                i,
                validationContext.getExecutable().getMember()
            );
          }
        }
View Full Code Here

  @Test
  public void constrainedParameterMetaData() throws Exception {
    Method method = CustomerRepository.class.getMethod( "createCustomer", CharSequence.class, String.class );
    ExecutableMetaData methodMetaData = beanMetaData.getMetaDataFor( ExecutableElement.forMethod( method ) );

    ParameterMetaData parameterMetaData = methodMetaData.getParameterMetaData( 1 );

    assertFalse( parameterMetaData.isCascading() );
    assertTrue( parameterMetaData.isConstrained() );
    assertEquals( parameterMetaData.getIndex(), 1 );
    assertEquals( parameterMetaData.getName(), "arg1" );
    assertThat( parameterMetaData ).hasSize( 1 );
    assertEquals(
        parameterMetaData.iterator().next().getDescriptor().getAnnotation().annotationType(), NotNull.class
    );
  }
View Full Code Here

  @Test
  public void cascadingParameterMetaData() throws Exception {
    Method method = CustomerRepository.class.getMethod( "saveCustomer", Customer.class );
    ExecutableMetaData methodMetaData = beanMetaData.getMetaDataFor( ExecutableElement.forMethod( method ) );

    ParameterMetaData parameterMetaData = methodMetaData.getParameterMetaData( 0 );

    assertTrue( parameterMetaData.isCascading() );
    assertTrue( parameterMetaData.isConstrained() );
    assertEquals( parameterMetaData.getIndex(), 0 );
    assertEquals( parameterMetaData.getName(), "arg0" );
    assertThat( parameterMetaData ).isEmpty();
  }
View Full Code Here

  @Test
  public void unconstrainedParameterMetaData() throws Exception {
    Method method = CustomerRepository.class.getMethod( "updateCustomer", Customer.class );
    ExecutableMetaData methodMetaData = beanMetaData.getMetaDataFor( ExecutableElement.forMethod( method ) );

    ParameterMetaData parameterMetaData = methodMetaData.getParameterMetaData( 0 );

    assertFalse( parameterMetaData.isCascading() );
    assertFalse( parameterMetaData.isConstrained() );
    assertThat( parameterMetaData ).isEmpty();
    assertEquals( parameterMetaData.unwrapMode(), UnwrapMode.AUTOMATIC );
  }
View Full Code Here

TOP

Related Classes of org.hibernate.validator.internal.metadata.aggregated.ParameterMetaData$Builder

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.