Package org.hibernate.validator.method

Examples of org.hibernate.validator.method.MethodConstraintViolationException


      Set<MethodConstraintViolation<Object>> violations = validator.unwrap(MethodValidator.class).validateAllParameters(ctx.getTarget(), ctx.getMethod(), ctx.getParameters());

      if (!violations.isEmpty())
      {
         throw new MethodConstraintViolationException(getMessage(ctx.getMethod(), ctx.getParameters(), violations), violations);
      }

      Object result = ctx.proceed();

      violations = validator.unwrap(MethodValidator.class).validateReturnValue(ctx.getTarget(), ctx.getMethod(), result);

      if (!violations.isEmpty())
      {
         throw new MethodConstraintViolationException(getMessage(ctx.getMethod(), ctx.getParameters(), violations), violations);
      }

      return result;
   }
View Full Code Here


  public Object invoke(MethodInvocation invocation) throws Throwable {
    Class[] groups = determineValidationGroups(invocation);
    Set<MethodConstraintViolation<Object>> result = this.validator.validateAllParameters(
        invocation.getThis(), invocation.getMethod(), invocation.getArguments(), groups);
    if (!result.isEmpty()) {
      throw new MethodConstraintViolationException(result);
    }
    Object returnValue = invocation.proceed();
    result = this.validator.validateReturnValue(
        invocation.getThis(), invocation.getMethod(), returnValue, groups);
    if (!result.isEmpty()) {
      throw new MethodConstraintViolationException(result);
    }
    return returnValue;
  }
View Full Code Here

  public Object invoke(MethodInvocation invocation) throws Throwable {
    Class[] groups = determineValidationGroups(invocation);
    Set<MethodConstraintViolation<Object>> result = this.validator.validateAllParameters(
        invocation.getThis(), invocation.getMethod(), invocation.getArguments(), groups);
    if (!result.isEmpty()) {
      throw new MethodConstraintViolationException(result);
    }
    Object returnValue = invocation.proceed();
    result = this.validator.validateReturnValue(
        invocation.getThis(), invocation.getMethod(), returnValue, groups);
    if (!result.isEmpty()) {
      throw new MethodConstraintViolationException(result);
    }
    return returnValue;
  }
View Full Code Here

    System.out.println("s = " + s);
  }

  @Override
  public void bar() throws ValidationException {
    throw new MethodConstraintViolationException(
        Collections.singleton(new MethodConstraintViolationImpl<MethodConstraintViolation<?>>(
            null, null, null, null, null, null, null, null, null, null, null,
            null)));
  }
View Full Code Here

  }

  @AfterThrowing(value = "validated()", throwing = "t")
  public void invoke(Throwable t) throws ValidationException {
    if (t instanceof MethodConstraintViolationException) {
      MethodConstraintViolationException methodConstraintViolationException = (MethodConstraintViolationException) t;
      throw new ValidationException(methodConstraintViolationException);
    }

  }
View Full Code Here

TOP

Related Classes of org.hibernate.validator.method.MethodConstraintViolationException

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.