当前位置: 首页>>代码示例>>Java>>正文


Java UnwrapValidatedValue类代码示例

本文整理汇总了Java中org.hibernate.validator.valuehandling.UnwrapValidatedValue的典型用法代码示例。如果您正苦于以下问题:Java UnwrapValidatedValue类的具体用法?Java UnwrapValidatedValue怎么用?Java UnwrapValidatedValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


UnwrapValidatedValue类属于org.hibernate.validator.valuehandling包,在下文中一共展示了UnwrapValidatedValue类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkAnnotations

import org.hibernate.validator.valuehandling.UnwrapValidatedValue; //导入依赖的package包/类
private void checkAnnotations(Class<?> contractClass) {
    Field[] fields = contractClass.getFields();
    for (Field field : fields) {
        Class fieldType = field.getType();
        if (Optional.class.isAssignableFrom(fieldType)) {
            checkAnnotation(contractClass, field,UnwrapValidatedValue.class);
            checkNoAnnotation(contractClass, field, NotNull.class);
        }
        else {
            checkNoAnnotation(contractClass, field, UnwrapValidatedValue.class);
            checkAnnotation(contractClass, field,NotNull.class);
        }
    }

    for(Method method : contractClass.getMethods()) {
        if(method.isAnnotationPresent(AssertTrue.class) || method.isAnnotationPresent(AssertFalse.class)) {
            if(method.getReturnType() != boolean.class && method.getReturnType() != Boolean.class) {
                throw new IllegalStateException("AssertTrue or AssertFalse annotations must be placed above methods that return boolean value");
            }

            if(!method.getName().startsWith("is")) {
                throw new IllegalStateException("Methods annotated with AssertTrue or AssertFalse must start with \"is\"");
            }
        }
    }
}
 
开发者ID:forter,项目名称:storm-data-contracts,代码行数:27,代码来源:ContractsBoltReflector.java


注:本文中的org.hibernate.validator.valuehandling.UnwrapValidatedValue类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。