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

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

本文整理了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

  1. /**
  2. * Returns <code>true</code> if class or resource name matches
  3. * at least one package rule from the list.
  4. */
  5. protected boolean isMatchingRules(String name, String... rules) {
  6. for (String rule : rules) {
  7. if (Wildcard.equalsOrMatch(name, rule)) {
  8. return true;
  9. }
  10. }
  11. return false;
  12. }

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

  1. /**
  2. * Returns <code>true</code> if class or resource name matches
  3. * at least one package rule from the list.
  4. */
  5. protected boolean isMatchingRules(final String name, final String... rules) {
  6. for (String rule : rules) {
  7. if (Wildcard.equalsOrMatch(name, rule)) {
  8. return true;
  9. }
  10. }
  11. return false;
  12. }

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

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

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

  1. /**
  2. * Returns all the profiles that define certain prop's key name.
  3. * Key name is given as a wildcard, or it can be matched fully.
  4. */
  5. public String[] getProfilesFor(final String propKeyNameWildcard) {
  6. HashSet<String> profiles = new HashSet<>();
  7. profile:
  8. for (Map.Entry<String, Map<String, PropsEntry>> entries : data.profileProperties.entrySet()) {
  9. String profileName = entries.getKey();
  10. Map<String, PropsEntry> value = entries.getValue();
  11. for (String propKeyName : value.keySet()) {
  12. if (Wildcard.equalsOrMatch(propKeyName, propKeyNameWildcard)) {
  13. profiles.add(profileName);
  14. continue profile;
  15. }
  16. }
  17. }
  18. return profiles.toArray(new String[0]);
  19. }

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

  1. /**
  2. * Returns <code>true</code> if class or resource name matches
  3. * at least one package rule from the list.
  4. */
  5. protected boolean isMatchingRules(final String name, final String... rules) {
  6. for (String rule : rules) {
  7. if (Wildcard.equalsOrMatch(name, rule)) {
  8. return true;
  9. }
  10. }
  11. return false;
  12. }

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

  1. /**
  2. * Returns all the profiles that define certain prop's key name.
  3. * Key name is given as a wildcard, or it can be matched fully.
  4. */
  5. public String[] getProfilesFor(final String propKeyNameWildcard) {
  6. HashSet<String> profiles = new HashSet<>();
  7. profile:
  8. for (Map.Entry<String, Map<String, PropsEntry>> entries : data.profileProperties.entrySet()) {
  9. String profileName = entries.getKey();
  10. Map<String, PropsEntry> value = entries.getValue();
  11. for (String propKeyName : value.keySet()) {
  12. if (Wildcard.equalsOrMatch(propKeyName, propKeyNameWildcard)) {
  13. profiles.add(profileName);
  14. continue profile;
  15. }
  16. }
  17. }
  18. return profiles.toArray(new String[0]);
  19. }

相关文章