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

Examples of org.hibernate.validator.internal.metadata.raw.ExecutableElement$ConstructorElement


    public boolean accepts(ConstrainedElement constrainedElement) {
      if ( kind != constrainedElement.getKind() ) {
        return false;
      }

      ExecutableElement executableElement = ( (ConstrainedExecutable) constrainedElement ).getExecutable();

      //are the locations equal (created by different builders) or
      //does one of the executables override the other one?
      return
          executable.equals( executableElement ) ||
View Full Code Here


  private <T> int validateParametersForGroup(MethodValidationContext<T> validationContext, T object, Object[] parameterValues, Group group) {

    int numberOfViolationsBefore = validationContext.getFailingConstraints().size();

    ExecutableElement executable = validationContext.getExecutable();

    BeanMetaData<T> beanMetaData = beanMetaDataManager.getBeanMetaData( validationContext.getRootBeanClass() );
    ExecutableMetaData methodMetaData = beanMetaData.getMetaDataFor( executable );

    // 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( object );
    }
    else {
      groupList = Arrays.<Class<?>>asList( group.getDefiningClass() );
    }

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

      int numberOfViolationsOfCurrentGroup = 0;

      for ( int i = 0; i < parameterValues.length; i++ ) {
        Object value = parameterValues[i];
        String parameterName = methodMetaData.getParameterMetaData( i ).getName();

        // validate constraints at parameter itself
        ValueContext<T, Object> valueContext;

        if ( object != null ) {
          valueContext = ValueContext.getLocalExecutionContext(
              object, PathImpl.createPathForParameter( executable, parameterName ), i, parameterName
          );
        }
        else {
          valueContext = ValueContext.getLocalExecutionContext(
              object,
              (Class<T>) executable.getMember().getDeclaringClass(),
              PathImpl.createPathForParameter( executable, parameterName ),
              i,
              parameterName
          );
        }
View Full Code Here

  //TODO GM: if possible integrate with validateParameterForGroup()
  private <T, V> int validateReturnValueForGroup(MethodValidationContext<T> validationContext, T bean, V value, Group group) {

    int numberOfViolationsBefore = validationContext.getFailingConstraints().size();

    ExecutableElement executable = validationContext.getExecutable();

    BeanMetaData<T> beanMetaData = beanMetaDataManager.getBeanMetaData( validationContext.getRootBeanClass() );
    ExecutableMetaData methodMetaData = beanMetaData.getMetaDataFor( executable );

    // 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( bean );
    }
    else {
      groupList = Arrays.<Class<?>>asList( group.getDefiningClass() );
    }

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

      int numberOfViolationsOfCurrentGroup = 0;

      // validate constraints at return value itself
      ValueContext<T, V> valueContext;
      if ( bean != null ) {
        valueContext = ValueContext.getLocalExecutionContext(
            bean, PathImpl.createPathForMethodReturnValue( executable )
        );
      }
      else {
        //constructor validation
        valueContext = ValueContext.getLocalExecutionContext(
            (Class<T>) executable.getMember().getDeclaringClass(),
            PathImpl.createPathForMethodReturnValue( executable )
        );
      }

      valueContext.setCurrentValidatedValue( value );
View Full Code Here

    public boolean accepts(ConstrainedElement constrainedElement) {
      if ( kind != constrainedElement.getKind() ) {
        return false;
      }

      ExecutableElement executableElement = ( (ConstrainedExecutable) constrainedElement ).getLocation()
          .getExecutableElement();

      //are the locations equal (created by different builders) or
      //does one of the executables override the other one?
      return
          location.getExecutableElement().equals( executableElement ) ||
              location.getExecutableElement().overrides( executableElement ) ||
              executableElement.overrides(
                  location.getExecutableElement()
              );
    }
View Full Code Here

    @Override
    public ExecutableMetaData build() {
      assertCorrectnessOfConfiguration();

      ExecutableElement executableElement = location.getExecutableElement();

      return new ExecutableMetaData(
          executableElement.getSimpleName(),
          executableElement.getReturnType(),
          executableElement.getParameterTypes(),
          kind == ConstrainedElement.ConstrainedElementKind.CONSTRUCTOR ? ElementKind.CONSTRUCTOR : ElementKind.METHOD,
          adaptOriginsAndImplicitGroups( getConstraints() ),
          findParameterMetaData(),
          adaptOriginsAndImplicitGroups( crossParameterConstraints ),
          getGroupConversions(),
          isCascading(),
          isConstrained,
          executableElement.isGetterMethod()
      );
    }
View Full Code Here

      }
      else {
        alreadyProcessedMethods.add( method );
      }

      ExecutableElement methodExecutableElement = ExecutableElement.forMethod( method );

      // ignore annotations
      if ( methodType.getIgnoreAnnotations() != null ) {
        annotationProcessingOptions.ignoreConstraintAnnotationsOnMember(
            method,
View Full Code Here

      }
      else {
        alreadyProcessedConstructors.add( constructor );
      }

      ExecutableElement constructorExecutableElement = ExecutableElement.forConstructor( constructor );

      // ignore annotations
      if ( constructorType.getIgnoreAnnotations() != null ) {
        annotationProcessingOptions.ignoreConstraintAnnotationsOnMember(
            constructor,
View Full Code Here

    public boolean accepts(ConstrainedElement constrainedElement) {
      if ( kind != constrainedElement.getKind() ) {
        return false;
      }

      ExecutableElement executableElement = ( (ConstrainedExecutable) constrainedElement ).getLocation()
          .getExecutableElement();

      //are the locations equal (created by different builders) or
      //does one of the executables override the other one?
      return
          location.getExecutableElement().equals( executableElement ) ||
              location.getExecutableElement().overrides( executableElement ) ||
              executableElement.overrides(
                  location.getExecutableElement()
              );
    }
View Full Code Here

      executablesByDeclaringType.put( beanClass, mergedExecutable.merge( executable ) );
    }

    @Override
    public ExecutableMetaData build() {
      ExecutableElement executableElement = location.getExecutableElement();

      ConstraintDeclarationException constraintDeclarationException = checkParameterConstraints();
      if ( constraintDeclarationException == null ) {
        constraintDeclarationException = checkReturnValueConfiguration();
      }

      return new ExecutableMetaData(
          executableElement.getSimpleName(),
          executableElement.getReturnType(),
          executableElement.getParameterTypes(),
          kind == ConstrainedElement.ConstrainedElementKind.CONSTRUCTOR ? ElementKind.CONSTRUCTOR : ElementKind.METHOD,
          adaptOriginsAndImplicitGroups( getConstraints() ),
          findParameterMetaData(),
          adaptOriginsAndImplicitGroups( crossParameterConstraints ),
          constraintDeclarationException,
          getGroupConversions(),
          isCascading(),
          isConstrained,
          executableElement.isGetterMethod()
      );
    }
View Full Code Here

TOP

Related Classes of org.hibernate.validator.internal.metadata.raw.ExecutableElement$ConstructorElement

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.