【发布时间】:2019-05-03 13:33:58
【问题描述】:
我有两套产品
public enum ProductType {
FOUNDATION_OR_PAYMENT ("946", "949", "966"),
NOVA_L_S_OR_SESAM ("907", "222");
private String[] type;
ProductType(String... type) {
this.type = type;
}
}
然后给定一个值“actualProductType”我需要检查它是否是productType的一部分..我该怎么做..
isAnyProductTypes(requestData.getProductType(), ProductType.NOVA_L_S_SESAM)
public boolean isAnyProductTypes(String actualProductType, ProductType productTypes) {
return Arrays.stream(productTypes).anyMatch(productType -> productType.equals(actualProductType));
}
我在这部分 Arrays.stream(productTypes) 收到错误
【问题讨论】:
-
这里的术语有些不对劲。产品类型是字符串还是字符串数组?它们不能都是“产品类型”
标签: java enums java-8 java-stream