public boolean couldMatch()

in spectator-reg-atlas/src/main/java/com/netflix/spectator/atlas/impl/QueryIndex.java [581:630]


  public boolean couldMatch(Function<String, String> tags) {
    // Matches for this level
    if (!matches.isEmpty()) {
      return true;
    }

    boolean keyPresent = false;
    final String keyRef = key;
    if (keyRef != null) {
      String v = tags.apply(keyRef);
      if (v != null) {
        keyPresent = true;

        // Check exact matches
        QueryIndex<T> eqIdx = equalChecks.get(v);
        if (eqIdx != null && eqIdx.couldMatch(tags)) {
          return true;
        }

        // Scan for matches with other conditions
        if (!otherChecks.isEmpty()) {
          boolean otherMatches = otherChecksTree.exists(v, kq -> {
            if (kq instanceof Query.In || couldMatch(kq, v)) {
              QueryIndex<T> idx = otherChecks.get(kq);
              return idx != null && idx.couldMatch(tags);
            }
            return false;
          });
          if (otherMatches) {
            return true;
          }
        }

        // Check matches for has key
        final QueryIndex<T> hasKeyIdxRef = hasKeyIdx;
        if (hasKeyIdxRef != null && hasKeyIdxRef.couldMatch(tags)) {
          return true;
        }
      }
    }

    // Check matches with other keys
    final QueryIndex<T> otherKeysIdxRef = otherKeysIdx;
    if (otherKeysIdxRef != null && otherKeysIdxRef.couldMatch(tags)) {
      return true;
    }

    // Check matches with missing keys
    return !keyPresent;
  }