根据注册器以及类获取所有需要被验证的属性，封装为<code>AnnotationValidator</code>列表返回

@param registry 验证器对象寻找注册器
@param clazz    待验证类定义

@return <code>AnnotationValidator</code>列表
336613
private static List<AnnotationValidator> getAllAnnotationValidators(Registry registry, Class<?> clazz) {
        List<AnnotationValidator> annotationValidators = CollectionUtil.createArrayList();

        Field[] fields = ReflectionUtil.getAnnotationFields(clazz, FluentValidate.class);
        for (int i = 0; i < fields.length; i++) {
            Field field = fields[i];
            FluentValidate fluentValidateAnnt = ReflectionUtil.getAnnotation(field, FluentValidate.class);

            Class<? extends Validator>[] validatorClasses = fluentValidateAnnt.value();
            Class<?>[] groups = fluentValidateAnnt.groups();
            if (validatorClasses == null || validatorClasses.length == 0) {
                LOGGER.debug(String.format("No validator annotation bound %s#%s", clazz.getSimpleName(),
                        field.getName()));
                continue;
            }

            List<Validator> validators = CollectionUtil.createArrayList(4);
            for (Class<? extends Validator> validatorClass : validatorClasses) {
                if (!Validator.class.isAssignableFrom(validatorClass)) {
                    LOGGER.warn(String.format("Validator annotation class %s is not assignable from %s",
                            validatorClass.getSimpleName(), Validator.class.getSimpleName()));
                    continue;
                }
                if (!VALIDATOR_MAP.containsKey(validatorClass)) {
                    List<? extends Validator> validatorsFound = registry.findByType(validatorClass);
                    if (CollectionUtil.isEmpty(validatorsFound)) {
                        LOGGER.warn(String.format("Validator annotation class %s not found or init failed for "
                                + "%s#%s", validatorClass.getSimpleName(), clazz.getSimpleName(), field.getName()));
                        continue;
                    }
                    if (validatorsFound.size() > 1) {
                        LOGGER.warn(String.format(
                                "Validator annotation class %s found multiple instances for %s#%s, so the first "
                                        + "one will be used",
                                validatorClass.getSimpleName(), clazz.getSimpleName(), field.getName()));
                    }
                    VALIDATOR_MAP.putIfAbsent(validatorClass, validatorsFound.get(0));
                    LOGGER.info(String.format("Cached validator %s", validatorClass.getSimpleName()));
                }
                validators.add(VALIDATOR_MAP.get(validatorClass));
            }

            if (CollectionUtil.isEmpty(validators)) {
                LOGGER.debug(String.format("Annotation-based validation enabled but none of the validators is "
                        + "applicable for %s#%s", clazz.getSimpleName(), field.getName()));
                continue;
            }

            AnnotationValidator av = new AnnotationValidator();
            av.setField(field);
            av.setMethod(ReflectionUtil.getGetterMethod(clazz, field));
            av.setValidators(validators);
            av.setGroups(groups);
            annotationValidators.add(av);
            LOGGER.trace("Annotation-based validation added " + av);
        }

        fields = ReflectionUtil.getAnnotationFields(clazz, FluentValid.class);
        for (int i = 0; i < fields.length; i++) {
            Field field = fields[i];
            FluentValid cascadeAnnt = ReflectionUtil.getAnnotation(field, FluentValid.class);

            AnnotationValidator av = new AnnotationValidator();
            av.setField(field);
            av.setMethod(ReflectionUtil.getGetterMethod(clazz, field));
            av.setValidators(null);
            av.setGroups(null);
            av.setIsCascade(cascadeAnnt != null);
            annotationValidators.add(av);
            LOGGER.trace("Cascade annotation-based validation added " + av);
        }

        return annotationValidators;
    }
942859
private boolean checkValidClass(Class<?> clazz) {
        return clazz.isAnnotationPresent(Entity.class) || clazz.isAnnotationPresent(MappedSuperclass.class)
            || clazz.isAnnotationPresent(Embeddable.class);

    }
261689
public Annotator getAnnotator(Class<? extends Annotator> clazz) {

        if (!Annotator.class.isAssignableFrom(clazz)) {
            throw new IllegalArgumentException("The class name given as a custom annotator (" + clazz.getName() + ") does not refer to a class that implements " + Annotator.class.getName());
        }

        try {
            try {
                Constructor<? extends Annotator> constructor = clazz.getConstructor(GenerationConfig.class);
                return constructor.newInstance(generationConfig);
            } catch (NoSuchMethodException e) {
                return clazz.newInstance();
            }
        } catch (InvocationTargetException | InstantiationException e) {
            throw new IllegalArgumentException("Failed to create a custom annotator from the given class. An exception was thrown on trying to create a new instance.", e.getCause());
        } catch (IllegalAccessException e) {
            throw new IllegalArgumentException("Failed to create a custom annotator from the given class. It appears that we do not have access to this class - is both the class and its no-arg constructor marked public?", e);
        }

    }
108055
public <T> CFMappingDef<T> initializeCacheForClass(Class<T> clazz) {
    CFMappingDef<T> cfMapDef = initializeColumnFamilyMapDef(clazz);
    try {
      initializePropertiesMapDef(cfMapDef);
    } catch (IntrospectionException e) {
      throw new HectorObjectMapperException(e);
    } catch (InstantiationException e) {
      throw new HectorObjectMapperException(e);
    } catch (IllegalAccessException e) {
      throw new HectorObjectMapperException(e);
    }

    // by the time we get here, all super classes and their annotations have
    // been processed and validated, and all annotations for this class have
    // been processed. what's left to do is validate this class, set super
    // classes, and and set any defaults
    checkMappingAndSetDefaults(cfMapDef);

    // if this class is not a derived class, then map the ColumnFamily name
    if (!cfMapDef.isDerivedEntity()) {
      cfMapByColFamName.put(cfMapDef.getEffectiveColFamName(), cfMapDef);
    }

    // always map the parsed class to its ColumnFamily map definition
    cfMapByClazz.put(cfMapDef.getRealClass(), cfMapDef);

    return cfMapDef;
  }
853836
static <T extends Annotation> T findAnnotation(Method method, Class<T> clazz) {
		T annotation = AnnotationUtils.findAnnotation(method, clazz);
		if (annotation == null) {
			try {
				annotation = AnnotationUtils.findAnnotation(method.getDeclaringClass()
						.getMethod(method.getName(), method.getParameterTypes()), clazz);
			}
			catch (NoSuchMethodException | SecurityException ex) {
				if (log.isDebugEnabled()) {
					log.debug("Exception occurred while tyring to find the annotation",
							ex);
				}
			}
		}
		return annotation;
	}
1003916
static Class<?> validateElementType(Class<?> clazz) {
        if (clazz.isEnum()) {
            return clazz;
        }
        if (supportedElementTypes.containsKey(clazz)) {
            return clazz;
        }
        throw new IllegalArgumentException("Parameter type '" + clazz.getName() + "' is not supported.");
    }
1026497
public static <T extends Annotation> Set<Method> getAnnotatedPublicMethods(Class<?> clazz, Class<T> annotation) {
		// 已递归到Objebt.class, 停止递归
		if (Object.class.equals(clazz)) {
			return Collections.emptySet();
		}

		List<Class<?>> ifcs = ClassUtils.getAllInterfaces(clazz);
		Set<Method> annotatedMethods = new HashSet<Method>();

		// 遍历当前类的所有公共方法
		Method[] methods = clazz.getMethods();

		for (Method method : methods) {
			// 如果当前方法有标注，或定义了该方法的所有接口有标注
			if (method.getAnnotation(annotation) != null || searchOnInterfaces(method, annotation, ifcs)) {
				annotatedMethods.add(method);
			}
		}

		return annotatedMethods;
	}
210654
public String getTypeName(Class<?> clazz) {
		Type type = typeAnnotations.get(clazz);

		if (type != null) {
			return type.value();
		}
		return null;
	}
861781
public static String generatedNameOf(Class<?> clazz, Class<? extends Annotation> annotationClass)
    {
        return builder(clazz, annotationClass).build();
    }
1112086
public static CustomPropertyDescriptor[] getPropertyDescriptors(Class<?> clazz) throws NullPointerException {
        if (clazz == null) {
            throw new NullPointerException("clazz为null");
        }
        // 首先从缓存中检查
        CustomPropertyDescriptor[] descriptors = CACHE.get(clazz);
        if (descriptors != null) {
            log.debug("获取Class {} 的说明时发现缓存中有，取出缓存中的说明返回", clazz);
            return descriptors;
        }

        Field[] fields = getAllFields(clazz);

        descriptors = new CustomPropertyDescriptor[fields.length];
        if (fields.length == 0) {
            log.debug("源{}中不存在已经声明的字段", clazz.getName());
            CACHE.put(clazz, descriptors);
            return descriptors;
        }

        int j = 0;
        for (Field field : fields) {
            CustomPropertyDescriptor descriptor = buildDescriptor(field, clazz);
            if (descriptor != null) {
                descriptors[j++] = descriptor;
            }
        }

        if (j < descriptors.length) {
            log.debug("构建构成中发生了异常，数组中有null，除去null");
            CustomPropertyDescriptor[] propertyDescriptor = new CustomPropertyDescriptor[j];
            System.arraycopy(descriptors, 0, propertyDescriptor, 0, j);
            CACHE.put(clazz, propertyDescriptor);
            return propertyDescriptor;
        } else {
            log.debug("构建没有异常，构建成功");
            CACHE.put(clazz, descriptors);
            return descriptors;
        }
    }
487900
public static <A extends Annotation> A findAnnotation(Class<?> clazz, Class<A> annotationType) {
		if (clazz == null) throw new IllegalArgumentException("Clazz parameter can't be null");
		
		A annotation = clazz.getAnnotation(annotationType);
		if (annotation != null) return annotation;
		
		for (Class<?> ifc : clazz.getInterfaces()) {
			annotation = findAnnotation(ifc, annotationType);
			if (annotation != null) return annotation;
		}
		
		if (!Annotation.class.isAssignableFrom(clazz))
			for (Annotation ann : clazz.getAnnotations()) {
				annotation = findAnnotation(ann.annotationType(), annotationType);
				if (annotation != null) return annotation;
			}
		
		Class<?> superClass = clazz.getSuperclass();
		if (superClass == null || superClass == Object.class) return null;
		return findAnnotation(superClass, annotationType);
	}
83333
private static Map<String, PropertyAccessor> _getAccessors(
                    final Class<?> clazz
                    )
    {
        Map<String, PropertyAccessor>  accessors = null;

        synchronized (_ACCESSORS_REG_) {
            accessors = _ACCESSORS_REG_.get( clazz );
            if (accessors == null) {
                accessors = PropertyAccessor.findAll( clazz );
                _ACCESSORS_REG_.put( clazz, accessors );
            }
        }

        return accessors;
    }
306402
public static String getTypeName(Class<?> clazz) {
		Type typeAnnotation = clazz.getAnnotation(Type.class);
		return typeAnnotation != null ? typeAnnotation.value() : null;
	}
791697
public static boolean hasAnnotation(CtClass clazz, String annotationName) {
        ClassFile cf = clazz.getClassFile2();
        AnnotationsAttribute ainfo = (AnnotationsAttribute)
            cf.getAttribute(AnnotationsAttribute.invisibleTag);
        AnnotationsAttribute ainfo2 = (AnnotationsAttribute)
            cf.getAttribute(AnnotationsAttribute.visibleTag);
        return checkAnnotation(ainfo, ainfo2, annotationName);
    }
840502
@SuppressWarnings("unchecked")
    public <T> List<T> getAnnotations(final Class<? extends Annotation> clazz) {
        return (List<T>) foundAnnotations.get(clazz);
    }
585852
public static void initEN16931 (@Nonnull final ValidationExecutorSetRegistry aRegistry)
  {
    ValueEnforcer.notNull (aRegistry, "Registry");

    // For better error messages
    LocationBeautifierSPI.addMappings (UBL21NamespaceContext.getInstance ());
    LocationBeautifierSPI.addMappings (CIID16BNamespaceContext.getInstance ());

    final boolean bDeprecated = true;
    final boolean bNotDeprecated = false;

    aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_CII_100,
                                                                           "EN 16931 CII " + VID_CII_100.getVersion (),
                                                                           bDeprecated,
                                                                           ValidationExecutorXSD.create (ECIID16BDocumentType.CROSS_INDUSTRY_INVOICE),
                                                                           new ValidationExecutorSchematron (new ValidationArtefact (EValidationType.SCHEMATRON_XSLT,
                                                                                                                                     _getCL (),
                                                                                                                                     INVOICE_CII_100_XSLT),
                                                                                                             null,
                                                                                                             CIID16BNamespaceContext.getInstance ())));
    aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_CII_110,
                                                                           "EN 16931 CII " + VID_CII_110.getVersion (),
                                                                           bDeprecated,
                                                                           ValidationExecutorXSD.create (ECIID16BDocumentType.CROSS_INDUSTRY_INVOICE),
                                                                           new ValidationExecutorSchematron (new ValidationArtefact (EValidationType.SCHEMATRON_XSLT,
                                                                                                                                     _getCL (),
                                                                                                                                     INVOICE_CII_110_XSLT),
                                                                                                             null,
                                                                                                             CIID16BNamespaceContext.getInstance ())));
    aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_CII_120,
                                                                           "EN 16931 CII " + VID_CII_120.getVersion (),
                                                                           bNotDeprecated,
                                                                           ValidationExecutorXSD.create (ECIID16BDocumentType.CROSS_INDUSTRY_INVOICE),
                                                                           new ValidationExecutorSchematron (new ValidationArtefact (EValidationType.SCHEMATRON_XSLT,
                                                                                                                                     _getCL (),
                                                                                                                                     INVOICE_CII_120_XSLT),
                                                                                                             null,
                                                                                                             CIID16BNamespaceContext.getInstance ())));

    aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_EDIFACT_100,
                                                                           "EN 16931 EDIFACT/ISO 20625 " +
                                                                                            VID_EDIFACT_100.getVersion (),
                                                                           bNotDeprecated,
                                                                           ValidationExecutorXSD.create (new JAXBDocumentType (MINVOIC.class,
                                                                                                                               new CommonsArrayList <> (new ClassPathResource ("/schemas/INVOIC_D14B_ISO20625.xsd",
                                                                                                                                                                               _getCL ())),
                                                                                                                               null)),
                                                                           new ValidationExecutorSchematron (new ValidationArtefact (EValidationType.SCHEMATRON_XSLT,
                                                                                                                                     _getCL (),
                                                                                                                                     INVOICE_EDIFACT_100_XSLT),
                                                                                                             null,
                                                                                                             null)));

    // Pure is quicker than XSLT
    aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_UBL_INVOICE_100,
                                                                           "EN 16931 UBL Invoice " +
                                                                                                VID_UBL_INVOICE_100.getVersion (),
                                                                           bDeprecated,
                                                                           ValidationExecutorXSD.create (EUBL21DocumentType.INVOICE),
                                                                           new ValidationExecutorSchematron (new ValidationArtefact (EValidationType.SCHEMATRON_XSLT,
                                                                                                                                     _getCL (),
                                                                                                                                     INVOICE_UBL_100_XSLT),
                                                                                                             null,
                                                                                                             UBL21NamespaceContext.getInstance ())));
    aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_UBL_CREDIT_NOTE_100,
                                                                           "EN 16931 UBL CreditNote " +
                                                                                                    VID_UBL_CREDIT_NOTE_100.getVersion (),
                                                                           bDeprecated,
                                                                           ValidationExecutorXSD.create (EUBL21DocumentType.CREDIT_NOTE),
                                                                           new ValidationExecutorSchematron (new ValidationArtefact (EValidationType.SCHEMATRON_XSLT,
                                                                                                                                     _getCL (),
                                                                                                                                     INVOICE_UBL_110_XSLT),
                                                                                                             null,
                                                                                                             UBL21NamespaceContext.getInstance ())));
    aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_UBL_INVOICE_110,
                                                                           "EN 16931 UBL Invoice " +
                                                                                                VID_UBL_INVOICE_110.getVersion (),
                                                                           bDeprecated,
                                                                           ValidationExecutorXSD.create (EUBL21DocumentType.INVOICE),
                                                                           new ValidationExecutorSchematron (new ValidationArtefact (EValidationType.SCHEMATRON_XSLT,
                                                                                                                                     _getCL (),
                                                                                                                                     INVOICE_UBL_110_XSLT),
                                                                                                             null,
                                                                                                             UBL21NamespaceContext.getInstance ())));
    aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_UBL_CREDIT_NOTE_110,
                                                                           "EN 16931 UBL CreditNote " +
                                                                                                    VID_UBL_CREDIT_NOTE_110.getVersion (),
                                                                           bDeprecated,
                                                                           ValidationExecutorXSD.create (EUBL21DocumentType.CREDIT_NOTE),
                                                                           new ValidationExecutorSchematron (new ValidationArtefact (EValidationType.SCHEMATRON_XSLT,
                                                                                                                                     _getCL (),
                                                                                                                                     INVOICE_UBL_110_XSLT),
                                                                                                             null,
                                                                                                             UBL21NamespaceContext.getInstance ())));
    aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_UBL_INVOICE_120,
                                                                           "EN 16931 UBL Invoice " +
                                                                                                VID_UBL_INVOICE_120.getVersion (),
                                                                           bNotDeprecated,
                                                                           ValidationExecutorXSD.create (EUBL21DocumentType.INVOICE),
                                                                           new ValidationExecutorSchematron (new ValidationArtefact (EValidationType.SCHEMATRON_XSLT,
                                                                                                                                     _getCL (),
                                                                                                                                     INVOICE_UBL_120_XSLT),
                                                                                                             null,
                                                                                                             UBL21NamespaceContext.getInstance ())));
    aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_UBL_CREDIT_NOTE_120,
                                                                           "EN 16931 UBL CreditNote " +
                                                                                                    VID_UBL_CREDIT_NOTE_120.getVersion (),
                                                                           bNotDeprecated,
                                                                           ValidationExecutorXSD.create (EUBL21DocumentType.CREDIT_NOTE),
                                                                           new ValidationExecutorSchematron (new ValidationArtefact (EValidationType.SCHEMATRON_XSLT,
                                                                                                                                     _getCL (),
                                                                                                                                     INVOICE_UBL_120_XSLT),
                                                                                                             null,
                                                                                                             UBL21NamespaceContext.getInstance ())));
  }
367896
public FluentValidator doValidate(ValidateCallback cb) {
        Preconditions.checkNotNull(cb, "ValidateCallback should not be NULL");
        if (validatorElementList.isEmpty()) {
            LOGGER.debug("Nothing to validate");
            return this;
        }
        context.setResult(result);

        LOGGER.debug("Start to validate through " + validatorElementList);
        long start = System.currentTimeMillis();
        try {
            GroupingHolder.setGrouping(groups);
            for (ValidatorElement element : validatorElementList.getAllValidatorElements()) {
                Object target = element.getTarget();
                Validator v = element.getValidator();
                try {
                    if (v.accept(context, target)) {
                        if (!v.validate(context, target)) {
                            result.setIsSuccess(false);
                            if (isFailFast) {
                                break;
                            }
                        }
                    }
                } catch (Exception e) {
                    try {
                        v.onException(e, context, target);
                        cb.onUncaughtException(v, e, target);
                    } catch (Exception e1) {
                        if (LOGGER.isDebugEnabled()) {
                            LOGGER.error(v + " onException or onUncaughtException throws exception due to " + e1
                                    .getMessage(), e1);
                        }
                        throw new RuntimeValidateException(e1);
                    }
                    if (LOGGER.isDebugEnabled()) {
                        LOGGER.error(v + " failed due to " + e.getMessage(), e);
                    }
                    throw new RuntimeValidateException(e);
                }
            }

            if (result.isSuccess()) {
                cb.onSuccess(validatorElementList);
            } else {
                cb.onFail(validatorElementList, result.getErrors());
            }
        } finally {
            GroupingHolder.clean();
            int timeElapsed = (int) (System.currentTimeMillis() - start);
            LOGGER.debug("End to validate through" + validatorElementList + " costing " + timeElapsed + "ms with "
                    + "isSuccess=" + result.isSuccess());
            result.setTimeElapsed(timeElapsed);
        }
        return this;
    }