CommonUtil { public static boolean match(final String rule, final String matchValue) { boolean ismatch = false; if (StringUtils.isNotEmpty(rule) && StringUtils.isNotEmpty(matchValue)) { if (GlobalConstants.ASTERISK.equals(rule)) { ismatch = true; } else if (rule.startsWith("NOT:")) { String tempRule = rule.substring("NOT:".length()); ismatch = tempRule.indexOf(GlobalConstants.SPLITOR) == -1 ? !tempRule.equals(matchValue) : new StringBuilder().append(GlobalConstants.SPLITOR).append(tempRule) .append(GlobalConstants.SPLITOR).indexOf(new StringBuilder().append(GlobalConstants.SPLITOR) .append(matchValue).append(GlobalConstants.SPLITOR).toString()) == -1; } else { ismatch = rule.indexOf(GlobalConstants.SPLITOR) == -1 ? rule.equals(matchValue) : new StringBuilder().append(GlobalConstants.SPLITOR).append(rule).append(GlobalConstants.SPLITOR) .indexOf(new StringBuilder().append(GlobalConstants.SPLITOR).append(matchValue) .append(GlobalConstants.SPLITOR).toString()) != -1; } } return ismatch; }  static String messageFormat(final String message, final Object... params); static String getTransactionID(); static String getRandomCode(); static String getRandomNumber(final int size); static String getRandomChar(final int size); static String getString(final Object obj); static String notNullStr(final String str); static Date getDate(final Long time); static Integer[] splitId(final String idStr, final String splitor); static Long[] splitIdsByLong(final String idStr, final String splitor); static Integer[] splitId(final String idStr); static boolean wildcardMatch(final Collection<String> rules, final String matchValue); static boolean wildcardMatch(final String rule, final String matchValue); static boolean match(final String rule, final String matchValue); static String removeAllSymbol(final String str); static String replaceAllBlank(final String str); static String replaceRedundantBlank(final String str); static boolean isNotEmpty(final T[] paramTypes); static boolean isEmpty(final T[] paramTypes);  }
@Test public void match() { String a = "10,100, 110"; String b = "10"; Assert.isTrue(CommonUtil.match(a, b), ErrorCodeDef.SYSTEM_ERROR_10001); System.out.println("字符串b在字符串a内可以找到"); b = "1"; Assert.isFalse(CommonUtil.match(a, b), ErrorCodeDef.SYSTEM_ERROR_10001); System.out.println("字符串b在字符串a内不能找到"); a = "NOT:10,100,110"; Assert.isTrue(CommonUtil.match(a, b), ErrorCodeDef.SYSTEM_ERROR_10001); System.out.println("字符串b不在字符串a内"); }