判断以逗号分隔的字符串是否包含指定的值方法优化
This commit is contained in:
parent
c955981105
commit
48fdebbb5b
|
|
@ -543,10 +543,24 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
|
||||||
* @return true 表示包含,false 表示不包含
|
* @return true 表示包含,false 表示不包含
|
||||||
*/
|
*/
|
||||||
public static boolean containsExactValue(String strings, String target) {
|
public static boolean containsExactValue(String strings, String target) {
|
||||||
return strings.matches("(?<![^,])" + Pattern.quote(target) + "(?![^,])");
|
if (strings == null || target == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (strings.isEmpty() || target.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String[] parts = strings.split(",");
|
||||||
|
for (String part : parts) {
|
||||||
|
if (part == null || part.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (part.equals(target)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 进行结算审批
|
* 进行结算审批
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue