MethodDescriptor.hasConstrainedParameters
Code IndexAdd Codota to your IDE (free)

Best code snippets using javax.validation.metadata.MethodDescriptor.hasConstrainedParameters(Showing top 5 results out of 315)

  • Common ways to obtain MethodDescriptor
private void myMethod () {
MethodDescriptor m =
  • BeanDescriptor beanDescriptor;beanDescriptor.getConstraintsForMethod(method.getName(), method2.getParameterTypes())
  • Smart code suggestions by Codota
}
origin: jersey/jersey

@Override
public void onValidate(final ValidationInterceptorContext ctx) {
  final Object resource = ctx.getResource();
  final Invocable resourceMethod = ctx.getInvocable();
  final Object[] args = ctx.getArgs();
  final Set<ConstraintViolation<Object>> constraintViolations = new HashSet<>();
  final BeanDescriptor beanDescriptor = getConstraintsForClass(resource.getClass());
  // Resource validation.
  if (beanDescriptor.isBeanConstrained()) {
    constraintViolations.addAll(validate(resource));
  }
  if (resourceMethod != null
      && configuration.getBootstrapConfiguration().isExecutableValidationEnabled()) {
    final Method handlingMethod = resourceMethod.getHandlingMethod();
    // Resource method validation - input parameters.
    final MethodDescriptor methodDescriptor = beanDescriptor.getConstraintsForMethod(handlingMethod.getName(),
        handlingMethod.getParameterTypes());
    if (methodDescriptor != null
        && methodDescriptor.hasConstrainedParameters()
        && validateOnExecutionHandler.validateMethod(resource.getClass(),
                               resourceMethod.getDefinitionMethod(),
                               resourceMethod.getHandlingMethod())) {
      constraintViolations.addAll(forExecutables().validateParameters(resource, handlingMethod, args));
    }
  }
  if (!constraintViolations.isEmpty()) {
    throw new ConstraintViolationException(constraintViolations);
  }
}
origin: org.apache.bval/bval-jsr

@Override
public MethodDescriptor getConstraintsForMethod(final String methodName, final Class<?>... parameterTypes) {
  if (methodName == null) {
    throw new IllegalArgumentException("Method name can't be null");
  }
  final MethodDescriptor methodDescriptor =
    meta.methodConstraints.get(methodName + Arrays.toString(parameterTypes));
  if (methodDescriptor != null
    && (methodDescriptor.hasConstrainedParameters() || methodDescriptor.hasConstrainedReturnValue())) {
    return methodDescriptor;
  }
  return null;
}
origin: br.com.caelum/vraptor

/**
 * Only accepts if method isn't parameterless and have at least one constraint.
 */
private boolean hasConstraints(ControllerMethod controllerMethod) {
  Method method = controllerMethod.getMethod();
  if (method.getParameterTypes().length == 0) {
    logger.debug("method {} has no parameters, skipping", controllerMethod);
    return false;
  }
  BeanDescriptor bean = bvalidator.getConstraintsForClass(controllerMethod.getController().getType());
  if(bean == null) {
    return false;
  }
  MethodDescriptor descriptor = bean.getConstraintsForMethod(method.getName(), method.getParameterTypes());
  return descriptor != null && descriptor.hasConstrainedParameters();
}
origin: caelum/vraptor4

/**
 * Only accepts if method isn't parameterless and have at least one constraint.
 */
private boolean hasConstraints(ControllerMethod controllerMethod) {
  Method method = controllerMethod.getMethod();
  if (method.getParameterTypes().length == 0) {
    logger.debug("method {} has no parameters, skipping", controllerMethod);
    return false;
  }
  BeanDescriptor bean = bvalidator.getConstraintsForClass(controllerMethod.getController().getType());
  if(bean == null) {
    return false;
  }
  MethodDescriptor descriptor = bean.getConstraintsForMethod(method.getName(), method.getParameterTypes());
  return descriptor != null && descriptor.hasConstrainedParameters();
}
origin: org.glassfish.jersey.ext/jersey-bean-validation

@Override
public void onValidate(final ValidationInterceptorContext ctx) {
  final Object resource = ctx.getResource();
  final Invocable resourceMethod = ctx.getInvocable();
  final Object[] args = ctx.getArgs();
  final Set<ConstraintViolation<Object>> constraintViolations = new HashSet<>();
  final BeanDescriptor beanDescriptor = getConstraintsForClass(resource.getClass());
  // Resource validation.
  if (beanDescriptor.isBeanConstrained()) {
    constraintViolations.addAll(validate(resource));
  }
  if (resourceMethod != null
      && configuration.getBootstrapConfiguration().isExecutableValidationEnabled()) {
    final Method handlingMethod = resourceMethod.getHandlingMethod();
    // Resource method validation - input parameters.
    final MethodDescriptor methodDescriptor = beanDescriptor.getConstraintsForMethod(handlingMethod.getName(),
        handlingMethod.getParameterTypes());
    if (methodDescriptor != null
        && methodDescriptor.hasConstrainedParameters()
        && validateOnExecutionHandler.validateMethod(resource.getClass(),
                               resourceMethod.getDefinitionMethod(),
                               resourceMethod.getHandlingMethod())) {
      constraintViolations.addAll(forExecutables().validateParameters(resource, handlingMethod, args));
    }
  }
  if (!constraintViolations.isEmpty()) {
    throw new ConstraintViolationException(constraintViolations);
  }
}
javax.validation.metadataMethodDescriptorhasConstrainedParameters

Popular methods of MethodDescriptor

  • getParameterDescriptors
  • hasConstrainedReturnValue
  • getName
  • getReturnValueDescriptor

Popular classes and methods

  • getExternalFilesDir (Context)
  • onCreateOptionsMenu (Activity)
  • getSharedPreferences (Context)
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables us
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • Reference (javax.naming)
  • JButton (javax.swing)

For IntelliJ IDEA and
Android Studio

  • Codota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutContact Us
  • Terms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)