private void initClassConstraints(
      Class<?> clazz, AnnotationIgnores annotationIgnores, BeanMetaDataCache beanMetaDataCache) {
    if (annotationIgnores.isIgnoreAnnotations(clazz)) {
      return;
    }

    // HV-262
    BeanMetaDataImpl<?> cachedMetaData = beanMetaDataCache.getBeanMetaData(clazz);
    List<ConstraintDescriptorImpl<?>> classMetaData;
    if (cachedMetaData != null && cachedMetaData.getMetaConstraintsAsMap().get(clazz) != null) {
      classMetaData = new ArrayList<ConstraintDescriptorImpl<?>>();
      for (MetaConstraint<?> metaConstraint : cachedMetaData.getMetaConstraintsAsMap().get(clazz)) {
        ConstraintDescriptorImpl<?> descriptor = metaConstraint.getDescriptor();
        if (descriptor.getElementType() == ElementType.TYPE) {
          classMetaData.add(descriptor);
        }
      }
    } else {
      classMetaData = findClassLevelConstraints(clazz);
    }

    for (ConstraintDescriptorImpl<?> constraintDescription : classMetaData) {
      BeanMetaConstraint<?> metaConstraint =
          createBeanMetaConstraint(clazz, null, constraintDescription);
      addMetaConstraint(clazz, metaConstraint);
    }
  }
  private void initFieldConstraints(
      Class<?> clazz, AnnotationIgnores annotationIgnores, BeanMetaDataCache beanMetaDataCache) {
    final Field[] fields = ReflectionHelper.getDeclaredFields(clazz);
    for (Field field : fields) {
      addToPropertyNameList(field);

      // HV-172
      if (Modifier.isStatic(field.getModifiers())) {
        continue;
      }

      if (annotationIgnores.isIgnoreAnnotations(field)) {
        continue;
      }

      // HV-262
      BeanMetaDataImpl<?> cachedMetaData = beanMetaDataCache.getBeanMetaData(clazz);
      boolean metaDataCached = cachedMetaData != null;
      List<ConstraintDescriptorImpl<?>> fieldMetaData;
      if (metaDataCached && cachedMetaData.getMetaConstraintsAsMap().get(clazz) != null) {
        fieldMetaData = new ArrayList<ConstraintDescriptorImpl<?>>();
        for (BeanMetaConstraint<?> metaConstraint :
            cachedMetaData.getMetaConstraintsAsMap().get(clazz)) {
          ConstraintDescriptorImpl<?> descriptor = metaConstraint.getDescriptor();
          if (descriptor.getElementType() == ElementType.FIELD
              && metaConstraint
                  .getLocation()
                  .getPropertyName()
                  .equals(ReflectionHelper.getPropertyName(field))) {
            fieldMetaData.add(descriptor);
          }
        }
      } else {
        fieldMetaData = findConstraints(field, ElementType.FIELD);
      }

      for (ConstraintDescriptorImpl<?> constraintDescription : fieldMetaData) {
        ReflectionHelper.setAccessibility(field);
        BeanMetaConstraint<?> metaConstraint =
            createBeanMetaConstraint(clazz, field, constraintDescription);
        addMetaConstraint(clazz, metaConstraint);
      }

      // HV-433 Make sure the field is marked as cascaded in case it was configured via
      // xml/programmatic API or
      // it hosts the @Valid annotation
      boolean isCascadedField =
          metaDataCached && cachedMetaData.getCascadedMembers().contains(field);
      if (isCascadedField || field.isAnnotationPresent(Valid.class)) {
        addCascadedMember(field);
      }
    }
  }
  private MethodMetaData getFromCache(
      Class<?> clazz, Method method, BeanMetaDataCache beanMetaDataCache) {
    BeanMetaDataImpl<?> cachedBeanMetaData = beanMetaDataCache.getBeanMetaData(clazz);

    if (cachedBeanMetaData != null) {
      AggregatedMethodMetaData cachedMethodMetaData = cachedBeanMetaData.getMetaDataFor(method);

      if (cachedMethodMetaData != null) {
        return cachedMethodMetaData.getSingleMetaDataFor(method);
      }
    }

    return null;
  }