Package javax.validation

Examples of javax.validation.ConstraintDefinitionException


      methods = getMethods.run();
    }
    for ( Method m : methods ) {
      if ( m.getName().startsWith( "valid" ) ) {
        String msg = "Parameters starting with 'valid' are not allowed in a constraint.";
        throw new ConstraintDefinitionException( msg );
      }
    }
  }
View Full Code Here


        method = getMethod.run();
      }
      if (method == null) {
        String msg = annotation.annotationType().getName() + " contains Constraint annotation, but does " +
          "not contain a payload parameter.";
        throw new ConstraintDefinitionException( msg );
      }
      Class<?>[] defaultPayload = ( Class<?>[] ) method.getDefaultValue();
      if ( defaultPayload.length != 0 ) {
        String msg = annotation.annotationType()
            .getName() + " contains Constraint annotation, but the payload " +
            "paramter default value is not the empty array.";
        throw new ConstraintDefinitionException( msg );
      }
    }
    catch ( ClassCastException e ) {
      String msg = annotation.annotationType().getName() + " contains Constraint annotation, but the " +
          "payload parameter is of wrong type.";
      throw new ConstraintDefinitionException( msg );
    }
  }
View Full Code Here

        method = getMethod.run();
      }
      if (method == null) {
        String msg = annotation.annotationType().getName() + " contains Constraint annotation, but does " +
          "not contain a groups parameter.";
        throw new ConstraintDefinitionException( msg );
      }
      Class<?>[] defaultGroups = ( Class<?>[] ) method.getDefaultValue();
      if ( defaultGroups.length != 0 ) {
        String msg = annotation.annotationType()
            .getName() + " contains Constraint annotation, but the groups " +
            "paramter default value is not the empty array.";
        throw new ConstraintDefinitionException( msg );
      }
    }
    catch ( ClassCastException e ) {
      String msg = annotation.annotationType().getName() + " contains Constraint annotation, but the " +
          "groups parameter is of wrong type.";
      throw new ConstraintDefinitionException( msg );
    }
  }
View Full Code Here

      }
    }
    catch ( Exception e ) {
      String msg = annotation.annotationType().getName() + " contains Constraint annotation, but does " +
          "not contain a message parameter.";
      throw new ConstraintDefinitionException( msg );
    }
  }
View Full Code Here

  }

  private void ensureAttributeIsOverridable(Method m, OverridesAttribute overridesAttribute) {
    final Method method = ReflectionHelper.getMethod( overridesAttribute.constraint(), overridesAttribute.name() );
    if ( method == null ) {
      throw new ConstraintDefinitionException(
          "Overridden constraint does not define an attribute with name " + overridesAttribute.name()
      );
    }
    Class<?> returnTypeOfOverriddenConstraint = method.getReturnType();
    if ( !returnTypeOfOverriddenConstraint.equals( m.getReturnType() ) ) {
      String message = "The overriding type of a composite constraint must be identical to the overridden one. Expected " + returnTypeOfOverriddenConstraint
          .getName() + " found " + m.getReturnType();
      throw new ConstraintDefinitionException( message );
    }
  }
View Full Code Here

  private void assertNoParameterStartsWithValid(Class<? extends Annotation> annotationType) {
    final Method[] methods = ReflectionHelper.getMethods( annotationType );
    for ( Method m : methods ) {
      if ( m.getName().startsWith( "valid" ) ) {
        String msg = "Parameters starting with 'valid' are not allowed in a constraint.";
        throw new ConstraintDefinitionException( msg );
      }
    }
  }
View Full Code Here

    try {
      final Method method = ReflectionHelper.getMethod( annotationType, "payload" );
      if ( method == null ) {
        String msg = annotationType.getName() + " contains Constraint annotation, but does " +
            "not contain a payload parameter.";
        throw new ConstraintDefinitionException( msg );
      }
      Class<?>[] defaultPayload = ( Class<?>[] ) method.getDefaultValue();
      if ( defaultPayload.length != 0 ) {
        String msg = annotationType
            .getName() + " contains Constraint annotation, but the payload " +
            "parameter default value is not the empty array.";
        throw new ConstraintDefinitionException( msg );
      }
    }
    catch ( ClassCastException e ) {
      String msg = annotationType.getName() + " contains Constraint annotation, but the " +
          "payload parameter is of wrong type.";
      throw new ConstraintDefinitionException( msg );
    }
  }
View Full Code Here

    try {
      final Method method = ReflectionHelper.getMethod( annotationType, "groups" );
      if ( method == null ) {
        String msg = annotationType.getName() + " contains Constraint annotation, but does " +
            "not contain a groups parameter.";
        throw new ConstraintDefinitionException( msg );
      }
      Class<?>[] defaultGroups = ( Class<?>[] ) method.getDefaultValue();
      if ( defaultGroups.length != 0 ) {
        String msg = annotationType
            .getName() + " contains Constraint annotation, but the groups " +
            "parameter default value is not the empty array.";
        throw new ConstraintDefinitionException( msg );
      }
    }
    catch ( ClassCastException e ) {
      String msg = annotationType.getName() + " contains Constraint annotation, but the " +
          "groups parameter is of wrong type.";
      throw new ConstraintDefinitionException( msg );
    }
  }
View Full Code Here

    try {
      final Method method = ReflectionHelper.getMethod( annotationType, "message" );
      if ( method == null ) {
        String msg = annotationType.getName() + " contains Constraint annotation, but does " +
            "not contain a message parameter.";
        throw new ConstraintDefinitionException( msg );
      }
      if ( method.getReturnType() != String.class ) {
        String msg = annotationType.getName() + " contains Constraint annotation, but the message parameter " +
            "is not of type java.lang.String.";
        throw new ConstraintDefinitionException( msg );
      }
    }
    catch ( ClassCastException e ) {
      String msg = annotationType.getName() + " contains Constraint annotation, but the " +
          "groups parameter is of wrong type.";
      throw new ConstraintDefinitionException( msg );
    }
  }
View Full Code Here

    }
    else {
      method = getMethod.run();
    }
    if ( method == null ) {
      throw new ConstraintDefinitionException(
          "Overridden constraint does not define an attribute with name " + overridesAttribute.name()
      );
    }
    Class<?> returnTypeOfOverriddenConstraint = method.getReturnType();
    if ( !returnTypeOfOverriddenConstraint.equals( m.getReturnType() ) ) {
      String message = "The overriding type of a composite constraint must be identical to the overridden one. Expected " + returnTypeOfOverriddenConstraint
          .getName() + " found " + m.getReturnType();
      throw new ConstraintDefinitionException( message );
    }
  }
View Full Code Here

TOP

Related Classes of javax.validation.ConstraintDefinitionException

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.