1   /*
2    * SPDX-FileCopyrightText: none
3    * SPDX-License-Identifier: CC0-1.0
4    */
5   
6   package dev.metaschema.core.metapath.cst.path;
7   
8   import dev.metaschema.core.metapath.item.node.IDefinitionNodeItem;
9   import edu.umd.cs.findbugs.annotations.NonNull;
10  
11  /**
12   * A wildcard matcher that matches any local name in a specific namespace.
13   * <p>
14   * This matcher implements the namespace:* pattern where it matches any node
15   * whose namespace exactly matches the specified namespace, regardless of the
16   * local name.
17   */
18  class MatchAnyLocalName implements IWildcardMatcher {
19    @NonNull
20    private final String namespace;
21  
22    /**
23     * Construct the matcher using the provided namespace for matching.
24     *
25     * @param namespace
26     *          the namespace used to match nodes
27     */
28    public MatchAnyLocalName(@NonNull String namespace) {
29      this.namespace = namespace;
30    }
31  
32    @Override
33    public boolean test(IDefinitionNodeItem<?, ?> item) {
34      return namespace.equals(item.getQName().getNamespace());
35    }
36  
37    @Override
38    public String toString() {
39      return namespace + ":*";
40    }
41  }