Package org.hibernate.validator.internal.metadata.raw

Examples of org.hibernate.validator.internal.metadata.raw.ConstrainedParameter


  public MethodConstraintMappingContext method(String name, Class<?>... parameterTypes) {
    return executableContext.getTypeContext().method( name, parameterTypes );
  }

  public ConstrainedParameter build(ConstraintHelper constraintHelper, ParameterNameProvider parameterNameProvider) {
    return new ConstrainedParameter(
        ConfigurationSource.API,
        ConstraintLocation.forParameter( executableContext.getExecutable(), parameterIndex ),
        ReflectionHelper.typeOf( executableContext.getExecutable(), parameterIndex ),
        parameterIndex,
        executableContext.getExecutable().getParameterNames( parameterNameProvider ).get( parameterIndex ),
View Full Code Here


            parameterType.getIgnoreAnnotations()
        );
      }

      // TODO HV-919 Support specification of type parameter constraints via XML and API
      ConstrainedParameter constrainedParameter = new ConstrainedParameter(
          ConfigurationSource.XML,
          constraintLocation,
          ReflectionHelper.typeOf( executableElement, i ),
          i,
          parameterNames.get( i ),
View Full Code Here

    return executableContext.getTypeContext().method( name, parameterTypes );
  }

  public ConstrainedParameter build(ConstraintHelper constraintHelper, ParameterNameProvider parameterNameProvider) {
    // TODO HV-919 Support specification of type parameter constraints via XML and API
    return new ConstrainedParameter(
        ConfigurationSource.API,
        ConstraintLocation.forParameter( executableContext.getExecutable(), parameterIndex ),
        ReflectionHelper.typeOf( executableContext.getExecutable(), parameterIndex ),
        parameterIndex,
        executableContext.getExecutable().getParameterNames( parameterNameProvider ).get( parameterIndex ),
View Full Code Here

      if ( parameter != null ) {
        constrainedParameters.add( parameter.build( constraintHelper, parameterNameProvider ) );
      }
      else {
        constrainedParameters.add(
            new ConstrainedParameter(
                ConfigurationSource.API,
                ConstraintLocation.forParameter( executable, i ),
                ReflectionHelper.typeOf( executable, i ),
                i,
                executable.getParameterNames( parameterNameProvider ).get( i )
View Full Code Here

      return ( (ConstrainedParameter) constrainedElement ).getLocation().getParameterIndex() == parameterIndex;
    }

    @Override
    public void add(ConstrainedElement constrainedElement) {
      ConstrainedParameter constrainedParameter = (ConstrainedParameter) constrainedElement;

      constraints.addAll( constrainedParameter.getConstraints() );

      if ( name == null ) {
        name = constrainedParameter.getParameterName();
      }

      isCascading = isCascading || constrainedParameter.isCascading();
    }
View Full Code Here

      );
      List<ConstrainedParameter> parameterMetaDataList = newArrayList();

      for ( int i = 0; i < oneMethod.getParameterTypes().length; i++ ) {
        parameterMetaDataList.add(
            new ConstrainedParameter(
                ConfigurationSource.API,
                new MethodConstraintLocation( oneMethod, i ),
                parameterNames[i],
                asMetaConstraints( constraintsByParameter.get( i ) ),
                cascadesByParameter.containsKey( i )
View Full Code Here

        "setValues",
        String.class,
        Integer.class,
        List.class
    );
    ConstrainedParameter parameter = executable.getParameterMetaData( 2 );
    assertThat( parameter.getTypeArgumentsConstraints() ).hasSize( 2 );
    assertThat( getAnnotationsTypes( parameter.getTypeArgumentsConstraints() ) ).contains(
        NotNullTypeUse.class, NotBlankTypeUse.class
    );
  }
View Full Code Here

        String.class,
        Integer.class,
        List.class
    );

    ConstrainedParameter parameter = executable.getParameterMetaData( 2 );
    assertThat( parameter.getTypeArgumentsConstraints() ).hasSize( 2 );
    assertThat( getAnnotationsTypes( parameter.getTypeArgumentsConstraints() ) ).contains(
        NotNullTypeUse.class, NotBlankTypeUse.class
    );
  }
View Full Code Here

      ConvertGroup groupConversion = null;
      ConvertGroup.List groupConversionList = null;

      if ( annotationProcessingOptions.areParameterConstraintsIgnoredFor( executable.getMember(), i ) ) {
        metaData.add(
            new ConstrainedParameter(
                ConfigurationSource.ANNOTATION,
                ConstraintLocation.forParameter( executable, i ),
                ReflectionHelper.typeOf( executable, i ),
                i,
                parameterName,
                parameterConstraints,
                typeArgumentsConstraints,
                getGroupConversions( groupConversion, groupConversionList ),
                false,
                UnwrapMode.AUTOMATIC
            )
        );
        i++;
        continue;
      }

      UnwrapMode unwrapMode = UnwrapMode.AUTOMATIC;
      for ( Annotation parameterAnnotation : parameterAnnotations ) {
        //1. mark parameter as cascading if this annotation is the @Valid annotation
        if ( parameterAnnotation.annotationType().equals( Valid.class ) ) {
          parameterIsCascading = true;
        }

        //2. determine group conversions
        else if ( parameterAnnotation.annotationType().equals( ConvertGroup.class ) ) {
          groupConversion = (ConvertGroup) parameterAnnotation;
        }
        else if ( parameterAnnotation.annotationType().equals( ConvertGroup.List.class ) ) {
          groupConversionList = (ConvertGroup.List) parameterAnnotation;
        }

        //3. unwrapping required?
        else if ( parameterAnnotation.annotationType().equals( UnwrapValidatedValue.class ) ) {
          UnwrapValidatedValue unwrapValidatedValue = (UnwrapValidatedValue) parameterAnnotation;
          unwrapMode = unwrapValidatedValue.value() ? UnwrapMode.UNWRAP : UnwrapMode.SKIP_UNWRAP;
        }

        //4. collect constraints if this annotation is a constraint annotation
        List<ConstraintDescriptorImpl<?>> constraints = findConstraintAnnotations(
            executable.getMember(), parameterAnnotation, ElementType.PARAMETER
        );
        for ( ConstraintDescriptorImpl<?> constraintDescriptorImpl : constraints ) {
          parameterConstraints.add(
              createParameterMetaConstraint( executable, i, constraintDescriptorImpl )
          );
        }
      }

      typeArgumentsConstraints = findTypeAnnotationConstraintsForExecutableParameter( executable.getMember(), i );
      // if there are type annotation constraints for a parameter which is not an iterable, we force the unwrapping
      if ( !typeArgumentsConstraints.isEmpty() ) {
        if ( !ReflectionHelper.isIterable( ReflectionHelper.typeOf( executable, i ) ) ) {
          unwrapMode = UnwrapMode.UNWRAP;
        }
      }

      metaData.add(
          new ConstrainedParameter(
              ConfigurationSource.ANNOTATION,
              ConstraintLocation.forParameter( executable, i ),
              ReflectionHelper.typeOf( executable, i ),
              i,
              parameterName,
View Full Code Here

    @Override
    public void add(ConstrainedElement constrainedElement) {
      super.add( constrainedElement );

      ConstrainedParameter constrainedParameter = (ConstrainedParameter) constrainedElement;

      typeArgumentsConstraints.addAll( constrainedParameter.getTypeArgumentsConstraints() );

      if ( name == null ) {
        name = constrainedParameter.getName();
      }
    }
View Full Code Here

TOP

Related Classes of org.hibernate.validator.internal.metadata.raw.ConstrainedParameter

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.