原因很简单,enum类初始化失败. 因为初始化实例时, companion object还没有初始化. 引用其字段, 导致NPE, 类初始化失败, 导致ClassNotFoundException, Could not initialize class. 所以就剩下三种方式解决: 该enum用java arraySetOf该伴身方法转移到另一个类 直接把ArraySet(listOf(*suffixes))套用上每个枚举 简...
packagecom.yidoo.base.metadata.validate;importjavax.validation.ConstraintValidator;importjavax.validation.ConstraintValidatorContext;importcom.yidoo.base.metadata.cons.DictUtils;publicclassIntDictValidatorimplementsConstraintValidator<IntDict, Integer>{privateString dictName; @Overridepublicvoidinitialize(IntDict dictAnn...
// 通过名称构建缓存,通过EnumCache.findByName(StatusEnum.class,"SUCCESS",null);调用能获取枚举 EnumCache.registerByName(StatusEnum.class, StatusEnum.values()); // 通过code构建缓存,通过EnumCache.findByValue(StatusEnum.class,"S",null);调用能获取枚举 EnumCache.registerByValue(StatusEnum.class, Status...
packagecom.yidoo.base.metadata.validate;importjavax.validation.ConstraintValidator;importjavax.validation.ConstraintValidatorContext;importcom.yidoo.base.metadata.cons.DictUtils;publicclassIntDictValidatorimplementsConstraintValidator<IntDict, Integer>{privateString dictName; @Overridepublicvoidinitialize(IntDict dictAnn...
@Overridepublicvoidinitialize(Dict dictAnno) {this.dictName =dictAnno.dictName(); } @OverridepublicbooleanisValid(String value, ConstraintValidatorContext context) {if(DictUtils.isValid(dictName, value)) {returntrue; } context.disableDefaultConstraintViolation(); ...