Package javax.validation

Examples of javax.validation.ConstraintDeclarationException


    private Field getField(String name, Class<?> type) {
        Field f;
        try {
            f = type.getDeclaredField(name);
        } catch(NoSuchFieldException e) {
            throw new ConstraintDeclarationException(
                "Could not validate " + StartBeforeEnd.class.getSimpleName()
                + ". No field found in " + type.getName() + " for " + name);
        }
        if(f.getType() != Date.class) {
            throw new UnexpectedTypeException(
View Full Code Here


      if ( methodsWithParameterConstraints.isEmpty() ) {
        return null;
      }

      if ( methodsWithParameterConstraints.size() > 1 ) {
        return new ConstraintDeclarationException(
            "Only the root method of an overridden method in an inheritance hierarchy may be annotated with parameter constraints, " +
                "but there are parameter constraints defined at all of the following overridden methods: " +
                methodsWithParameterConstraints
        );
      }

      MethodMetaData constrainedMethod = methodsWithParameterConstraints.iterator().next();

      for ( MethodMetaData oneMethod : allMethods ) {

        if ( !constrainedMethod.getMethod()
            .getDeclaringClass()
            .isAssignableFrom( oneMethod.getMethod().getDeclaringClass() ) ) {
          return new ConstraintDeclarationException(
              "Only the root method of an overridden method in an inheritance hierarchy may be annotated with parameter constraints. " +
                  "The following method itself has no parameter constraints but it is not defined on a sub-type of " +
                  constrainedMethod.getMethod().getDeclaringClass() + ": " + oneMethod
          );
        }
View Full Code Here

    try {
      ScriptEvaluatorFactory evaluatorFactory = ScriptEvaluatorFactory.getInstance();
      scriptEvaluator = evaluatorFactory.getScriptEvaluatorByLanguageName( languageName );
    }
    catch ( ScriptException e ) {
      throw new ConstraintDeclarationException( e );
    }

    try {
      evaluationResult = scriptEvaluator.evaluate( script, value, alias );
    }
    catch ( ScriptException e ) {
      throw new ConstraintDeclarationException(
          "Error during execution of script \"" + script + "\" occurred.", e
      );
    }

    if ( evaluationResult == null ) {
      throw new ConstraintDeclarationException( "Script \"" + script + "\" returned null, but must return either true or false." );
    }
    if ( !( evaluationResult instanceof Boolean ) ) {
      throw new ConstraintDeclarationException(
          "Script \"" + script + "\" returned " + evaluationResult + " (of type " + evaluationResult.getClass()
              .getCanonicalName() + "), but must return either true or false."
      );
    }
View Full Code Here

      for ( ConstrainedExecutable constrainedExecutable : executablesWithParameterConstraints ) {
        definingTypes.add( constrainedExecutable.getLocation().getBeanClass() );
      }

      if ( definingTypes.size() > 1 ) {
        return new ConstraintDeclarationException(
            "Only the root method of an overridden method in an inheritance hierarchy may be annotated with parameter constraints, " +
                "but there are parameter constraints defined at all of the following overridden methods: " +
                executablesWithParameterConstraints
        );
      }

      ConstrainedExecutable constrainedExecutable = executablesWithParameterConstraints.iterator()
          .next();

      for ( ConstrainedExecutable oneExecutable : constrainedExecutables ) {

        if ( !constrainedExecutable.getLocation().getBeanClass()
            .isAssignableFrom( oneExecutable.getLocation().getBeanClass() ) ) {
          return new ConstraintDeclarationException(
              "Only the root method of an overridden method in an inheritance hierarchy may be annotated with parameter constraints. " +
                  "The following method itself has no parameter constraints but it is not defined on a sub-type of " +
                  constrainedExecutable.getLocation()
                      .getBeanClass() + ": " + oneExecutable
          );
View Full Code Here

      for ( ConstrainedMethod constrainedMethod : methodsWithParameterConstraints ) {
        definingTypes.add( constrainedMethod.getLocation().getBeanClass() );
      }

      if ( definingTypes.size() > 1 ) {
        return new ConstraintDeclarationException(
            "Only the root method of an overridden method in an inheritance hierarchy may be annotated with parameter constraints, " +
                "but there are parameter constraints defined at all of the following overridden methods: " +
                methodsWithParameterConstraints
        );
      }

      ConstrainedMethod constrainedMethod = methodsWithParameterConstraints.iterator().next();

      for ( ConstrainedMethod oneMethod : constrainedMethods ) {

        if ( !constrainedMethod.getLocation().getBeanClass()
            .isAssignableFrom( oneMethod.getLocation().getBeanClass() ) ) {
          return new ConstraintDeclarationException(
              "Only the root method of an overridden method in an inheritance hierarchy may be annotated with parameter constraints. " +
                  "The following method itself has no parameter constraints but it is not defined on a sub-type of " +
                  constrainedMethod.getLocation().getBeanClass() + ": " + oneMethod
          );
        }
View Full Code Here

      for ( ConstrainedExecutable constrainedExecutable : executablesWithParameterConstraints ) {
        definingTypes.add( constrainedExecutable.getLocation().getBeanClass() );
      }

      if ( definingTypes.size() > 1 ) {
        return new ConstraintDeclarationException(
            "Only the root method of an overridden method in an inheritance hierarchy may be annotated with parameter constraints, " +
                "but there are parameter constraints defined at all of the following overridden methods: " +
                executablesWithParameterConstraints
        );
      }

      ConstrainedExecutable constrainedExecutable = executablesWithParameterConstraints.iterator()
          .next();

      for ( ConstrainedExecutable oneExecutable : constrainedExecutables ) {

        if ( !constrainedExecutable.getLocation().getBeanClass()
            .isAssignableFrom( oneExecutable.getLocation().getBeanClass() ) ) {
          return new ConstraintDeclarationException(
              "Only the root method of an overridden method in an inheritance hierarchy may be annotated with parameter constraints. " +
                  "The following method itself has no parameter constraints but it is not defined on a sub-type of " +
                  constrainedExecutable.getLocation()
                      .getBeanClass() + ": " + oneExecutable
          );
View Full Code Here

        try {
            ScriptEvaluatorFactory evaluatorFactory = ScriptEvaluatorFactory.getInstance();
            scriptEvaluator = evaluatorFactory.getScriptEvaluatorByLanguageName( languageName );
        }
        catch ( ScriptException e ) {
            throw new ConstraintDeclarationException( e );
        }

        try {
            evaluationResult = scriptEvaluator.evaluate( script, value, alias );
        }
View Full Code Here

        try {
            ScriptEvaluatorFactory evaluatorFactory = ScriptEvaluatorFactory.getInstance();
            scriptEvaluator = evaluatorFactory.getScriptEvaluatorByLanguageName( languageName );
        }
        catch ( ScriptException e ) {
            throw new ConstraintDeclarationException( e );
        }

        try {
            evaluationResult = scriptEvaluator.evaluate( script, value, alias );
        }
View Full Code Here

        try {
            ScriptEvaluatorFactory evaluatorFactory = ScriptEvaluatorFactory.getInstance();
            scriptEvaluator = evaluatorFactory.getScriptEvaluatorByLanguageName( languageName );
        }
        catch ( ScriptException e ) {
            throw new ConstraintDeclarationException( e );
        }

        try {
            evaluationResult = scriptEvaluator.evaluate( script, value, alias );
        }
View Full Code Here

    try {
      pattern = java.util.regex.Pattern.compile( parameters.regexp(), intFlag );
    }
    catch ( PatternSyntaxException e ) {
      throw new ConstraintDeclarationException( "Invalid regular expression.", e );
    }
  }
View Full Code Here

TOP

Related Classes of javax.validation.ConstraintDeclarationException

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.