Package javax.validation

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


      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

    public void addGroupConversion(final GroupConversionDescriptor descriptor) {
        groupConversions.add(descriptor);
        final Group from = new Group(descriptor.getFrom());
        if (mapGroup(from) != from) { // ref == is fine
            throw new ConstraintDeclarationException("You can't map twice from the same group");
        }
        addGroupMapping(from, new Group(descriptor.getTo()));
    }
View Full Code Here

        addXmlConstraints(beanClass, metabean);

        for (final String name : missingValid) {
            final MetaProperty metaProperty = metabean.getProperty(name);
            if (metaProperty != null && metaProperty.getFeature(JsrFeatures.Property.REF_CASCADE) == null) {
                throw new ConstraintDeclarationException("@ConvertGroup needs @Valid");
            }
        }
        missingValid.clear();
    }
View Full Code Here

        }
    }

    private static void checkValidationAppliesTo(final ConstraintTarget configured, final ConstraintTarget forbidden) {
        if (forbidden.equals(configured)) {
            throw new ConstraintDeclarationException(forbidden.name() + " forbidden here");
        }
    }
View Full Code Here

            // Search for the overrides to apply
            ConstraintOverrides generalOverride = findOverride(composite.getAnnotation().annotationType(), -1);
            if (generalOverride != null) {
                if (index > 0) {
                    throw new ConstraintDeclarationException("Wrong OverridesAttribute declaration for "
                        + generalOverride.constraintType
                        + ", it needs a defined index when there is a list of constraints");
                }
                generalOverride.applyOn(composite);
            }
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

  public void initialize(DecimalMin minValue) {
    try {
      this.minValue = new BigDecimal( minValue.value() );
    }
    catch ( NumberFormatException nfe ) {
      throw new ConstraintDeclarationException( minValue.value() + " does not represent a valid BigDemcimal formt" );
    }
  }
View Full Code Here

  public void initialize(DecimalMin minValue) {
    try {
      this.minValue = new BigDecimal( minValue.value() );
    }
    catch ( NumberFormatException nfe ) {
      throw new ConstraintDeclarationException( minValue.value() + " does not represent a valid BigDemcimal formt" );
    }
  }
View Full Code Here

  public void initialize(DecimalMax maxValue) {
    try {
      this.maxValue = new BigDecimal( maxValue.value() );
    }
    catch ( NumberFormatException nfe ) {
      throw new ConstraintDeclarationException( maxValue.value() + " does not represent a valid BigDemcimal formt" );
    }
  }
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.