我有一个自定义注释如下.
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE,ElementType.METHOD })
@Documented
@Conditional(OnApiVersionConditional.class)
public @interface ConditionalOnApiVersion {
int[] value() default 5;
String property();
}
OnApiVersionConditional是,
public class OnApiVersionConditional implements Condition {
@Override
public boolean matches(final ConditionContext context,final AnnotatedTypeMetadata Metadata) {
final MultiValueMapMetadata.getAllAnnotationAttributes(ConditionalOnApiVersion.class.getName());
attributes.get("value");
final String inputVersion = context.getEnvironment().getProperty("userInputVersion");
}
在我的Bean注释中,
@Bean
@ConditionalOnApiVersion(value = {6,7},property = "userInputVersion")
还有像单一版本匹配的bean
@Bean
@ConditionalOnApiVersion(value = 8,property = "userInputVersion")
我想验证属性文件中的userInput版本到可用的Beans支持版本.不确定,如何获取值,迭代并与userInoutVersion进行比较.该值可以是8或{6,7}作为int数组.不确定,如何迭代该值以检查是否有任何值与输入版本匹配.
final List apiVersions = attributes.get(“value”).stream().collect(Collectors.toList());
题:
如何迭代attributes.get(“value”)并与userInputVersion进行比较?
attributes.get(“value”)返回一个Object列表.
我试过下面的代码,
final List
但得到以下错误在第二行anyMatch,
java.lang.ClassCastException: [I cannot be cast to java.lang.Integer
谢谢