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 a specific local name in any namespace.
13   * <p>
14   * This matcher implements the '*:localName' syntax in path expressions, where
15   * the asterisk matches any namespace while requiring an exact match on the
16   * local name part.
17   *
18   * @since 1.0.0
19   */
20  class MatchAnyNamespace implements IWildcardMatcher {
21    @NonNull
22    private final String localName;
23  
24    /**
25     * Construct the matcher using the provided local name for matching.
26     *
27     * @param localName
28     *          the name used to match nodes
29     */
30    public MatchAnyNamespace(@NonNull String localName) {
31      this.localName = localName;
32    }
33  
34    @Override
35    public boolean test(IDefinitionNodeItem<?, ?> item) {
36      return localName.equals(item.getQName().getLocalName());
37    }
38  
39    @Override
40    public String toString() {
41      return "*:" + localName;
42    }
43  }