Pick up byte-buddy from yangtools
[mdsal.git] / binding / yang-binding / src / main / java / org / opendaylight / yangtools / yang / binding / YangFeature.java
1 /*
2  * Copyright (c) 2022 PANTHEON.tech, 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.binding;
9
10 import com.google.common.base.MoreObjects;
11 import org.eclipse.jdt.annotation.NonNullByDefault;
12 import org.eclipse.jdt.annotation.Nullable;
13 import org.opendaylight.yangtools.yang.common.QName;
14
15 /**
16  * Abstract base class for classes generated for YANG {@code feature} statements.
17  */
18 @NonNullByDefault
19 public abstract non-sealed class YangFeature<F extends YangFeature<F, R>, R extends DataRoot>
20         implements BindingContract<F> {
21     @Override
22     public abstract Class<F> implementedInterface();
23
24     /**
25      * Return the {@link QName} associated with this feature.
26      *
27      * @return A QName
28      */
29     public abstract QName qname();
30
31     /**
32      * Return the {@code module} which defines this feature.
33      *
34      * @return A module's {@link DataRoot} class
35      */
36     public abstract Class<R> definingModule();
37
38     @Override
39     public final int hashCode() {
40         return implementedInterface().hashCode();
41     }
42
43     @Override
44     public final boolean equals(final @Nullable Object obj) {
45         return obj == this || obj instanceof YangFeature<?, ?> other
46             && implementedInterface().equals(other.implementedInterface());
47     }
48
49     @Override
50     public final String toString() {
51         return MoreObjects.toStringHelper(this).add("qname", qname()).toString();
52     }
53 }