Examples of ConstraintDeclarationException


Examples of javax.validation.ConstraintDeclarationException

        }

        private void ensureMethodDoesntDefineParameterConstraint(MethodDescriptorImpl methodDesc) {
            for (final ParameterDescriptor pd : methodDesc.getParameterDescriptors()) {
                if (!pd.getConstraintDescriptors().isEmpty()) {
                    throw new ConstraintDeclarationException("child shouldn't get more constraint than parent");
                }
                if (pd.isCascaded()) { // @Valid
                    throw new ConstraintDeclarationException("child shouldn't get more constraint than parent");
                }
            }
        }
View Full Code Here

Examples of javax.validation.ConstraintDeclarationException

                return;
            }

            final ReturnValueDescriptor parentReturnDesc = parentMtdDesc.getReturnValueDescriptor();
            if (parentReturnDesc.isCascaded() && !returnValueDescriptor.isCascaded() || parentReturnDesc.getConstraintDescriptors().size() > returnValueDescriptor.getConstraintDescriptors().size()) {
                throw new ConstraintDeclarationException(msg);
            }
        }
View Full Code Here

Examples of javax.validation.ConstraintDeclarationException

        }

        private static void ensureNoParameterConstraint(final InvocableElementDescriptor constraintsForMethod, final String msg) {
            for (final ParameterDescriptor parameterDescriptor : constraintsForMethod.getParameterDescriptors()) {
                if (!parameterDescriptor.getConstraintDescriptors().isEmpty() || parameterDescriptor.isCascaded()) {
                    throw new ConstraintDeclarationException(msg);
                }
            }
        }
View Full Code Here

Examples of javax.validation.ConstraintDeclarationException

        private static void ensureNoConvertGroup(final Method method, final String msg) {
            for (final Annotation[] annotations : method.getParameterAnnotations()) {
                for (final Annotation a : annotations) {
                    if (ConvertGroup.class.isInstance(a)) {
                        throw new ConstraintDeclarationException(msg);
                    }
                }
            }
            if (method.getAnnotation(ConvertGroup.class) != null) {
                throw new ConstraintDeclarationException(msg);
            }
        }
View Full Code Here

Examples of javax.validation.ConstraintDeclarationException

            if (paramDesc.isCascaded() && from != null) {
                for (int i = 0; i < from.length; i++) {
                    paramDesc.addGroupConversion(new GroupConversionDescriptorImpl(from[i], to[i]));
                }
            } else if (from != null) {
                throw new ConstraintDeclarationException("Group conversion is only relevant for @Valid cases");
            }

            return validations;
        }
View Full Code Here

Examples of javax.validation.ConstraintDeclarationException

  private ScriptEvaluator createNewScriptEvaluator(String languageName) {

    ScriptEngine engine = new ScriptEngineManager().getEngineByName( languageName );

    if ( engine == null ) {
      throw new ConstraintDeclarationException(
          "No JSR 223 script engine found for language \"" + languageName + "\"."
      );
    }

    return new ScriptEvaluator( engine );
View Full Code Here

Examples of javax.validation.ConstraintDeclarationException

    try {
      evaluationResult = engine.eval( script );
    }
    catch ( ScriptException e ) {
      throw new ConstraintDeclarationException(
          "Error during execution of script \"" + script + "\" occured.", 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

Examples of javax.validation.ConstraintDeclarationException

      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

Examples of javax.validation.ConstraintDeclarationException

      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

Examples of javax.validation.ConstraintDeclarationException

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

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

      return new ExecutableMetaData(
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.