Package com.em.validation.client.reflector

Examples of com.em.validation.client.reflector.IReflector


  public <T> Set<ConstraintViolation<T>> validate(T object, Class<?>... groups) {
    return this.validate(new HashSet<Class<?>>(), object, groups);
  }
 
  private <T> Set<ConstraintViolation<T>> validate(Set<Class<?>> previousGroups, T object, Class<?>... groups) {
    IReflector reflector = ReflectorFactory.INSTANCE.getReflector(object.getClass());
    Set<ConstraintViolation<T>> violations = new HashSet<ConstraintViolation<T>>();
    for(Class<?> group : reflector.getGroupSequence()) {
      if(previousGroups.contains(group)) {
        throw new GroupDefinitionException("The group sequence on " + object.getClass().getName() + " already contains " + group.getName() + ".  Definitions may not be cyclic or circular");
      }
     
      violations.addAll(this.coreValidator.validate(object, group));
View Full Code Here


  public <T> Set<ConstraintViolation<T>> validateProperty(T object, String propertyName, Class<?>... groups) {
    return this.validateProperty(new HashSet<Class<?>>(), object, propertyName, groups);
  }

  private <T> Set<ConstraintViolation<T>> validateProperty(Set<Class<?>> previousGroups, T object, String propertyName, Class<?>... groups) {
    IReflector reflector = ReflectorFactory.INSTANCE.getReflector(object.getClass());
    Set<ConstraintViolation<T>> violations = new HashSet<ConstraintViolation<T>>();
    for(Class<?> group : reflector.getGroupSequence()) {
      if(previousGroups.contains(group)) {
        throw new GroupDefinitionException("The group sequence on " + object.getClass().getName() + " already contains " + group.getName() + ".  Definitions may not be cyclic or circular");
      }
     
      violations.addAll(this.coreValidator.validateProperty(object, propertyName, group));
View Full Code Here

  public <T> Set<ConstraintViolation<T>> validateValue(Class<T> beanType,  String propertyName, Object value, Class<?>... groups) {
    return this.validateValue(new HashSet<Class<?>>(), beanType, propertyName, value, groups);
  }
 
  private <T> Set<ConstraintViolation<T>> validateValue(Set<Class<?>> previousGroups, Class<T> beanType,  String propertyName, Object value, Class<?>... groups) {
    IReflector reflector = ReflectorFactory.INSTANCE.getReflector(beanType);
    Set<ConstraintViolation<T>> violations = new HashSet<ConstraintViolation<T>>();
    for(Class<?> group : reflector.getGroupSequence()) {
      if(previousGroups.contains(group)) {
        throw new GroupDefinitionException("The group sequence on " + beanType.getName() + " already contains " + group.getName() + ".  Definitions may not be cyclic or circular");
      }
     
      violations.addAll(this.coreValidator.validateValue(beanType, propertyName, group));
View Full Code Here

      //create temp set
      Set<Class<?>> tempSet = new HashSet<Class<?>>(groupSet);
     
      //create deeper set and check again
      for(Class<?> group : groupSet) {
        IReflector gReflector = ReflectorFactory.INSTANCE.getReflector(group);
       
        if(gReflector != null) {
          if(gReflector.getParentReflector() != null) {
            tempSet.add(gReflector.getParentReflector().getTargetClass());
          }
         
          if(gReflector.getInterfaceReflectors() != null) {
            for(IReflector ireflector : gReflector.getInterfaceReflectors()) {
              if(ireflector != null) {
                tempSet.add(ireflector.getTargetClass());
              }
            }
          }
View Full Code Here

   
    if(groups == null) {
      throw new IllegalArgumentException("The groups list cannot be null.");
    }
   
    IReflector reflector = ReflectorFactory.INSTANCE.getReflector(object.getClass());
    if(reflector.hasGroupSequence() && (groups == null || groups.length == 0)) {
      return this.groupSequenceValidator.validate(object, groups);
    }   
    return this.coreValidator.validate(object, groups);
  }
View Full Code Here

   
    if(groups == null) {
      throw new IllegalArgumentException("The groups list cannot be null.");
    }

    IReflector reflector = ReflectorFactory.INSTANCE.getReflector(object.getClass());
    if(reflector.hasGroupSequence() && (groups == null || groups.length == 0)) {
      return this.groupSequenceValidator.validateProperty(object, propertyName, groups);
    }   
    return this.coreValidator.validateProperty(object, propertyName, groups);
  }
View Full Code Here

   
    if(groups == null) {
      throw new IllegalArgumentException("The groups list cannot be null.");
    }
   
    IReflector reflector = ReflectorFactory.INSTANCE.getReflector(beanType);
    if(reflector.hasGroupSequence() && (groups == null || groups.length == 0)) {
      return this.groupSequenceValidator.validateValue(beanType, propertyName, value, groups);
    }   
    return this.coreValidator.validateValue(beanType, propertyName, value, groups);

  }
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  private <T> Set<ConstraintViolation<T>> validateProperty(Map<Class<?>,Map<String,Map<Object,Set<ConstraintViolation<?>>>>> validationCache, T object, String propertyName, Class<?>... groups) {
    //get reflector to get property value
    IReflector reflector = ReflectorFactory.INSTANCE.getReflector((Class<T>)object.getClass());
   
    if(!reflector.getPropertyNames().contains(propertyName)) {
      throw new IllegalArgumentException("Bean type " + object.getClass().getName() + " does not contain property " + propertyName);
    }
   
    Object value = reflector.getValue(propertyName, object);

    //create path for this level
    PathImpl path = new PathImpl();
    NodeImpl localNode = new NodeImpl();
    localNode.setName(propertyName);
View Full Code Here

 
  @SuppressWarnings({ "unchecked", "rawtypes" })
  private <T> Set<ConstraintViolation<T>> validateValue(Map<Class<?>,Map<String,Map<Object,Set<ConstraintViolation<?>>>>> validationCache, Class<T> beanType, String propertyName, Object value, Class<?>... groups) {
   
    //get reflector to get property value
    IReflector reflector = ReflectorFactory.INSTANCE.getReflector(beanType);
   
    if(!reflector.getPropertyNames().contains(propertyName)) {
      throw new IllegalArgumentException("Bean type " + beanType.getName() + " does not contain property " + propertyName);
    }
   
    //create path for this level
    PathImpl path = new PathImpl();
View Full Code Here

TOP

Related Classes of com.em.validation.client.reflector.IReflector

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.