c0f37fed8d54e1de501262ca26e06f8f3b855524
[mdsal.git] / binding / mdsal-binding-dom-codec-api / src / main / java / org / opendaylight / mdsal / binding / dom / codec / api / BindingIdentityCodec.java
1 /*
2  * Copyright (c) 2019 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.mdsal.binding.dom.codec.api;
9
10 import com.google.common.annotations.Beta;
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.opendaylight.yangtools.concepts.Immutable;
13 import org.opendaylight.yangtools.yang.binding.BaseIdentity;
14 import org.opendaylight.yangtools.yang.common.QName;
15
16 /**
17  * A codec capable of translating {@code identity} values between their YANG (QName) and Binding (Class) representation.
18  */
19 @Beta
20 public interface BindingIdentityCodec extends Immutable {
21     /**
22      * Convert a QNname to its corresponding Binding class.
23      *
24      * @param qname Identity QName
25      * @return A binding Class corresponding to the QName
26      * @throws IllegalArgumentException if the qname does not map to an identity
27      * @throws NullPointerException if qname is null
28      */
29     @NonNull Class<? extends BaseIdentity> toBinding(@NonNull QName qname);
30
31     /**
32      * Concert a Binding class to its QName equivalent.
33      *
34      * @param bindingClass Binding class to convert
35      * @return QName corresponding to the binding class
36      * @throws NullPointerException if bindingClass is null
37      */
38     @NonNull QName fromBinding(Class<? extends BaseIdentity> bindingClass);
39 }