BUG-4688: Add flexible match support to NamespaceStorageSupport
[yangtools.git] / yang / yang-parser-spi / src / main / java / org / opendaylight / yangtools / yang / parser / spi / meta / NamespaceKeyCriterion.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies, s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang.parser.spi.meta;
9
10 import com.google.common.annotations.Beta;
11 import javax.annotation.Nonnull;
12
13 /**
14  * Namespace key matching criterion.
15  *
16  * @param <K> Key type
17  *
18  * @author Robert Varga
19  */
20 @Beta
21 public abstract class NamespaceKeyCriterion<K> {
22     /**
23      * Match a key against this criterion.
24      *
25      * @param key Key to be matched
26      * @return True if the key matches this criterion, false otherwise.
27      */
28     public abstract boolean match(@Nonnull K key);
29
30     /**
31      * Select the better match from two candidate keys.
32      *
33      * @param first First key
34      * @param second Second key
35      * @return Selected key, must be either first or second key, by identity.
36      */
37     public abstract K select(@Nonnull K first, @Nonnull K second);
38
39     @Override
40     public abstract String toString();
41
42     @Override
43     public final int hashCode() {
44         return super.hashCode();
45     }
46
47     @Override
48     public final boolean equals(final Object obj) {
49         return super.equals(obj);
50     }
51 }