return CLASS_TO_QNAME.getUnchecked(dataType).orElse(null);
}
- public static @NonNull QName getQName(final BaseIdentity identity) {
- return CLASS_TO_QNAME.getUnchecked(identity.implementedInterface())
- .orElseThrow(() -> new IllegalStateException("Failed to resolve QName of " + identity));
- }
-
public static QNameModule getQNameModule(final Class<?> clz) {
if (DataContainer.class.isAssignableFrom(clz) || BaseIdentity.class.isAssignableFrom(clz)
|| Action.class.isAssignableFrom(clz)) {
*/
package org.opendaylight.mdsal.binding.spec.reflect;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.List;
import org.junit.Test;
import org.opendaylight.yangtools.yang.binding.Augmentation;
-import org.opendaylight.yangtools.yang.binding.BaseIdentity;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.RpcService;
import org.opendaylight.yangtools.yang.common.QName;
public void testBindingWithDummyObject() throws Exception {
assertFalse("Should not be RpcType", BindingReflections.isRpcType(DataObject.class));
assertTrue("Should be BindingClass", BindingReflections.isBindingClass(DataObject.class));
-
- assertEquals(QName.create("test", "test"), BindingReflections.getQName(TestIdentity.VALUE));
- }
-
- interface TestIdentity extends BaseIdentity {
- QName QNAME = QName.create("test", "test");
- TestIdentity VALUE = () -> TestIdentity.class;
-
- @Override
- Class<? extends TestIdentity> implementedInterface();
}
static final class TestImplementation implements Augmentation<TestImplementation>, RpcService {
return TestImplementation.class;
}
}
-}
\ No newline at end of file
+}