jodd.util.Wildcard.equalsOrMatch()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(2.9k)|赞(0)|评价(0)|浏览(87)

本文整理了Java中jodd.util.Wildcard.equalsOrMatch()方法的一些代码示例,展示了Wildcard.equalsOrMatch()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Wildcard.equalsOrMatch()方法的具体详情如下:
包路径:jodd.util.Wildcard
类名称:Wildcard
方法名:equalsOrMatch

Wildcard.equalsOrMatch介绍

[英]Checks if two strings are equals or if they #match(CharSequence,CharSequence). Useful for cases when matching a lot of equal strings and speed is important.
[中]检查两个字符串是否相等或是否匹配(CharSequence,CharSequence)。在匹配大量相等字符串的情况下非常有用,速度很重要。

代码示例

代码示例来源:origin: redisson/redisson

/**
 * Returns <code>true</code> if class or resource name matches
 * at least one package rule from the list.
 */
protected boolean isMatchingRules(String name, String... rules) {
  for (String rule : rules) {
    if (Wildcard.equalsOrMatch(name, rule)) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: oblac/jodd

/**
 * Returns <code>true</code> if class or resource name matches
 * at least one package rule from the list.
 */
protected boolean isMatchingRules(final String name, final String... rules) {
  for (String rule : rules) {
    if (Wildcard.equalsOrMatch(name, rule)) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: oblac/jodd

private void checkClassName(final List<String> classnameWhitelist, final String className) {
  if (classnameWhitelist == null) {
    return;
  }
  classnameWhitelist.forEach(pattern -> {
    if (!Wildcard.equalsOrMatch(className, pattern)) {
      throw new JsonException("Class can't be loaded as it is not whitelisted: " + className);
    }
  });
}

代码示例来源:origin: oblac/jodd

/**
 * Returns all the profiles that define certain prop's key name.
 * Key name is given as a wildcard, or it can be matched fully.
 */
public String[] getProfilesFor(final String propKeyNameWildcard) {
  HashSet<String> profiles = new HashSet<>();
  profile:
  for (Map.Entry<String, Map<String, PropsEntry>> entries : data.profileProperties.entrySet()) {
    String profileName = entries.getKey();
    Map<String, PropsEntry> value = entries.getValue();
    for (String propKeyName : value.keySet()) {
      if (Wildcard.equalsOrMatch(propKeyName, propKeyNameWildcard)) {
        profiles.add(profileName);
        continue profile;
      }
    }
  }
  return profiles.toArray(new String[0]);
}

代码示例来源:origin: org.jodd/jodd-core

/**
 * Returns <code>true</code> if class or resource name matches
 * at least one package rule from the list.
 */
protected boolean isMatchingRules(final String name, final String... rules) {
  for (String rule : rules) {
    if (Wildcard.equalsOrMatch(name, rule)) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: org.jodd/jodd-props

/**
 * Returns all the profiles that define certain prop's key name.
 * Key name is given as a wildcard, or it can be matched fully.
 */
public String[] getProfilesFor(final String propKeyNameWildcard) {
  HashSet<String> profiles = new HashSet<>();
  profile:
  for (Map.Entry<String, Map<String, PropsEntry>> entries : data.profileProperties.entrySet()) {
    String profileName = entries.getKey();
    Map<String, PropsEntry> value = entries.getValue();
    for (String propKeyName : value.keySet()) {
      if (Wildcard.equalsOrMatch(propKeyName, propKeyNameWildcard)) {
        profiles.add(profileName);
        continue profile;
      }
    }
  }
  return profiles.toArray(new String[0]);
}

相关文章