From 195f63ec83e0bc53990031acde9d79bea6d0b3ba Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Thu, 4 Oct 2018 10:18:17 +0200 Subject: [PATCH] Remove binding2/prototype This code is not plugged into build, hence it is pure clutter. Change-Id: I69139ceef2a26136a91e9c8cbc0ad95559eefc8c Signed-off-by: Robert Varga --- binding2/prototype/pom.xml | 43 -- binding2/prototype/readme.adoc | 14 - .../prototype/src/main/yang/mainYangTest.yang | 71 -- .../src/main/yang/mainYangTestImporting.yang | 35 - .../$YangModelBindingProvider.java | 8 - .../mainyangtest/$YangModuleInfoImpl.java | 79 -- .../test/mainyangtest/MainYangTestData.java | 168 ---- .../urn/test/mainyangtest/data/MainCont.java | 108 --- .../urn/test/mainyangtest/data/MainCont1.java | 18 - .../mainyangtest/data/MainCont1Builder.java | 112 --- .../mainyangtest/data/MainContBuilder.java | 232 ------ .../urn/test/mainyangtest/grp/MainGroup.java | 74 -- .../test/mainyangtest/grp/SecondGroup.java | 35 - .../grp/main/group/MainGroupCont.java | 91 --- .../grp/main/group/MainGroupContBuilder.java | 395 ---------- .../main/group/cont/MainGroupContChoice.java | 38 - .../group/cont/MainGroupContListOrdered.java | 53 -- .../cont/MainGroupContListOrderedBuilder.java | 283 ------- .../cont/MainGroupContListOrderedKey.java | 76 -- .../cont/MainGroupContListUnordered.java | 53 -- .../MainGroupContListUnorderedBuilder.java | 283 ------- .../cont/MainGroupContListUnorderedKey.java | 76 -- .../group/cont/main/group/cont/choice/A.java | 36 - .../cont/main/group/cont/choice/ABuilder.java | 205 ----- .../group/cont/main/group/cont/choice/B.java | 36 - .../cont/main/group/cont/choice/BBuilder.java | 205 ----- .../grp/second/group/SecondGroupCont.java | 38 - .../second/group/SecondGroupContBuilder.java | 205 ----- .../$YangModelBindingProvider.java | 8 - .../$YangModuleInfoImpl.java | 82 -- .../MainYangTestImportingData.java | 109 --- .../data/ImportingContainer.java | 90 --- .../data/ImportingContainerBuilder.java | 231 ------ .../mainyangtestimporting/data/MainCont1.java | 19 - .../data/MainCont1Builder.java | 112 --- .../mainyangtestimporting/data/MainCont2.java | 19 - .../data/MainCont2Builder.java | 112 --- .../data/MainGroupCont1.java | 19 - .../data/MainGroupCont1Builder.java | 112 --- .../mainyangtestimporting/package-info.java | 9 - binding2/prototype/yang-binding2/pom.xml | 53 -- .../yangtools/yang/binding/Augmentable.java | 34 - .../yangtools/yang/binding/Augmentation.java | 26 - .../yang/binding/AugmentationHolder.java | 32 - .../yangtools/yang/binding/BaseIdentity.java | 23 - .../yangtools/yang/binding/BindingCodec.java | 22 - .../yang/binding/BindingDeserializer.java | 13 - .../yang/binding/BindingMapping.java | 244 ------ .../yang/binding/BindingSerializer.java | 12 - .../binding/BindingStreamEventWriter.java | 471 ------------ .../yangtools/yang/binding/ChildTreeNode.java | 28 - .../yang/binding/DataObjectSerializer.java | 25 - .../DataObjectSerializerImplementation.java | 37 - .../binding/DataObjectSerializerRegistry.java | 29 - .../yang/binding/IdentifiableListItem.java | 25 - .../yangtools/yang/binding/Identifier.java | 22 - .../yang/binding/InstanceIdentifier.java | 717 ------------------ .../InstanceIdentifierBuilderImpl.java | 110 --- .../yang/binding/InterfaceTyped.java | 28 - .../yang/binding/KeyedInstanceIdentifier.java | 52 -- .../yangtools/yang/binding/Notification.java | 18 - .../yang/binding/NotificationListener.java | 29 - .../yang/binding/RpcImplementation.java | 22 - .../yangtools/yang/binding/RpcInput.java | 12 - .../yangtools/yang/binding/RpcService.java | 16 - .../yangtools/yang/binding/TreeNode.java | 18 - .../yangtools/yang/binding/TreeRoot.java | 17 - .../binding/YangModelBindingProvider.java | 31 - .../yang/binding/YangModuleInfo.java | 42 - .../yang/binding/annotations/ModuleQName.java | 24 - .../yang/binding/annotations/QName.java | 21 - .../binding/annotations/RoutingContext.java | 27 - .../yangtools/yang/binding/package-info.java | 8 - .../util/AbstractMappedRpcInvoker.java | 54 -- .../binding/util/AugmentationFieldGetter.java | 107 --- .../yang/binding/util/BindingReflections.java | 671 ---------------- .../util/ClassBasedRpcServiceInvoker.java | 50 -- .../yang/binding/util/ClassLoaderUtils.java | 205 ----- .../binding/util/DataObjectReadingUtil.java | 349 --------- .../util/LocalNameRpcServiceInvoker.java | 43 -- .../util/NotificationListenerInvoker.java | 122 --- .../binding/util/QNameRpcServiceInvoker.java | 27 - .../yang/binding/util/RpcMethodInvoker.java | 42 - .../util/RpcMethodInvokerWithInput.java | 36 - .../util/RpcMethodInvokerWithoutInput.java | 36 - .../yang/binding/util/RpcServiceInvoker.java | 78 -- .../util/StringValueObjectFactory.java | 132 ---- .../yang/binding/InstanceIdentifierTest.java | 145 ---- .../yang/binding/test/mock/FooChild.java | 14 - .../yang/binding/test/mock/GroupingFoo.java | 12 - .../binding/test/mock/InstantiatedFoo.java | 15 - .../yang/binding/test/mock/Node.java | 19 - .../yang/binding/test/mock/NodeChild.java | 19 - .../yang/binding/test/mock/NodeChildKey.java | 46 -- .../yang/binding/test/mock/NodeKey.java | 46 -- .../yang/binding/test/mock/Nodes.java | 18 - .../binding/util/BindingReflectionsTest.java | 34 - .../util/DataObjectReadingUtilTest.java | 76 -- 98 files changed, 8676 deletions(-) delete mode 100644 binding2/prototype/pom.xml delete mode 100644 binding2/prototype/readme.adoc delete mode 100644 binding2/prototype/src/main/yang/mainYangTest.yang delete mode 100644 binding2/prototype/src/main/yang/mainYangTestImporting.yang delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/$YangModelBindingProvider.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/$YangModuleInfoImpl.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/MainYangTestData.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/data/MainCont.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/data/MainCont1.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/data/MainCont1Builder.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/data/MainContBuilder.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/MainGroup.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/SecondGroup.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/MainGroupCont.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/MainGroupContBuilder.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/MainGroupContChoice.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/MainGroupContListOrdered.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/MainGroupContListOrderedBuilder.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/MainGroupContListOrderedKey.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/MainGroupContListUnordered.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/MainGroupContListUnorderedBuilder.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/MainGroupContListUnorderedKey.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/main/group/cont/choice/A.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/main/group/cont/choice/ABuilder.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/main/group/cont/choice/B.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/main/group/cont/choice/BBuilder.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/second/group/SecondGroupCont.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/second/group/SecondGroupContBuilder.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/$YangModelBindingProvider.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/$YangModuleInfoImpl.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/MainYangTestImportingData.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/ImportingContainer.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/ImportingContainerBuilder.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/MainCont1.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/MainCont1Builder.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/MainCont2.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/MainCont2Builder.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/MainGroupCont1.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/MainGroupCont1Builder.java delete mode 100644 binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/package-info.java delete mode 100644 binding2/prototype/yang-binding2/pom.xml delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/Augmentable.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/Augmentation.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/AugmentationHolder.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/BaseIdentity.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/BindingCodec.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/BindingDeserializer.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/BindingMapping.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/BindingSerializer.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/BindingStreamEventWriter.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/ChildTreeNode.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/DataObjectSerializer.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/DataObjectSerializerImplementation.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/DataObjectSerializerRegistry.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/IdentifiableListItem.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/Identifier.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifier.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifierBuilderImpl.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/InterfaceTyped.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/KeyedInstanceIdentifier.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/Notification.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/NotificationListener.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/RpcImplementation.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/RpcInput.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/RpcService.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/TreeNode.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/TreeRoot.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/YangModelBindingProvider.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/YangModuleInfo.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/annotations/ModuleQName.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/annotations/QName.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/annotations/RoutingContext.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/package-info.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/AbstractMappedRpcInvoker.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/AugmentationFieldGetter.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/BindingReflections.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/ClassBasedRpcServiceInvoker.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/ClassLoaderUtils.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/DataObjectReadingUtil.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/LocalNameRpcServiceInvoker.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/NotificationListenerInvoker.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/QNameRpcServiceInvoker.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/RpcMethodInvoker.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/RpcMethodInvokerWithInput.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/RpcMethodInvokerWithoutInput.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/RpcServiceInvoker.java delete mode 100644 binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/StringValueObjectFactory.java delete mode 100644 binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifierTest.java delete mode 100644 binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/FooChild.java delete mode 100644 binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/GroupingFoo.java delete mode 100644 binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/InstantiatedFoo.java delete mode 100644 binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/Node.java delete mode 100644 binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/NodeChild.java delete mode 100644 binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/NodeChildKey.java delete mode 100644 binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/NodeKey.java delete mode 100644 binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/Nodes.java delete mode 100644 binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/util/BindingReflectionsTest.java delete mode 100644 binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/util/DataObjectReadingUtilTest.java diff --git a/binding2/prototype/pom.xml b/binding2/prototype/pom.xml deleted file mode 100644 index 4fca7da8c2..0000000000 --- a/binding2/prototype/pom.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - 4.0.0 - - org.opendaylight.yangtools.yang.binding2 - prototype - 0.7.0-SNAPSHOT - - - - org.opendaylight.yangtools - yang-common - 2.1.1 - - - org.opendaylight.mdsal - yang-binding2 - 0.15.0-SNAPSHOT - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.5.1 - - 1.8 - 1.8 - - - - compile - - compile - - - - - - - diff --git a/binding2/prototype/readme.adoc b/binding2/prototype/readme.adoc deleted file mode 100644 index b815d2ef32..0000000000 --- a/binding2/prototype/readme.adoc +++ /dev/null @@ -1,14 +0,0 @@ -== Design Binding specification v2 - -This patch represents initial prototyping of binding specification v2 where: - -* Java code was generated from YANG module with binding spec v1 -* manually refactored according to new v2 rules for packages - - -=== Further notes: - -* generated structures -* yang-binding refactored -* grouping & data package suffix added -* trailling whitespaces fixed \ No newline at end of file diff --git a/binding2/prototype/src/main/yang/mainYangTest.yang b/binding2/prototype/src/main/yang/mainYangTest.yang deleted file mode 100644 index 6a62a5437b..0000000000 --- a/binding2/prototype/src/main/yang/mainYangTest.yang +++ /dev/null @@ -1,71 +0,0 @@ -module mainYangTest { - namespace "urn:test:mainYangTest"; - prefix myt; - - revision 2016-01-01 { - description "Main yang for testing spec v2"; - } - - grouping main-group { - container main-group-cont { - uses second-group; - leaf main-group-cont-leaf { - type string; - } - list main-group-cont-list-ordered { - ordered-by user; - key "name-1"; - leaf name-1 { - type string; - } - leaf type-1 { - type string; - } - } - list main-group-cont-list-unordered { - key "name-2"; - leaf name-2 { - type string; - } - leaf type-2 { - type string; - } - } - choice main-group-cont-choice { - case a { - leaf case-1 { - type string; - } - } - case b { - leaf case2-1 { - type string; - } - } - } - leaf leaf-ref-test { - type leafref { - path "../main-group-cont-leaf"; - } - } - } - } - - grouping second-group { - container second-group-cont { - leaf second-group-cont-leaf { - type string; - } - } - } - - augment "/main-cont" { - leaf main-augmented-leaf { - type string; - } - } - - container main-cont { - uses main-group; - } -} \ No newline at end of file diff --git a/binding2/prototype/src/main/yang/mainYangTestImporting.yang b/binding2/prototype/src/main/yang/mainYangTestImporting.yang deleted file mode 100644 index 4a561911b6..0000000000 --- a/binding2/prototype/src/main/yang/mainYangTestImporting.yang +++ /dev/null @@ -1,35 +0,0 @@ -module mainYangTestImporting { - namespace "urn:test:mainYangTestImporting"; - prefix myti; - - revision 2016-01-01 { - description "imported yang for testing spec v2"; - } - - import mainYangTest { - prefix imp; - revision-date 2016-01-01; - } - - augment "imp:main-cont" { - leaf imported-augmented-leaf-1 { - type string; - } - } - - augment "imp:main-cont" { - leaf imported-augmented-leaf-2 { - type string; - } - } - - container importing-container { - uses imp:main-group; - } - - augment "importing-container/main-group-cont" { - leaf imported-augmented-leaf-3 { - type string; - } - } -} \ No newline at end of file diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/$YangModelBindingProvider.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/$YangModelBindingProvider.java deleted file mode 100644 index d3003fecc5..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/$YangModelBindingProvider.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtest; - -public final class $YangModelBindingProvider implements org.opendaylight.yangtools.yang.binding.YangModelBindingProvider { - - public org.opendaylight.yangtools.yang.binding.YangModuleInfo getModuleInfo() { - return $YangModuleInfoImpl.getInstance(); - } -} diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/$YangModuleInfoImpl.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/$YangModuleInfoImpl.java deleted file mode 100644 index 2735a1b895..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/$YangModuleInfoImpl.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtest; -import org.opendaylight.yangtools.yang.binding.YangModuleInfo; -import java.util.Set; -import java.util.Collections; -import java.io.InputStream; -import java.io.IOException; -public final class $YangModuleInfoImpl implements YangModuleInfo { - - private static final YangModuleInfo INSTANCE = new $YangModuleInfoImpl(); - - private final String name = "mainYangTest"; - private final String namespace = "urn:test:mainYangTest"; - private final String revision = "2016-01-01"; - private final String resourcePath = "/META-INF/yang/mainYangTest.yang"; - - private final Set importedModules; - - public static YangModuleInfo getInstance() { - return INSTANCE; - } - - private $YangModuleInfoImpl() { - importedModules = Collections.emptySet(); - - InputStream stream = $YangModuleInfoImpl.class.getResourceAsStream(resourcePath); - if (stream == null) { - throw new IllegalStateException("Resource '" + resourcePath + "' is missing"); - } - try { - stream.close(); - } catch (IOException e) { - // Resource leak, but there is nothing we can do - } - } - - @Override - public String getName() { - return name; - } - - @Override - public String getRevision() { - return revision; - } - - @Override - public String getNamespace() { - return namespace; - } - - @Override - public InputStream getModuleSourceStream() throws IOException { - InputStream stream = $YangModuleInfoImpl.class.getResourceAsStream(resourcePath); - if (stream == null) { - throw new IOException("Resource " + resourcePath + " is missing"); - } - return stream; - } - - @Override - public Set getImportedModules() { - return importedModules; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(this.getClass().getCanonicalName()); - sb.append("["); - sb.append("name = " + name); - sb.append(", namespace = " + namespace); - sb.append(", revision = " + revision); - sb.append(", resourcePath = " + resourcePath); - sb.append(", imports = " + importedModules); - sb.append("]"); - return sb.toString(); - } - - -} diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/MainYangTestData.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/MainYangTestData.java deleted file mode 100644 index 61b3233b0a..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/MainYangTestData.java +++ /dev/null @@ -1,168 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtest; -import org.opendaylight.yang.gen.v1.urn.test.mainyangtest.data.MainCont; -import org.opendaylight.yangtools.yang.binding.TreeRoot; - - -/** - *

This class represents the following YANG schema fragment defined in module mainYangTest - *

- * module mainYangTest {
- *     yang-version 1;
- *     namespace "urn:test:mainYangTest";
- *     prefix "myt";
- *
- *     revision 2016-01-01 {
- *         description "";
- *     }
- *
- *     container main-cont {
- *         container main-group-cont {
- *             leaf main-group-cont-leaf {
- *                 type string;
- *             }
- *             list main-group-cont-list-ordered {
- *                 key "name-1"
- *                 leaf name-1 {
- *                     type string;
- *                 }
- *                 leaf type-1 {
- *                     type string;
- *                 }
- *             }
- *             list main-group-cont-list-unordered {
- *                 key "name-2"
- *                 leaf name-2 {
- *                     type string;
- *                 }
- *                 leaf type-2 {
- *                     type string;
- *                 }
- *             }
- *             choice main-group-cont-choice {
- *                 case a {
- *                     leaf case-1 {
- *                         type string;
- *                     }
- *                 }
- *                 case b {
- *                     leaf case2-1 {
- *                         type string;
- *                     }
- *                 }
- *             }
- *             leaf leaf-ref-test {
- *                 type leafref;
- *             }
- *             container second-group-cont {
- *                 leaf second-group-cont-leaf {
- *                     type string;
- *                 }
- *             }
- *             uses second-group;
- *         }
- *         leaf main-augmented-leaf {
- *             type string;
- *         }
- *         leaf imported-augmented-leaf-1 {
- *             type string;
- *         }
- *         leaf imported-augmented-leaf-2 {
- *             type string;
- *         }
- *         augment \(urn:test:mainYangTest)main-cont {
- *             status CURRENT;
- *             leaf main-augmented-leaf {
- *                 type string;
- *             }
- *         }
- *         augment \(urn:test:mainYangTest)main-cont {
- *             status CURRENT;
- *             leaf imported-augmented-leaf-1 {
- *                 type string;
- *             }
- *         }
- *         augment \(urn:test:mainYangTest)main-cont {
- *             status CURRENT;
- *             leaf imported-augmented-leaf-2 {
- *                 type string;
- *             }
- *         }
- *         uses main-group;
- *     }
- *
- *     grouping second-group {
- *         container second-group-cont {
- *             leaf second-group-cont-leaf {
- *                 type string;
- *             }
- *         }
- *     }
- *     grouping main-group {
- *         container main-group-cont {
- *             container second-group-cont {
- *                 leaf second-group-cont-leaf {
- *                     type string;
- *                 }
- *             }
- *             leaf main-group-cont-leaf {
- *                 type string;
- *             }
- *             list main-group-cont-list-ordered {
- *                 key "name-1"
- *                 leaf name-1 {
- *                     type string;
- *                 }
- *                 leaf type-1 {
- *                     type string;
- *                 }
- *             }
- *             list main-group-cont-list-unordered {
- *                 key "name-2"
- *                 leaf name-2 {
- *                     type string;
- *                 }
- *                 leaf type-2 {
- *                     type string;
- *                 }
- *             }
- *             choice main-group-cont-choice {
- *                 case a {
- *                     leaf case-1 {
- *                         type string;
- *                     }
- *                 }
- *                 case b {
- *                     leaf case2-1 {
- *                         type string;
- *                     }
- *                 }
- *             }
- *             leaf leaf-ref-test {
- *                 type leafref;
- *             }
- *             uses second-group;
- *         }
- *     }
- *
- *     augment \(urn:test:mainYangTest)main-cont {
- *         status CURRENT;
- *         leaf main-augmented-leaf {
- *             type string;
- *         }
- *     }
- * }
- * 
- * - */ -public interface MainYangTestData - extends - TreeRoot -{ - - - - - MainCont getMainCont(); - -} - diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/data/MainCont.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/data/MainCont.java deleted file mode 100644 index cb0490bb41..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/data/MainCont.java +++ /dev/null @@ -1,108 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtest.data; -import org.opendaylight.yangtools.yang.binding.ChildTreeNode; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yang.gen.v1.urn.test.mainyangtest.MainYangTestData; -import org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.MainGroup; -import org.opendaylight.yangtools.yang.binding.Augmentable; - - -/** - *

This class represents the following YANG schema fragment defined in module mainYangTest - *

- * container main-cont {
- *     container main-group-cont {
- *         leaf main-group-cont-leaf {
- *             type string;
- *         }
- *         list main-group-cont-list-ordered {
- *             key "name-1"
- *             leaf name-1 {
- *                 type string;
- *             }
- *             leaf type-1 {
- *                 type string;
- *             }
- *         }
- *         list main-group-cont-list-unordered {
- *             key "name-2"
- *             leaf name-2 {
- *                 type string;
- *             }
- *             leaf type-2 {
- *                 type string;
- *             }
- *         }
- *         choice main-group-cont-choice {
- *             case a {
- *                 leaf case-1 {
- *                     type string;
- *                 }
- *             }
- *             case b {
- *                 leaf case2-1 {
- *                     type string;
- *                 }
- *             }
- *         }
- *         leaf leaf-ref-test {
- *             type leafref;
- *         }
- *         container second-group-cont {
- *             leaf second-group-cont-leaf {
- *                 type string;
- *             }
- *         }
- *         uses second-group;
- *     }
- *     leaf main-augmented-leaf {
- *         type string;
- *     }
- *     leaf imported-augmented-leaf-1 {
- *         type string;
- *     }
- *     leaf imported-augmented-leaf-2 {
- *         type string;
- *     }
- *     augment \(urn:test:mainYangTest)main-cont {
- *         status CURRENT;
- *         leaf main-augmented-leaf {
- *             type string;
- *         }
- *     }
- *     augment \(urn:test:mainYangTest)main-cont {
- *         status CURRENT;
- *         leaf imported-augmented-leaf-1 {
- *             type string;
- *         }
- *     }
- *     augment \(urn:test:mainYangTest)main-cont {
- *         status CURRENT;
- *         leaf imported-augmented-leaf-2 {
- *             type string;
- *         }
- *     }
- *     uses main-group;
- * }
- * 
- * The schema path to identify an instance is - * mainYangTest/main-cont - * - *

To create instances of this class use {@link org.opendaylight.yang.gen.v1.urn.test.mainyangtest.data.MainContBuilder}. - * @see org.opendaylight.yang.gen.v1.urn.test.mainyangtest.data.MainContBuilder - * - */ -public interface MainCont - extends - ChildTreeNode, - Augmentable, - MainGroup -{ - - - - public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.create("urn:test:mainYangTest", - "2016-01-01", "main-cont").intern(); - - -} - diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/data/MainCont1.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/data/MainCont1.java deleted file mode 100644 index c919f5d348..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/data/MainCont1.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtest.data; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.binding.TreeNode; - - -public interface MainCont1 - extends - TreeNode, - Augmentation -{ - - - - - java.lang.String getMainAugmentedLeaf(); - -} - diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/data/MainCont1Builder.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/data/MainCont1Builder.java deleted file mode 100644 index a9779a4a60..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/data/MainCont1Builder.java +++ /dev/null @@ -1,112 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtest.data; -import org.opendaylight.yangtools.yang.binding.TreeNode; -import org.opendaylight.yangtools.concepts.Builder; -import java.util.Objects; - - -/** - * Class that builds {@link org.opendaylight.yang.gen.v1.urn.test.mainyangtest.data.MainCont1} instances. - * - * @see org.opendaylight.yang.gen.v1.urn.test.mainyangtest.data.MainCont1 - * - */ -public class MainCont1Builder implements Builder { - - private java.lang.String _mainAugmentedLeaf; - - - public MainCont1Builder() { - } - - public MainCont1Builder(MainCont1 base) { - this._mainAugmentedLeaf = base.getMainAugmentedLeaf(); - } - - - public java.lang.String getMainAugmentedLeaf() { - return _mainAugmentedLeaf; - } - - - public MainCont1Builder setMainAugmentedLeaf(final java.lang.String value) { - this._mainAugmentedLeaf = value; - return this; - } - - public MainCont1 build() { - return new MainCont1Impl(this); - } - - private static final class MainCont1Impl implements MainCont1 { - - public java.lang.Class implementedInterface() { - return org.opendaylight.yang.gen.v1.urn.test.mainyangtest.data.MainCont1.class; - } - - private final java.lang.String _mainAugmentedLeaf; - - - private MainCont1Impl(MainCont1Builder base) { - this._mainAugmentedLeaf = base.getMainAugmentedLeaf(); - } - - @Override - public java.lang.String getMainAugmentedLeaf() { - return _mainAugmentedLeaf; - } - - private int hash = 0; - private volatile boolean hashValid = false; - - @Override - public int hashCode() { - if (hashValid) { - return hash; - } - - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(_mainAugmentedLeaf); - - hash = result; - hashValid = true; - return result; - } - - @Override - public boolean equals(java.lang.Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof TreeNode)) { - return false; - } - if (!org.opendaylight.yang.gen.v1.urn.test.mainyangtest.data.MainCont1.class.equals(((TreeNode)obj).implementedInterface())) { - return false; - } - org.opendaylight.yang.gen.v1.urn.test.mainyangtest.data.MainCont1 other = (org.opendaylight.yang.gen.v1.urn.test.mainyangtest.data.MainCont1)obj; - if (!Objects.equals(_mainAugmentedLeaf, other.getMainAugmentedLeaf())) { - return false; - } - return true; - } - - @Override - public java.lang.String toString() { - java.lang.StringBuilder builder = new java.lang.StringBuilder ("MainCont1 ["); - boolean first = true; - - if (_mainAugmentedLeaf != null) { - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("_mainAugmentedLeaf="); - builder.append(_mainAugmentedLeaf); - } - return builder.append(']').toString(); - } - } - -} diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/data/MainContBuilder.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/data/MainContBuilder.java deleted file mode 100644 index 1bc3300927..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/data/MainContBuilder.java +++ /dev/null @@ -1,232 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtest.data; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.binding.AugmentationHolder; -import org.opendaylight.yangtools.yang.binding.TreeNode; -import java.util.HashMap; -import org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.MainGroup; -import org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.MainGroupCont; -import org.opendaylight.yangtools.concepts.Builder; -import java.util.Objects; -import java.util.Collections; -import java.util.Map; - - -/** - * Class that builds {@link org.opendaylight.yang.gen.v1.urn.test.mainyangtest.data.MainCont} instances. - * - * @see org.opendaylight.yang.gen.v1.urn.test.mainyangtest.data.MainCont - * - */ -public class MainContBuilder implements Builder { - - private MainGroupCont _mainGroupCont; - - Map>, Augmentation> augmentation = Collections.emptyMap(); - - public MainContBuilder() { - } - public MainContBuilder(org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.MainGroup arg) { - this._mainGroupCont = arg.getMainGroupCont(); - } - - public MainContBuilder(MainCont base) { - this._mainGroupCont = base.getMainGroupCont(); - if (base instanceof MainContImpl) { - MainContImpl impl = (MainContImpl) base; - if (!impl.augmentation.isEmpty()) { - this.augmentation = new HashMap<>(impl.augmentation); - } - } else if (base instanceof AugmentationHolder) { - @SuppressWarnings("unchecked") - AugmentationHolder casted =(AugmentationHolder) base; - if (!casted.augmentations().isEmpty()) { - this.augmentation = new HashMap<>(casted.augmentations()); - } - } - } - - /** - *Set fields from given grouping argument. Valid argument is instance of one of following types: - *

    - *
  • org.opendaylight.yang.gen.v1.urn.test.mainyangtest.rev160101.MainGroup
  • - *
- * - * @param arg grouping object - * @throws IllegalArgumentException if given argument is none of valid types - */ - public void fieldsFrom(TreeNode arg) { - boolean isValidArg = false; - if (arg instanceof org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.MainGroup) { - this._mainGroupCont = ((org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.MainGroup)arg).getMainGroupCont(); - isValidArg = true; - } - if (!isValidArg) { - throw new IllegalArgumentException( - "expected one of: [org.opendaylight.yang.gen.v1.urn.test.mainyangtest.rev160101.MainGroup] \n" + - "but was: " + arg - ); - } - } - - public MainGroupCont getMainGroupCont() { - return _mainGroupCont; - } - - @SuppressWarnings("unchecked") - public > E getAugmentation(java.lang.Class augmentationType) { - if (augmentationType == null) { - throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); - } - return (E) augmentation.get(augmentationType); - } - - - public MainContBuilder setMainGroupCont(final MainGroupCont value) { - this._mainGroupCont = value; - return this; - } - - public MainContBuilder addAugmentation(java.lang.Class> augmentationType, Augmentation augmentation) { - if (augmentation == null) { - return removeAugmentation(augmentationType); - } - - if (!(this.augmentation instanceof HashMap)) { - this.augmentation = new HashMap<>(); - } - - this.augmentation.put(augmentationType, augmentation); - return this; - } - - public MainContBuilder removeAugmentation(java.lang.Class> augmentationType) { - if (this.augmentation instanceof HashMap) { - this.augmentation.remove(augmentationType); - } - return this; - } - - public MainCont build() { - return new MainContImpl(this); - } - - private static final class MainContImpl implements MainCont { - - public java.lang.Class implementedInterface() { - return org.opendaylight.yang.gen.v1.urn.test.mainyangtest.data.MainCont.class; - } - - private final MainGroupCont _mainGroupCont; - - private Map>, Augmentation> augmentation = Collections.emptyMap(); - - private MainContImpl(MainContBuilder base) { - this._mainGroupCont = base.getMainGroupCont(); - switch (base.augmentation.size()) { - case 0: - this.augmentation = Collections.emptyMap(); - break; - case 1: - final Map.Entry>, Augmentation> e = base.augmentation.entrySet().iterator().next(); - this.augmentation = Collections.>, Augmentation>singletonMap(e.getKey(), e.getValue()); - break; - default : - this.augmentation = new HashMap<>(base.augmentation); - } - } - - @Override - public MainGroupCont getMainGroupCont() { - return _mainGroupCont; - } - - @SuppressWarnings("unchecked") - @Override - public > E getAugmentation(java.lang.Class augmentationType) { - if (augmentationType == null) { - throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); - } - return (E) augmentation.get(augmentationType); - } - - private int hash = 0; - private volatile boolean hashValid = false; - - @Override - public int hashCode() { - if (hashValid) { - return hash; - } - - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(_mainGroupCont); - result = prime * result + Objects.hashCode(augmentation); - - hash = result; - hashValid = true; - return result; - } - - @Override - public boolean equals(java.lang.Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof TreeNode)) { - return false; - } - if (!org.opendaylight.yang.gen.v1.urn.test.mainyangtest.data.MainCont.class.equals(((TreeNode)obj).implementedInterface())) { - return false; - } - org.opendaylight.yang.gen.v1.urn.test.mainyangtest.data.MainCont other = (org.opendaylight.yang.gen.v1.urn.test.mainyangtest.data.MainCont)obj; - if (!Objects.equals(_mainGroupCont, other.getMainGroupCont())) { - return false; - } - if (getClass() == obj.getClass()) { - // Simple case: we are comparing against self - MainContImpl otherImpl = (MainContImpl) obj; - if (!Objects.equals(augmentation, otherImpl.augmentation)) { - return false; - } - } else { - // Hard case: compare our augments with presence there... - for (Map.Entry>, Augmentation> e : augmentation.entrySet()) { - if (!e.getValue().equals(other.getAugmentation(e.getKey()))) { - return false; - } - } - // .. and give the other one the chance to do the same - if (!obj.equals(this)) { - return false; - } - } - return true; - } - - @Override - public java.lang.String toString() { - java.lang.StringBuilder builder = new java.lang.StringBuilder ("MainCont ["); - boolean first = true; - - if (_mainGroupCont != null) { - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("_mainGroupCont="); - builder.append(_mainGroupCont); - } - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("augmentation="); - builder.append(augmentation.values()); - return builder.append(']').toString(); - } - } - -} diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/MainGroup.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/MainGroup.java deleted file mode 100644 index 6ce57c3100..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/MainGroup.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp; -import org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.MainGroupCont; -import org.opendaylight.yangtools.yang.binding.TreeNode; -import org.opendaylight.yangtools.yang.common.QName; - - -/** - *

This class represents the following YANG schema fragment defined in module mainYangTest - *

- * grouping main-group {
- *     container main-group-cont {
- *         container second-group-cont {
- *             leaf second-group-cont-leaf {
- *                 type string;
- *             }
- *         }
- *         leaf main-group-cont-leaf {
- *             type string;
- *         }
- *         list main-group-cont-list-ordered {
- *             key "name-1"
- *             leaf name-1 {
- *                 type string;
- *             }
- *             leaf type-1 {
- *                 type string;
- *             }
- *         }
- *         list main-group-cont-list-unordered {
- *             key "name-2"
- *             leaf name-2 {
- *                 type string;
- *             }
- *             leaf type-2 {
- *                 type string;
- *             }
- *         }
- *         choice main-group-cont-choice {
- *             case a {
- *                 leaf case-1 {
- *                     type string;
- *                 }
- *             }
- *             case b {
- *                 leaf case2-1 {
- *                     type string;
- *                 }
- *             }
- *         }
- *         leaf leaf-ref-test {
- *             type leafref;
- *         }
- *         uses second-group;
- *     }
- * }
- * 
- * The schema path to identify an instance is - * mainYangTest/main-group - * - */ -public interface MainGroup - extends - TreeNode -{ - - - - public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.create("urn:test:mainYangTest", - "2016-01-01", "main-group").intern(); - - MainGroupCont getMainGroupCont(); - -} - diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/SecondGroup.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/SecondGroup.java deleted file mode 100644 index 5e1fde36ab..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/SecondGroup.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp; -import org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.second.group.SecondGroupCont; -import org.opendaylight.yangtools.yang.binding.TreeNode; -import org.opendaylight.yangtools.yang.common.QName; - - -/** - *

This class represents the following YANG schema fragment defined in module mainYangTest - *

- * grouping second-group {
- *     container second-group-cont {
- *         leaf second-group-cont-leaf {
- *             type string;
- *         }
- *     }
- * }
- * 
- * The schema path to identify an instance is - * mainYangTest/second-group - * - */ -public interface SecondGroup - extends - TreeNode -{ - - - - public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.create("urn:test:mainYangTest", - "2016-01-01", "second-group").intern(); - - SecondGroupCont getSecondGroupCont(); - -} - diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/MainGroupCont.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/MainGroupCont.java deleted file mode 100644 index 44d7fb6dd4..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/MainGroupCont.java +++ /dev/null @@ -1,91 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group; -import org.opendaylight.yangtools.yang.binding.ChildTreeNode; -import org.opendaylight.yangtools.yang.common.QName; -import java.util.List; -import org.opendaylight.yangtools.yang.binding.Augmentable; -import org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.MainGroup; -import org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.SecondGroup; -import org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.MainGroupContChoice; -import org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.MainGroupContListOrdered; -import org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.MainGroupContListUnordered; - - -/** - *

This class represents the following YANG schema fragment defined in module mainYangTest - *

- * container main-group-cont {
- *     container second-group-cont {
- *         leaf second-group-cont-leaf {
- *             type string;
- *         }
- *     }
- *     leaf main-group-cont-leaf {
- *         type string;
- *     }
- *     list main-group-cont-list-ordered {
- *         key "name-1"
- *         leaf name-1 {
- *             type string;
- *         }
- *         leaf type-1 {
- *             type string;
- *         }
- *     }
- *     list main-group-cont-list-unordered {
- *         key "name-2"
- *         leaf name-2 {
- *             type string;
- *         }
- *         leaf type-2 {
- *             type string;
- *         }
- *     }
- *     choice main-group-cont-choice {
- *         case a {
- *             leaf case-1 {
- *                 type string;
- *             }
- *         }
- *         case b {
- *             leaf case2-1 {
- *                 type string;
- *             }
- *         }
- *     }
- *     leaf leaf-ref-test {
- *         type leafref;
- *     }
- *     uses second-group;
- * }
- * 
- * The schema path to identify an instance is - * mainYangTest/main-group/main-group-cont - * - *

To create instances of this class use {@link org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.MainGroupContBuilder}. - * @see org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.MainGroupContBuilder - * - */ -public interface MainGroupCont - extends - ChildTreeNode, - Augmentable, - SecondGroup -{ - - - - public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.create("urn:test:mainYangTest", - "2016-01-01", "main-group-cont").intern(); - - java.lang.String getMainGroupContLeaf(); - - List getMainGroupContListOrdered(); - - List getMainGroupContListUnordered(); - - MainGroupContChoice getMainGroupContChoice(); - - java.lang.String getLeafRefTest(); - -} - diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/MainGroupContBuilder.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/MainGroupContBuilder.java deleted file mode 100644 index 07a6596621..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/MainGroupContBuilder.java +++ /dev/null @@ -1,395 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group; -import org.opendaylight.yangtools.yang.binding.AugmentationHolder; -import java.util.HashMap; -import org.opendaylight.yangtools.concepts.Builder; -import org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.MainGroupContChoice; -import org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.MainGroupContListOrdered; -import org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.MainGroupContListUnordered; -import org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.second.group.SecondGroupCont; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.binding.TreeNode; -import java.util.Objects; -import java.util.List; -import java.util.Collections; -import java.util.Map; - - -/** - * Class that builds {@link org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.MainGroupCont} instances. - * - * @see org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.MainGroupCont - * - */ -public class MainGroupContBuilder implements Builder { - - private java.lang.String _leafRefTest; - private MainGroupContChoice _mainGroupContChoice; - private java.lang.String _mainGroupContLeaf; - private List _mainGroupContListOrdered; - private List _mainGroupContListUnordered; - private SecondGroupCont _secondGroupCont; - - Map>, Augmentation> augmentation = Collections.emptyMap(); - - public MainGroupContBuilder() { - } - public MainGroupContBuilder(org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.SecondGroup arg) { - this._secondGroupCont = arg.getSecondGroupCont(); - } - - public MainGroupContBuilder(MainGroupCont base) { - this._leafRefTest = base.getLeafRefTest(); - this._mainGroupContChoice = base.getMainGroupContChoice(); - this._mainGroupContLeaf = base.getMainGroupContLeaf(); - this._mainGroupContListOrdered = base.getMainGroupContListOrdered(); - this._mainGroupContListUnordered = base.getMainGroupContListUnordered(); - this._secondGroupCont = base.getSecondGroupCont(); - if (base instanceof MainGroupContImpl) { - MainGroupContImpl impl = (MainGroupContImpl) base; - if (!impl.augmentation.isEmpty()) { - this.augmentation = new HashMap<>(impl.augmentation); - } - } else if (base instanceof AugmentationHolder) { - @SuppressWarnings("unchecked") - AugmentationHolder casted =(AugmentationHolder) base; - if (!casted.augmentations().isEmpty()) { - this.augmentation = new HashMap<>(casted.augmentations()); - } - } - } - - /** - *Set fields from given grouping argument. Valid argument is instance of one of following types: - *

    - *
  • org.opendaylight.yang.gen.v1.urn.test.mainyangtest.rev160101.SecondGroup
  • - *
- * - * @param arg grouping object - * @throws IllegalArgumentException if given argument is none of valid types - */ - public void fieldsFrom(TreeNode arg) { - boolean isValidArg = false; - if (arg instanceof org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.SecondGroup) { - this._secondGroupCont = ((org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.SecondGroup)arg).getSecondGroupCont(); - isValidArg = true; - } - if (!isValidArg) { - throw new IllegalArgumentException( - "expected one of: [org.opendaylight.yang.gen.v1.urn.test.mainyangtest.rev160101.SecondGroup] \n" + - "but was: " + arg - ); - } - } - - public java.lang.String getLeafRefTest() { - return _leafRefTest; - } - - public MainGroupContChoice getMainGroupContChoice() { - return _mainGroupContChoice; - } - - public java.lang.String getMainGroupContLeaf() { - return _mainGroupContLeaf; - } - - public List getMainGroupContListOrdered() { - return _mainGroupContListOrdered; - } - - public List getMainGroupContListUnordered() { - return _mainGroupContListUnordered; - } - - public SecondGroupCont getSecondGroupCont() { - return _secondGroupCont; - } - - @SuppressWarnings("unchecked") - public > E getAugmentation(java.lang.Class augmentationType) { - if (augmentationType == null) { - throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); - } - return (E) augmentation.get(augmentationType); - } - - - public MainGroupContBuilder setLeafRefTest(final java.lang.String value) { - this._leafRefTest = value; - return this; - } - - - public MainGroupContBuilder setMainGroupContChoice(final MainGroupContChoice value) { - this._mainGroupContChoice = value; - return this; - } - - - public MainGroupContBuilder setMainGroupContLeaf(final java.lang.String value) { - this._mainGroupContLeaf = value; - return this; - } - - - public MainGroupContBuilder setMainGroupContListOrdered(final List value) { - this._mainGroupContListOrdered = value; - return this; - } - - - public MainGroupContBuilder setMainGroupContListUnordered(final List value) { - this._mainGroupContListUnordered = value; - return this; - } - - - public MainGroupContBuilder setSecondGroupCont(final SecondGroupCont value) { - this._secondGroupCont = value; - return this; - } - - public MainGroupContBuilder addAugmentation(java.lang.Class> augmentationType, Augmentation augmentation) { - if (augmentation == null) { - return removeAugmentation(augmentationType); - } - - if (!(this.augmentation instanceof HashMap)) { - this.augmentation = new HashMap<>(); - } - - this.augmentation.put(augmentationType, augmentation); - return this; - } - - public MainGroupContBuilder removeAugmentation(java.lang.Class> augmentationType) { - if (this.augmentation instanceof HashMap) { - this.augmentation.remove(augmentationType); - } - return this; - } - - public MainGroupCont build() { - return new MainGroupContImpl(this); - } - - private static final class MainGroupContImpl implements MainGroupCont { - - public java.lang.Class implementedInterface() { - return org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.MainGroupCont.class; - } - - private final java.lang.String _leafRefTest; - private final MainGroupContChoice _mainGroupContChoice; - private final java.lang.String _mainGroupContLeaf; - private final List _mainGroupContListOrdered; - private final List _mainGroupContListUnordered; - private final SecondGroupCont _secondGroupCont; - - private Map>, Augmentation> augmentation = Collections.emptyMap(); - - private MainGroupContImpl(MainGroupContBuilder base) { - this._leafRefTest = base.getLeafRefTest(); - this._mainGroupContChoice = base.getMainGroupContChoice(); - this._mainGroupContLeaf = base.getMainGroupContLeaf(); - this._mainGroupContListOrdered = base.getMainGroupContListOrdered(); - this._mainGroupContListUnordered = base.getMainGroupContListUnordered(); - this._secondGroupCont = base.getSecondGroupCont(); - switch (base.augmentation.size()) { - case 0: - this.augmentation = Collections.emptyMap(); - break; - case 1: - final Map.Entry>, Augmentation> e = base.augmentation.entrySet().iterator().next(); - this.augmentation = Collections.>, Augmentation>singletonMap(e.getKey(), e.getValue()); - break; - default : - this.augmentation = new HashMap<>(base.augmentation); - } - } - - @Override - public java.lang.String getLeafRefTest() { - return _leafRefTest; - } - - @Override - public MainGroupContChoice getMainGroupContChoice() { - return _mainGroupContChoice; - } - - @Override - public java.lang.String getMainGroupContLeaf() { - return _mainGroupContLeaf; - } - - @Override - public List getMainGroupContListOrdered() { - return _mainGroupContListOrdered; - } - - @Override - public List getMainGroupContListUnordered() { - return _mainGroupContListUnordered; - } - - @Override - public SecondGroupCont getSecondGroupCont() { - return _secondGroupCont; - } - - @SuppressWarnings("unchecked") - @Override - public > E getAugmentation(java.lang.Class augmentationType) { - if (augmentationType == null) { - throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); - } - return (E) augmentation.get(augmentationType); - } - - private int hash = 0; - private volatile boolean hashValid = false; - - @Override - public int hashCode() { - if (hashValid) { - return hash; - } - - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(_leafRefTest); - result = prime * result + Objects.hashCode(_mainGroupContChoice); - result = prime * result + Objects.hashCode(_mainGroupContLeaf); - result = prime * result + Objects.hashCode(_mainGroupContListOrdered); - result = prime * result + Objects.hashCode(_mainGroupContListUnordered); - result = prime * result + Objects.hashCode(_secondGroupCont); - result = prime * result + Objects.hashCode(augmentation); - - hash = result; - hashValid = true; - return result; - } - - @Override - public boolean equals(java.lang.Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof TreeNode)) { - return false; - } - if (!org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.MainGroupCont.class.equals(((TreeNode)obj).implementedInterface())) { - return false; - } - org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.MainGroupCont other = (org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.MainGroupCont)obj; - if (!Objects.equals(_leafRefTest, other.getLeafRefTest())) { - return false; - } - if (!Objects.equals(_mainGroupContChoice, other.getMainGroupContChoice())) { - return false; - } - if (!Objects.equals(_mainGroupContLeaf, other.getMainGroupContLeaf())) { - return false; - } - if (!Objects.equals(_mainGroupContListOrdered, other.getMainGroupContListOrdered())) { - return false; - } - if (!Objects.equals(_mainGroupContListUnordered, other.getMainGroupContListUnordered())) { - return false; - } - if (!Objects.equals(_secondGroupCont, other.getSecondGroupCont())) { - return false; - } - if (getClass() == obj.getClass()) { - // Simple case: we are comparing against self - MainGroupContImpl otherImpl = (MainGroupContImpl) obj; - if (!Objects.equals(augmentation, otherImpl.augmentation)) { - return false; - } - } else { - // Hard case: compare our augments with presence there... - for (Map.Entry>, Augmentation> e : augmentation.entrySet()) { - if (!e.getValue().equals(other.getAugmentation(e.getKey()))) { - return false; - } - } - // .. and give the other one the chance to do the same - if (!obj.equals(this)) { - return false; - } - } - return true; - } - - @Override - public java.lang.String toString() { - java.lang.StringBuilder builder = new java.lang.StringBuilder ("MainGroupCont ["); - boolean first = true; - - if (_leafRefTest != null) { - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("_leafRefTest="); - builder.append(_leafRefTest); - } - if (_mainGroupContChoice != null) { - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("_mainGroupContChoice="); - builder.append(_mainGroupContChoice); - } - if (_mainGroupContLeaf != null) { - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("_mainGroupContLeaf="); - builder.append(_mainGroupContLeaf); - } - if (_mainGroupContListOrdered != null) { - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("_mainGroupContListOrdered="); - builder.append(_mainGroupContListOrdered); - } - if (_mainGroupContListUnordered != null) { - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("_mainGroupContListUnordered="); - builder.append(_mainGroupContListUnordered); - } - if (_secondGroupCont != null) { - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("_secondGroupCont="); - builder.append(_secondGroupCont); - } - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("augmentation="); - builder.append(augmentation.values()); - return builder.append(']').toString(); - } - } - -} diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/MainGroupContChoice.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/MainGroupContChoice.java deleted file mode 100644 index 86a4be03bf..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/MainGroupContChoice.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont; -import org.opendaylight.yangtools.yang.binding.InterfaceTyped; -import org.opendaylight.yangtools.yang.common.QName; - - -/** - *

This class represents the following YANG schema fragment defined in module mainYangTest - *

- * choice main-group-cont-choice {
- *     case a {
- *         leaf case-1 {
- *             type string;
- *         }
- *     }
- *     case b {
- *         leaf case2-1 {
- *             type string;
- *         }
- *     }
- * }
- * 
- * The schema path to identify an instance is - * mainYangTest/main-group/main-group-cont/main-group-cont-choice - * - */ -public interface MainGroupContChoice - extends - InterfaceTyped -{ - - - - public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.create("urn:test:mainYangTest", - "2016-01-01", "main-group-cont-choice").intern(); - - -} - diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/MainGroupContListOrdered.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/MainGroupContListOrdered.java deleted file mode 100644 index 640266e55a..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/MainGroupContListOrdered.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont; -import org.opendaylight.yangtools.yang.binding.ChildTreeNode; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.MainGroupCont; -import org.opendaylight.yangtools.yang.binding.Augmentable; -import org.opendaylight.yangtools.yang.binding.IdentifiableListItem; - - -/** - *

This class represents the following YANG schema fragment defined in module mainYangTest - *

- * list main-group-cont-list-ordered {
- *     key "name-1"
- *     leaf name-1 {
- *         type string;
- *     }
- *     leaf type-1 {
- *         type string;
- *     }
- * }
- * 
- * The schema path to identify an instance is - * mainYangTest/main-group/main-group-cont/main-group-cont-list-ordered - * - *

To create instances of this class use {@link org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.MainGroupContListOrderedBuilder}. - * @see org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.MainGroupContListOrderedBuilder - * @see org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.MainGroupContListOrderedKey - * - */ -public interface MainGroupContListOrdered - extends - ChildTreeNode, - Augmentable, - IdentifiableListItem -{ - - - - public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.create("urn:test:mainYangTest", - "2016-01-01", "main-group-cont-list-ordered").intern(); - - java.lang.String getName1(); - - java.lang.String getType1(); - - /** - * Returns Primary Key of Yang List Type - * - */ - MainGroupContListOrderedKey identifier(); - -} - diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/MainGroupContListOrderedBuilder.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/MainGroupContListOrderedBuilder.java deleted file mode 100644 index a6f1368fdf..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/MainGroupContListOrderedBuilder.java +++ /dev/null @@ -1,283 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.binding.AugmentationHolder; -import org.opendaylight.yangtools.yang.binding.TreeNode; -import java.util.HashMap; -import org.opendaylight.yangtools.concepts.Builder; -import java.util.Objects; -import java.util.Collections; -import java.util.Map; - - -/** - * Class that builds {@link org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.MainGroupContListOrdered} instances. - * - * @see org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.MainGroupContListOrdered - * - */ -public class MainGroupContListOrderedBuilder implements Builder { - - private MainGroupContListOrderedKey _key; - private java.lang.String _name1; - private java.lang.String _type1; - - Map>, Augmentation> augmentation = Collections.emptyMap(); - - public MainGroupContListOrderedBuilder() { - } - - public MainGroupContListOrderedBuilder(MainGroupContListOrdered base) { - if (base.identifier() == null) { - this._key = new MainGroupContListOrderedKey( - base.getName1() - ); - this._name1 = base.getName1(); - } else { - this._key = base.identifier(); - this._name1 = _key.getName1(); - } - this._type1 = base.getType1(); - if (base instanceof MainGroupContListOrderedImpl) { - MainGroupContListOrderedImpl impl = (MainGroupContListOrderedImpl) base; - if (!impl.augmentation.isEmpty()) { - this.augmentation = new HashMap<>(impl.augmentation); - } - } else if (base instanceof AugmentationHolder) { - @SuppressWarnings("unchecked") - AugmentationHolder casted =(AugmentationHolder) base; - if (!casted.augmentations().isEmpty()) { - this.augmentation = new HashMap<>(casted.augmentations()); - } - } - } - - - public MainGroupContListOrderedKey getKey() { - return _key; - } - - public java.lang.String getName1() { - return _name1; - } - - public java.lang.String getType1() { - return _type1; - } - - @SuppressWarnings("unchecked") - public > E getAugmentation(java.lang.Class augmentationType) { - if (augmentationType == null) { - throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); - } - return (E) augmentation.get(augmentationType); - } - - - public MainGroupContListOrderedBuilder setKey(final MainGroupContListOrderedKey value) { - this._key = value; - return this; - } - - - public MainGroupContListOrderedBuilder setName1(final java.lang.String value) { - this._name1 = value; - return this; - } - - - public MainGroupContListOrderedBuilder setType1(final java.lang.String value) { - this._type1 = value; - return this; - } - - public MainGroupContListOrderedBuilder addAugmentation(java.lang.Class> augmentationType, Augmentation augmentation) { - if (augmentation == null) { - return removeAugmentation(augmentationType); - } - - if (!(this.augmentation instanceof HashMap)) { - this.augmentation = new HashMap<>(); - } - - this.augmentation.put(augmentationType, augmentation); - return this; - } - - public MainGroupContListOrderedBuilder removeAugmentation(java.lang.Class> augmentationType) { - if (this.augmentation instanceof HashMap) { - this.augmentation.remove(augmentationType); - } - return this; - } - - public MainGroupContListOrdered build() { - return new MainGroupContListOrderedImpl(this); - } - - private static final class MainGroupContListOrderedImpl implements MainGroupContListOrdered { - - public java.lang.Class implementedInterface() { - return org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.MainGroupContListOrdered.class; - } - - private final MainGroupContListOrderedKey _key; - private final java.lang.String _name1; - private final java.lang.String _type1; - - private Map>, Augmentation> augmentation = Collections.emptyMap(); - - private MainGroupContListOrderedImpl(MainGroupContListOrderedBuilder base) { - if (base.getKey() == null) { - this._key = new MainGroupContListOrderedKey( - base.getName1() - ); - this._name1 = base.getName1(); - } else { - this._key = base.getKey(); - this._name1 = _key.getName1(); - } - this._type1 = base.getType1(); - switch (base.augmentation.size()) { - case 0: - this.augmentation = Collections.emptyMap(); - break; - case 1: - final Map.Entry>, Augmentation> e = base.augmentation.entrySet().iterator().next(); - this.augmentation = Collections.>, Augmentation>singletonMap(e.getKey(), e.getValue()); - break; - default : - this.augmentation = new HashMap<>(base.augmentation); - } - } - - @Override - public MainGroupContListOrderedKey identifier() { - return _key; - } - - @Override - public java.lang.String getName1() { - return _name1; - } - - @Override - public java.lang.String getType1() { - return _type1; - } - - @SuppressWarnings("unchecked") - @Override - public > E getAugmentation(java.lang.Class augmentationType) { - if (augmentationType == null) { - throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); - } - return (E) augmentation.get(augmentationType); - } - - private int hash = 0; - private volatile boolean hashValid = false; - - @Override - public int hashCode() { - if (hashValid) { - return hash; - } - - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(_key); - result = prime * result + Objects.hashCode(_name1); - result = prime * result + Objects.hashCode(_type1); - result = prime * result + Objects.hashCode(augmentation); - - hash = result; - hashValid = true; - return result; - } - - @Override - public boolean equals(java.lang.Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof TreeNode)) { - return false; - } - if (!org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.MainGroupContListOrdered.class.equals(((TreeNode)obj).implementedInterface())) { - return false; - } - org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.MainGroupContListOrdered other = (org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.MainGroupContListOrdered)obj; - if (!Objects.equals(_key, other.identifier())) { - return false; - } - if (!Objects.equals(_name1, other.getName1())) { - return false; - } - if (!Objects.equals(_type1, other.getType1())) { - return false; - } - if (getClass() == obj.getClass()) { - // Simple case: we are comparing against self - MainGroupContListOrderedImpl otherImpl = (MainGroupContListOrderedImpl) obj; - if (!Objects.equals(augmentation, otherImpl.augmentation)) { - return false; - } - } else { - // Hard case: compare our augments with presence there... - for (Map.Entry>, Augmentation> e : augmentation.entrySet()) { - if (!e.getValue().equals(other.getAugmentation(e.getKey()))) { - return false; - } - } - // .. and give the other one the chance to do the same - if (!obj.equals(this)) { - return false; - } - } - return true; - } - - @Override - public java.lang.String toString() { - java.lang.StringBuilder builder = new java.lang.StringBuilder ("MainGroupContListOrdered ["); - boolean first = true; - - if (_key != null) { - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("_key="); - builder.append(_key); - } - if (_name1 != null) { - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("_name1="); - builder.append(_name1); - } - if (_type1 != null) { - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("_type1="); - builder.append(_type1); - } - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("augmentation="); - builder.append(augmentation.values()); - return builder.append(']').toString(); - } - } - -} diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/MainGroupContListOrderedKey.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/MainGroupContListOrderedKey.java deleted file mode 100644 index 857620fe8e..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/MainGroupContListOrderedKey.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont; -import org.opendaylight.yangtools.yang.binding.Identifier; -import java.util.Objects; - - -public class MainGroupContListOrderedKey - implements Identifier { - private static final long serialVersionUID = -7926731649945418745L; - private final java.lang.String _name1; - - - public MainGroupContListOrderedKey(java.lang.String _name1) { - - - this._name1 = _name1; - } - - /** - * Creates a copy from Source Object. - * - * @param source Source object - */ - public MainGroupContListOrderedKey(MainGroupContListOrderedKey source) { - this._name1 = source._name1; - } - - - public java.lang.String getName1() { - return _name1; - } - - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(_name1); - return result; - } - - @Override - public boolean equals(java.lang.Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - MainGroupContListOrderedKey other = (MainGroupContListOrderedKey) obj; - if (!Objects.equals(_name1, other._name1)) { - return false; - } - return true; - } - - @Override - public java.lang.String toString() { - java.lang.StringBuilder builder = new java.lang.StringBuilder(org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.MainGroupContListOrderedKey.class.getSimpleName()).append(" ["); - boolean first = true; - - if (_name1 != null) { - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("_name1="); - builder.append(_name1); - } - return builder.append(']').toString(); - } -} - diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/MainGroupContListUnordered.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/MainGroupContListUnordered.java deleted file mode 100644 index 79dcabedef..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/MainGroupContListUnordered.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont; -import org.opendaylight.yangtools.yang.binding.ChildTreeNode; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.MainGroupCont; -import org.opendaylight.yangtools.yang.binding.Augmentable; -import org.opendaylight.yangtools.yang.binding.IdentifiableListItem; - - -/** - *

This class represents the following YANG schema fragment defined in module mainYangTest - *

- * list main-group-cont-list-unordered {
- *     key "name-2"
- *     leaf name-2 {
- *         type string;
- *     }
- *     leaf type-2 {
- *         type string;
- *     }
- * }
- * 
- * The schema path to identify an instance is - * mainYangTest/main-group/main-group-cont/main-group-cont-list-unordered - * - *

To create instances of this class use {@link org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.MainGroupContListUnorderedBuilder}. - * @see org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.MainGroupContListUnorderedBuilder - * @see org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.MainGroupContListUnorderedKey - * - */ -public interface MainGroupContListUnordered - extends - ChildTreeNode, - Augmentable, - IdentifiableListItem -{ - - - - public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.create("urn:test:mainYangTest", - "2016-01-01", "main-group-cont-list-unordered").intern(); - - java.lang.String getName2(); - - java.lang.String getType2(); - - /** - * Returns Primary Key of Yang List Type - * - */ - MainGroupContListUnorderedKey identifier(); - -} - diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/MainGroupContListUnorderedBuilder.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/MainGroupContListUnorderedBuilder.java deleted file mode 100644 index b46ba3597f..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/MainGroupContListUnorderedBuilder.java +++ /dev/null @@ -1,283 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.binding.AugmentationHolder; -import org.opendaylight.yangtools.yang.binding.TreeNode; -import java.util.HashMap; -import org.opendaylight.yangtools.concepts.Builder; -import java.util.Objects; -import java.util.Collections; -import java.util.Map; - - -/** - * Class that builds {@link org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.MainGroupContListUnordered} instances. - * - * @see org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.MainGroupContListUnordered - * - */ -public class MainGroupContListUnorderedBuilder implements Builder { - - private MainGroupContListUnorderedKey _key; - private java.lang.String _name2; - private java.lang.String _type2; - - Map>, Augmentation> augmentation = Collections.emptyMap(); - - public MainGroupContListUnorderedBuilder() { - } - - public MainGroupContListUnorderedBuilder(MainGroupContListUnordered base) { - if (base.identifier() == null) { - this._key = new MainGroupContListUnorderedKey( - base.getName2() - ); - this._name2 = base.getName2(); - } else { - this._key = base.identifier(); - this._name2 = _key.getName2(); - } - this._type2 = base.getType2(); - if (base instanceof MainGroupContListUnorderedImpl) { - MainGroupContListUnorderedImpl impl = (MainGroupContListUnorderedImpl) base; - if (!impl.augmentation.isEmpty()) { - this.augmentation = new HashMap<>(impl.augmentation); - } - } else if (base instanceof AugmentationHolder) { - @SuppressWarnings("unchecked") - AugmentationHolder casted =(AugmentationHolder) base; - if (!casted.augmentations().isEmpty()) { - this.augmentation = new HashMap<>(casted.augmentations()); - } - } - } - - - public MainGroupContListUnorderedKey getKey() { - return _key; - } - - public java.lang.String getName2() { - return _name2; - } - - public java.lang.String getType2() { - return _type2; - } - - @SuppressWarnings("unchecked") - public > E getAugmentation(java.lang.Class augmentationType) { - if (augmentationType == null) { - throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); - } - return (E) augmentation.get(augmentationType); - } - - - public MainGroupContListUnorderedBuilder setKey(final MainGroupContListUnorderedKey value) { - this._key = value; - return this; - } - - - public MainGroupContListUnorderedBuilder setName2(final java.lang.String value) { - this._name2 = value; - return this; - } - - - public MainGroupContListUnorderedBuilder setType2(final java.lang.String value) { - this._type2 = value; - return this; - } - - public MainGroupContListUnorderedBuilder addAugmentation(java.lang.Class> augmentationType, Augmentation augmentation) { - if (augmentation == null) { - return removeAugmentation(augmentationType); - } - - if (!(this.augmentation instanceof HashMap)) { - this.augmentation = new HashMap<>(); - } - - this.augmentation.put(augmentationType, augmentation); - return this; - } - - public MainGroupContListUnorderedBuilder removeAugmentation(java.lang.Class> augmentationType) { - if (this.augmentation instanceof HashMap) { - this.augmentation.remove(augmentationType); - } - return this; - } - - public MainGroupContListUnordered build() { - return new MainGroupContListUnorderedImpl(this); - } - - private static final class MainGroupContListUnorderedImpl implements MainGroupContListUnordered { - - public java.lang.Class implementedInterface() { - return org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.MainGroupContListUnordered.class; - } - - private final MainGroupContListUnorderedKey _key; - private final java.lang.String _name2; - private final java.lang.String _type2; - - private Map>, Augmentation> augmentation = Collections.emptyMap(); - - private MainGroupContListUnorderedImpl(MainGroupContListUnorderedBuilder base) { - if (base.getKey() == null) { - this._key = new MainGroupContListUnorderedKey( - base.getName2() - ); - this._name2 = base.getName2(); - } else { - this._key = base.getKey(); - this._name2 = _key.getName2(); - } - this._type2 = base.getType2(); - switch (base.augmentation.size()) { - case 0: - this.augmentation = Collections.emptyMap(); - break; - case 1: - final Map.Entry>, Augmentation> e = base.augmentation.entrySet().iterator().next(); - this.augmentation = Collections.>, Augmentation>singletonMap(e.getKey(), e.getValue()); - break; - default : - this.augmentation = new HashMap<>(base.augmentation); - } - } - - @Override - public MainGroupContListUnorderedKey identifier() { - return _key; - } - - @Override - public java.lang.String getName2() { - return _name2; - } - - @Override - public java.lang.String getType2() { - return _type2; - } - - @SuppressWarnings("unchecked") - @Override - public > E getAugmentation(java.lang.Class augmentationType) { - if (augmentationType == null) { - throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); - } - return (E) augmentation.get(augmentationType); - } - - private int hash = 0; - private volatile boolean hashValid = false; - - @Override - public int hashCode() { - if (hashValid) { - return hash; - } - - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(_key); - result = prime * result + Objects.hashCode(_name2); - result = prime * result + Objects.hashCode(_type2); - result = prime * result + Objects.hashCode(augmentation); - - hash = result; - hashValid = true; - return result; - } - - @Override - public boolean equals(java.lang.Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof TreeNode)) { - return false; - } - if (!org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.MainGroupContListUnordered.class.equals(((TreeNode)obj).implementedInterface())) { - return false; - } - org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.MainGroupContListUnordered other = (org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.MainGroupContListUnordered)obj; - if (!Objects.equals(_key, other.identifier())) { - return false; - } - if (!Objects.equals(_name2, other.getName2())) { - return false; - } - if (!Objects.equals(_type2, other.getType2())) { - return false; - } - if (getClass() == obj.getClass()) { - // Simple case: we are comparing against self - MainGroupContListUnorderedImpl otherImpl = (MainGroupContListUnorderedImpl) obj; - if (!Objects.equals(augmentation, otherImpl.augmentation)) { - return false; - } - } else { - // Hard case: compare our augments with presence there... - for (Map.Entry>, Augmentation> e : augmentation.entrySet()) { - if (!e.getValue().equals(other.getAugmentation(e.getKey()))) { - return false; - } - } - // .. and give the other one the chance to do the same - if (!obj.equals(this)) { - return false; - } - } - return true; - } - - @Override - public java.lang.String toString() { - java.lang.StringBuilder builder = new java.lang.StringBuilder ("MainGroupContListUnordered ["); - boolean first = true; - - if (_key != null) { - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("_key="); - builder.append(_key); - } - if (_name2 != null) { - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("_name2="); - builder.append(_name2); - } - if (_type2 != null) { - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("_type2="); - builder.append(_type2); - } - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("augmentation="); - builder.append(augmentation.values()); - return builder.append(']').toString(); - } - } - -} diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/MainGroupContListUnorderedKey.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/MainGroupContListUnorderedKey.java deleted file mode 100644 index 4104774e9b..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/MainGroupContListUnorderedKey.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont; -import org.opendaylight.yangtools.yang.binding.Identifier; -import java.util.Objects; - - -public class MainGroupContListUnorderedKey - implements Identifier { - private static final long serialVersionUID = 3614369169157466116L; - private final java.lang.String _name2; - - - public MainGroupContListUnorderedKey(java.lang.String _name2) { - - - this._name2 = _name2; - } - - /** - * Creates a copy from Source Object. - * - * @param source Source object - */ - public MainGroupContListUnorderedKey(MainGroupContListUnorderedKey source) { - this._name2 = source._name2; - } - - - public java.lang.String getName2() { - return _name2; - } - - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(_name2); - return result; - } - - @Override - public boolean equals(java.lang.Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - MainGroupContListUnorderedKey other = (MainGroupContListUnorderedKey) obj; - if (!Objects.equals(_name2, other._name2)) { - return false; - } - return true; - } - - @Override - public java.lang.String toString() { - java.lang.StringBuilder builder = new java.lang.StringBuilder(org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.MainGroupContListUnorderedKey.class.getSimpleName()).append(" ["); - boolean first = true; - - if (_name2 != null) { - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("_name2="); - builder.append(_name2); - } - return builder.append(']').toString(); - } -} - diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/main/group/cont/choice/A.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/main/group/cont/choice/A.java deleted file mode 100644 index a449fc341f..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/main/group/cont/choice/A.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice; -import org.opendaylight.yangtools.yang.binding.TreeNode; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.MainGroupContChoice; -import org.opendaylight.yangtools.yang.binding.Augmentable; - - -/** - *

This class represents the following YANG schema fragment defined in module mainYangTest - *

- * case a {
- *     leaf case-1 {
- *         type string;
- *     }
- * }
- * 
- * The schema path to identify an instance is - * mainYangTest/main-group/main-group-cont/main-group-cont-choice/a - * - */ -public interface A - extends - TreeNode, - Augmentable, - MainGroupContChoice -{ - - - - public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.create("urn:test:mainYangTest", - "2016-01-01", "a").intern(); - - java.lang.String getCase1(); - -} - diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/main/group/cont/choice/ABuilder.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/main/group/cont/choice/ABuilder.java deleted file mode 100644 index be5d73aabf..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/main/group/cont/choice/ABuilder.java +++ /dev/null @@ -1,205 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.binding.AugmentationHolder; -import org.opendaylight.yangtools.yang.binding.TreeNode; -import java.util.HashMap; -import org.opendaylight.yangtools.concepts.Builder; -import java.util.Objects; -import java.util.Collections; -import java.util.Map; - - -/** - * Class that builds {@link org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.A} instances. - * - * @see org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.A - * - */ -public class ABuilder implements Builder { - - private java.lang.String _case1; - - Map>, Augmentation> augmentation = Collections.emptyMap(); - - public ABuilder() { - } - - public ABuilder(A base) { - this._case1 = base.getCase1(); - if (base instanceof AImpl) { - AImpl impl = (AImpl) base; - if (!impl.augmentation.isEmpty()) { - this.augmentation = new HashMap<>(impl.augmentation); - } - } else if (base instanceof AugmentationHolder) { - @SuppressWarnings("unchecked") - AugmentationHolder casted =(AugmentationHolder) base; - if (!casted.augmentations().isEmpty()) { - this.augmentation = new HashMap<>(casted.augmentations()); - } - } - } - - - public java.lang.String getCase1() { - return _case1; - } - - @SuppressWarnings("unchecked") - public > E getAugmentation(java.lang.Class augmentationType) { - if (augmentationType == null) { - throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); - } - return (E) augmentation.get(augmentationType); - } - - - public ABuilder setCase1(final java.lang.String value) { - this._case1 = value; - return this; - } - - public ABuilder addAugmentation(java.lang.Class> augmentationType, Augmentation augmentation) { - if (augmentation == null) { - return removeAugmentation(augmentationType); - } - - if (!(this.augmentation instanceof HashMap)) { - this.augmentation = new HashMap<>(); - } - - this.augmentation.put(augmentationType, augmentation); - return this; - } - - public ABuilder removeAugmentation(java.lang.Class> augmentationType) { - if (this.augmentation instanceof HashMap) { - this.augmentation.remove(augmentationType); - } - return this; - } - - public A build() { - return new AImpl(this); - } - - private static final class AImpl implements A { - - public java.lang.Class implementedInterface() { - return org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.A.class; - } - - private final java.lang.String _case1; - - private Map>, Augmentation> augmentation = Collections.emptyMap(); - - private AImpl(ABuilder base) { - this._case1 = base.getCase1(); - switch (base.augmentation.size()) { - case 0: - this.augmentation = Collections.emptyMap(); - break; - case 1: - final Map.Entry>, Augmentation> e = base.augmentation.entrySet().iterator().next(); - this.augmentation = Collections.>, Augmentation>singletonMap(e.getKey(), e.getValue()); - break; - default : - this.augmentation = new HashMap<>(base.augmentation); - } - } - - @Override - public java.lang.String getCase1() { - return _case1; - } - - @SuppressWarnings("unchecked") - @Override - public > E getAugmentation(java.lang.Class augmentationType) { - if (augmentationType == null) { - throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); - } - return (E) augmentation.get(augmentationType); - } - - private int hash = 0; - private volatile boolean hashValid = false; - - @Override - public int hashCode() { - if (hashValid) { - return hash; - } - - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(_case1); - result = prime * result + Objects.hashCode(augmentation); - - hash = result; - hashValid = true; - return result; - } - - @Override - public boolean equals(java.lang.Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof TreeNode)) { - return false; - } - if (!org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.A.class.equals(((TreeNode)obj).implementedInterface())) { - return false; - } - org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.A other = (org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.A)obj; - if (!Objects.equals(_case1, other.getCase1())) { - return false; - } - if (getClass() == obj.getClass()) { - // Simple case: we are comparing against self - AImpl otherImpl = (AImpl) obj; - if (!Objects.equals(augmentation, otherImpl.augmentation)) { - return false; - } - } else { - // Hard case: compare our augments with presence there... - for (Map.Entry>, Augmentation> e : augmentation.entrySet()) { - if (!e.getValue().equals(other.getAugmentation(e.getKey()))) { - return false; - } - } - // .. and give the other one the chance to do the same - if (!obj.equals(this)) { - return false; - } - } - return true; - } - - @Override - public java.lang.String toString() { - java.lang.StringBuilder builder = new java.lang.StringBuilder ("A ["); - boolean first = true; - - if (_case1 != null) { - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("_case1="); - builder.append(_case1); - } - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("augmentation="); - builder.append(augmentation.values()); - return builder.append(']').toString(); - } - } - -} diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/main/group/cont/choice/B.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/main/group/cont/choice/B.java deleted file mode 100644 index 71cf1af645..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/main/group/cont/choice/B.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice; -import org.opendaylight.yangtools.yang.binding.TreeNode; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.MainGroupContChoice; -import org.opendaylight.yangtools.yang.binding.Augmentable; - - -/** - *

This class represents the following YANG schema fragment defined in module mainYangTest - *

- * case b {
- *     leaf case2-1 {
- *         type string;
- *     }
- * }
- * 
- * The schema path to identify an instance is - * mainYangTest/main-group/main-group-cont/main-group-cont-choice/b - * - */ -public interface B - extends - TreeNode, - Augmentable, - MainGroupContChoice -{ - - - - public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.create("urn:test:mainYangTest", - "2016-01-01", "b").intern(); - - java.lang.String getCase21(); - -} - diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/main/group/cont/choice/BBuilder.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/main/group/cont/choice/BBuilder.java deleted file mode 100644 index 988c366a86..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/main/group/main/group/cont/main/group/cont/choice/BBuilder.java +++ /dev/null @@ -1,205 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.binding.AugmentationHolder; -import org.opendaylight.yangtools.yang.binding.TreeNode; -import java.util.HashMap; -import org.opendaylight.yangtools.concepts.Builder; -import java.util.Objects; -import java.util.Collections; -import java.util.Map; - - -/** - * Class that builds {@link org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.B} instances. - * - * @see org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.B - * - */ -public class BBuilder implements Builder { - - private java.lang.String _case21; - - Map>, Augmentation> augmentation = Collections.emptyMap(); - - public BBuilder() { - } - - public BBuilder(B base) { - this._case21 = base.getCase21(); - if (base instanceof BImpl) { - BImpl impl = (BImpl) base; - if (!impl.augmentation.isEmpty()) { - this.augmentation = new HashMap<>(impl.augmentation); - } - } else if (base instanceof AugmentationHolder) { - @SuppressWarnings("unchecked") - AugmentationHolder casted =(AugmentationHolder) base; - if (!casted.augmentations().isEmpty()) { - this.augmentation = new HashMap<>(casted.augmentations()); - } - } - } - - - public java.lang.String getCase21() { - return _case21; - } - - @SuppressWarnings("unchecked") - public > E getAugmentation(java.lang.Class augmentationType) { - if (augmentationType == null) { - throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); - } - return (E) augmentation.get(augmentationType); - } - - - public BBuilder setCase21(final java.lang.String value) { - this._case21 = value; - return this; - } - - public BBuilder addAugmentation(java.lang.Class> augmentationType, Augmentation augmentation) { - if (augmentation == null) { - return removeAugmentation(augmentationType); - } - - if (!(this.augmentation instanceof HashMap)) { - this.augmentation = new HashMap<>(); - } - - this.augmentation.put(augmentationType, augmentation); - return this; - } - - public BBuilder removeAugmentation(java.lang.Class> augmentationType) { - if (this.augmentation instanceof HashMap) { - this.augmentation.remove(augmentationType); - } - return this; - } - - public B build() { - return new BImpl(this); - } - - private static final class BImpl implements B { - - public java.lang.Class implementedInterface() { - return org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.B.class; - } - - private final java.lang.String _case21; - - private Map>, Augmentation> augmentation = Collections.emptyMap(); - - private BImpl(BBuilder base) { - this._case21 = base.getCase21(); - switch (base.augmentation.size()) { - case 0: - this.augmentation = Collections.emptyMap(); - break; - case 1: - final Map.Entry>, Augmentation> e = base.augmentation.entrySet().iterator().next(); - this.augmentation = Collections.>, Augmentation>singletonMap(e.getKey(), e.getValue()); - break; - default : - this.augmentation = new HashMap<>(base.augmentation); - } - } - - @Override - public java.lang.String getCase21() { - return _case21; - } - - @SuppressWarnings("unchecked") - @Override - public > E getAugmentation(java.lang.Class augmentationType) { - if (augmentationType == null) { - throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); - } - return (E) augmentation.get(augmentationType); - } - - private int hash = 0; - private volatile boolean hashValid = false; - - @Override - public int hashCode() { - if (hashValid) { - return hash; - } - - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(_case21); - result = prime * result + Objects.hashCode(augmentation); - - hash = result; - hashValid = true; - return result; - } - - @Override - public boolean equals(java.lang.Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof TreeNode)) { - return false; - } - if (!org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.B.class.equals(((TreeNode)obj).implementedInterface())) { - return false; - } - org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.B other = (org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.B)obj; - if (!Objects.equals(_case21, other.getCase21())) { - return false; - } - if (getClass() == obj.getClass()) { - // Simple case: we are comparing against self - BImpl otherImpl = (BImpl) obj; - if (!Objects.equals(augmentation, otherImpl.augmentation)) { - return false; - } - } else { - // Hard case: compare our augments with presence there... - for (Map.Entry>, Augmentation> e : augmentation.entrySet()) { - if (!e.getValue().equals(other.getAugmentation(e.getKey()))) { - return false; - } - } - // .. and give the other one the chance to do the same - if (!obj.equals(this)) { - return false; - } - } - return true; - } - - @Override - public java.lang.String toString() { - java.lang.StringBuilder builder = new java.lang.StringBuilder ("B ["); - boolean first = true; - - if (_case21 != null) { - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("_case21="); - builder.append(_case21); - } - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("augmentation="); - builder.append(augmentation.values()); - return builder.append(']').toString(); - } - } - -} diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/second/group/SecondGroupCont.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/second/group/SecondGroupCont.java deleted file mode 100644 index dcb217fb12..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/second/group/SecondGroupCont.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.second.group; -import org.opendaylight.yangtools.yang.binding.ChildTreeNode; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.SecondGroup; -import org.opendaylight.yangtools.yang.binding.Augmentable; - - -/** - *

This class represents the following YANG schema fragment defined in module mainYangTest - *

- * container second-group-cont {
- *     leaf second-group-cont-leaf {
- *         type string;
- *     }
- * }
- * 
- * The schema path to identify an instance is - * mainYangTest/second-group/second-group-cont - * - *

To create instances of this class use {@link org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.second.group.SecondGroupContBuilder}. - * @see org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.second.group.SecondGroupContBuilder - * - */ -public interface SecondGroupCont - extends - ChildTreeNode, - Augmentable -{ - - - - public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.create("urn:test:mainYangTest", - "2016-01-01", "second-group-cont").intern(); - - java.lang.String getSecondGroupContLeaf(); - -} - diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/second/group/SecondGroupContBuilder.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/second/group/SecondGroupContBuilder.java deleted file mode 100644 index d091098096..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtest/grp/second/group/SecondGroupContBuilder.java +++ /dev/null @@ -1,205 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.second.group; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.binding.AugmentationHolder; -import org.opendaylight.yangtools.yang.binding.TreeNode; -import java.util.HashMap; -import org.opendaylight.yangtools.concepts.Builder; -import java.util.Objects; -import java.util.Collections; -import java.util.Map; - - -/** - * Class that builds {@link org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.second.group.SecondGroupCont} instances. - * - * @see org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.second.group.SecondGroupCont - * - */ -public class SecondGroupContBuilder implements Builder { - - private java.lang.String _secondGroupContLeaf; - - Map>, Augmentation> augmentation = Collections.emptyMap(); - - public SecondGroupContBuilder() { - } - - public SecondGroupContBuilder(SecondGroupCont base) { - this._secondGroupContLeaf = base.getSecondGroupContLeaf(); - if (base instanceof SecondGroupContImpl) { - SecondGroupContImpl impl = (SecondGroupContImpl) base; - if (!impl.augmentation.isEmpty()) { - this.augmentation = new HashMap<>(impl.augmentation); - } - } else if (base instanceof AugmentationHolder) { - @SuppressWarnings("unchecked") - AugmentationHolder casted =(AugmentationHolder) base; - if (!casted.augmentations().isEmpty()) { - this.augmentation = new HashMap<>(casted.augmentations()); - } - } - } - - - public java.lang.String getSecondGroupContLeaf() { - return _secondGroupContLeaf; - } - - @SuppressWarnings("unchecked") - public > E getAugmentation(java.lang.Class augmentationType) { - if (augmentationType == null) { - throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); - } - return (E) augmentation.get(augmentationType); - } - - - public SecondGroupContBuilder setSecondGroupContLeaf(final java.lang.String value) { - this._secondGroupContLeaf = value; - return this; - } - - public SecondGroupContBuilder addAugmentation(java.lang.Class> augmentationType, Augmentation augmentation) { - if (augmentation == null) { - return removeAugmentation(augmentationType); - } - - if (!(this.augmentation instanceof HashMap)) { - this.augmentation = new HashMap<>(); - } - - this.augmentation.put(augmentationType, augmentation); - return this; - } - - public SecondGroupContBuilder removeAugmentation(java.lang.Class> augmentationType) { - if (this.augmentation instanceof HashMap) { - this.augmentation.remove(augmentationType); - } - return this; - } - - public SecondGroupCont build() { - return new SecondGroupContImpl(this); - } - - private static final class SecondGroupContImpl implements SecondGroupCont { - - public java.lang.Class implementedInterface() { - return org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.second.group.SecondGroupCont.class; - } - - private final java.lang.String _secondGroupContLeaf; - - private Map>, Augmentation> augmentation = Collections.emptyMap(); - - private SecondGroupContImpl(SecondGroupContBuilder base) { - this._secondGroupContLeaf = base.getSecondGroupContLeaf(); - switch (base.augmentation.size()) { - case 0: - this.augmentation = Collections.emptyMap(); - break; - case 1: - final Map.Entry>, Augmentation> e = base.augmentation.entrySet().iterator().next(); - this.augmentation = Collections.>, Augmentation>singletonMap(e.getKey(), e.getValue()); - break; - default : - this.augmentation = new HashMap<>(base.augmentation); - } - } - - @Override - public java.lang.String getSecondGroupContLeaf() { - return _secondGroupContLeaf; - } - - @SuppressWarnings("unchecked") - @Override - public > E getAugmentation(java.lang.Class augmentationType) { - if (augmentationType == null) { - throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); - } - return (E) augmentation.get(augmentationType); - } - - private int hash = 0; - private volatile boolean hashValid = false; - - @Override - public int hashCode() { - if (hashValid) { - return hash; - } - - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(_secondGroupContLeaf); - result = prime * result + Objects.hashCode(augmentation); - - hash = result; - hashValid = true; - return result; - } - - @Override - public boolean equals(java.lang.Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof TreeNode)) { - return false; - } - if (!org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.second.group.SecondGroupCont.class.equals(((TreeNode)obj).implementedInterface())) { - return false; - } - org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.second.group.SecondGroupCont other = (org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.second.group.SecondGroupCont)obj; - if (!Objects.equals(_secondGroupContLeaf, other.getSecondGroupContLeaf())) { - return false; - } - if (getClass() == obj.getClass()) { - // Simple case: we are comparing against self - SecondGroupContImpl otherImpl = (SecondGroupContImpl) obj; - if (!Objects.equals(augmentation, otherImpl.augmentation)) { - return false; - } - } else { - // Hard case: compare our augments with presence there... - for (Map.Entry>, Augmentation> e : augmentation.entrySet()) { - if (!e.getValue().equals(other.getAugmentation(e.getKey()))) { - return false; - } - } - // .. and give the other one the chance to do the same - if (!obj.equals(this)) { - return false; - } - } - return true; - } - - @Override - public java.lang.String toString() { - java.lang.StringBuilder builder = new java.lang.StringBuilder ("SecondGroupCont ["); - boolean first = true; - - if (_secondGroupContLeaf != null) { - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("_secondGroupContLeaf="); - builder.append(_secondGroupContLeaf); - } - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("augmentation="); - builder.append(augmentation.values()); - return builder.append(']').toString(); - } - } - -} diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/$YangModelBindingProvider.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/$YangModelBindingProvider.java deleted file mode 100644 index 57134bbf6b..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/$YangModelBindingProvider.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting; - -public final class $YangModelBindingProvider implements org.opendaylight.yangtools.yang.binding.YangModelBindingProvider { - - public org.opendaylight.yangtools.yang.binding.YangModuleInfo getModuleInfo() { - return $YangModuleInfoImpl.getInstance(); - } -} diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/$YangModuleInfoImpl.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/$YangModuleInfoImpl.java deleted file mode 100644 index 9b1fb1acd4..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/$YangModuleInfoImpl.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting; -import org.opendaylight.yangtools.yang.binding.YangModuleInfo; -import java.util.Set; -import java.util.HashSet; -import com.google.common.collect.ImmutableSet; -import java.io.InputStream; -import java.io.IOException; -public final class $YangModuleInfoImpl implements YangModuleInfo { - - private static final YangModuleInfo INSTANCE = new $YangModuleInfoImpl(); - - private final String name = "mainYangTestImporting"; - private final String namespace = "urn:test:mainYangTestImporting"; - private final String revision = "2016-01-01"; - private final String resourcePath = "/META-INF/yang/mainYangTestImporting.yang"; - - private final Set importedModules; - - public static YangModuleInfo getInstance() { - return INSTANCE; - } - - private $YangModuleInfoImpl() { - Set set = new HashSet<>(); - set.add(org.opendaylight.yang.gen.v1.urn.test.mainyangtest.$YangModuleInfoImpl.getInstance()); - importedModules = ImmutableSet.copyOf(set); - - InputStream stream = $YangModuleInfoImpl.class.getResourceAsStream(resourcePath); - if (stream == null) { - throw new IllegalStateException("Resource '" + resourcePath + "' is missing"); - } - try { - stream.close(); - } catch (IOException e) { - // Resource leak, but there is nothing we can do - } - } - - @Override - public String getName() { - return name; - } - - @Override - public String getRevision() { - return revision; - } - - @Override - public String getNamespace() { - return namespace; - } - - @Override - public InputStream getModuleSourceStream() throws IOException { - InputStream stream = $YangModuleInfoImpl.class.getResourceAsStream(resourcePath); - if (stream == null) { - throw new IOException("Resource " + resourcePath + " is missing"); - } - return stream; - } - - @Override - public Set getImportedModules() { - return importedModules; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(this.getClass().getCanonicalName()); - sb.append("["); - sb.append("name = " + name); - sb.append(", namespace = " + namespace); - sb.append(", revision = " + revision); - sb.append(", resourcePath = " + resourcePath); - sb.append(", imports = " + importedModules); - sb.append("]"); - return sb.toString(); - } - - -} diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/MainYangTestImportingData.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/MainYangTestImportingData.java deleted file mode 100644 index ff8b38d109..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/MainYangTestImportingData.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting; -import org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data.ImportingContainer; -import org.opendaylight.yangtools.yang.binding.TreeRoot; - - -/** - *

This class represents the following YANG schema fragment defined in module mainYangTestImporting - *

- * module mainYangTestImporting {
- *     yang-version 1;
- *     namespace "urn:test:mainYangTestImporting";
- *     prefix "myti";
- *
- *     import mainYangTest { prefix "imp"; }
- *     revision 2016-01-01 {
- *         description "";
- *     }
- *
- *     container importing-container {
- *         container main-group-cont {
- *             leaf main-group-cont-leaf {
- *                 type string;
- *             }
- *             list main-group-cont-list-ordered {
- *                 key "name-1"
- *                 leaf name-1 {
- *                     type string;
- *                 }
- *                 leaf type-1 {
- *                     type string;
- *                 }
- *             }
- *             list main-group-cont-list-unordered {
- *                 key "name-2"
- *                 leaf name-2 {
- *                     type string;
- *                 }
- *                 leaf type-2 {
- *                     type string;
- *                 }
- *             }
- *             choice main-group-cont-choice {
- *                 case a {
- *                     leaf case-1 {
- *                         type string;
- *                     }
- *                 }
- *                 case b {
- *                     leaf case2-1 {
- *                         type string;
- *                     }
- *                 }
- *             }
- *             leaf leaf-ref-test {
- *                 type leafref;
- *             }
- *             container second-group-cont {
- *                 leaf second-group-cont-leaf {
- *                     type string;
- *                 }
- *             }
- *             leaf imported-augmented-leaf-3 {
- *                 type string;
- *             }
- *             augment \(urn:test:mainYangTestImporting)importing-container\(urn:test:mainYangTestImporting)main-group-cont {
- *                 status CURRENT;
- *                 leaf imported-augmented-leaf-3 {
- *                     type string;
- *                 }
- *             }
- *             uses second-group;
- *         }
- *         uses main-group;
- *     }
- *
- *     augment \(urn:test:mainYangTest)main-cont {
- *         status CURRENT;
- *         leaf imported-augmented-leaf-1 {
- *             type string;
- *         }
- *     }
- *     augment \(urn:test:mainYangTest)main-cont {
- *         status CURRENT;
- *         leaf imported-augmented-leaf-2 {
- *             type string;
- *         }
- *     }
- *     augment \(urn:test:mainYangTestImporting)importing-container\(urn:test:mainYangTestImporting)main-group-cont {
- *         status CURRENT;
- *         leaf imported-augmented-leaf-3 {
- *             type string;
- *         }
- *     }
- * }
- * 
- * - */ -public interface MainYangTestImportingData - extends - TreeRoot -{ - - - - - ImportingContainer getImportingContainer(); - -} - diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/ImportingContainer.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/ImportingContainer.java deleted file mode 100644 index c43661fe34..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/ImportingContainer.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data; -import org.opendaylight.yangtools.yang.binding.ChildTreeNode; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.MainGroup; -import org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.MainYangTestImportingData; -import org.opendaylight.yangtools.yang.binding.Augmentable; - - -/** - *

This class represents the following YANG schema fragment defined in module mainYangTestImporting - *

- * container importing-container {
- *     container main-group-cont {
- *         leaf main-group-cont-leaf {
- *             type string;
- *         }
- *         list main-group-cont-list-ordered {
- *             key "name-1"
- *             leaf name-1 {
- *                 type string;
- *             }
- *             leaf type-1 {
- *                 type string;
- *             }
- *         }
- *         list main-group-cont-list-unordered {
- *             key "name-2"
- *             leaf name-2 {
- *                 type string;
- *             }
- *             leaf type-2 {
- *                 type string;
- *             }
- *         }
- *         choice main-group-cont-choice {
- *             case a {
- *                 leaf case-1 {
- *                     type string;
- *                 }
- *             }
- *             case b {
- *                 leaf case2-1 {
- *                     type string;
- *                 }
- *             }
- *         }
- *         leaf leaf-ref-test {
- *             type leafref;
- *         }
- *         container second-group-cont {
- *             leaf second-group-cont-leaf {
- *                 type string;
- *             }
- *         }
- *         leaf imported-augmented-leaf-3 {
- *             type string;
- *         }
- *         augment \(urn:test:mainYangTestImporting)importing-container\(urn:test:mainYangTestImporting)main-group-cont {
- *             status CURRENT;
- *             leaf imported-augmented-leaf-3 {
- *                 type string;
- *             }
- *         }
- *         uses second-group;
- *     }
- *     uses main-group;
- * }
- * 
- * The schema path to identify an instance is - * mainYangTestImporting/importing-container - * - *

To create instances of this class use {@link org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data.ImportingContainerBuilder}. - * @see org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data.ImportingContainerBuilder - * - */ -public interface ImportingContainer - extends - ChildTreeNode, - Augmentable, - MainGroup -{ - - - - public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.create("urn:test:mainYangTestImporting", - "2016-01-01", "importing-container").intern(); - - -} - diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/ImportingContainerBuilder.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/ImportingContainerBuilder.java deleted file mode 100644 index 94ddd49e1d..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/ImportingContainerBuilder.java +++ /dev/null @@ -1,231 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.binding.AugmentationHolder; -import org.opendaylight.yangtools.yang.binding.TreeNode; -import java.util.HashMap; -import org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.MainGroupCont; -import org.opendaylight.yangtools.concepts.Builder; -import java.util.Objects; -import java.util.Collections; -import java.util.Map; - - -/** - * Class that builds {@link org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data.ImportingContainer} instances. - * - * @see org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data.ImportingContainer - * - */ -public class ImportingContainerBuilder implements Builder { - - private MainGroupCont _mainGroupCont; - - Map>, Augmentation> augmentation = Collections.emptyMap(); - - public ImportingContainerBuilder() { - } - public ImportingContainerBuilder(org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.MainGroup arg) { - this._mainGroupCont = arg.getMainGroupCont(); - } - - public ImportingContainerBuilder(ImportingContainer base) { - this._mainGroupCont = base.getMainGroupCont(); - if (base instanceof ImportingContainerImpl) { - ImportingContainerImpl impl = (ImportingContainerImpl) base; - if (!impl.augmentation.isEmpty()) { - this.augmentation = new HashMap<>(impl.augmentation); - } - } else if (base instanceof AugmentationHolder) { - @SuppressWarnings("unchecked") - AugmentationHolder casted =(AugmentationHolder) base; - if (!casted.augmentations().isEmpty()) { - this.augmentation = new HashMap<>(casted.augmentations()); - } - } - } - - /** - *Set fields from given grouping argument. Valid argument is instance of one of following types: - *

    - *
  • org.opendaylight.yang.gen.v1.urn.test.mainyangtest.rev160101.MainGroup
  • - *
- * - * @param arg grouping object - * @throws IllegalArgumentException if given argument is none of valid types - */ - public void fieldsFrom(TreeNode arg) { - boolean isValidArg = false; - if (arg instanceof org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.MainGroup) { - this._mainGroupCont = ((org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.MainGroup)arg).getMainGroupCont(); - isValidArg = true; - } - if (!isValidArg) { - throw new IllegalArgumentException( - "expected one of: [org.opendaylight.yang.gen.v1.urn.test.mainyangtest.rev160101.MainGroup] \n" + - "but was: " + arg - ); - } - } - - public MainGroupCont getMainGroupCont() { - return _mainGroupCont; - } - - @SuppressWarnings("unchecked") - public > E getAugmentation(java.lang.Class augmentationType) { - if (augmentationType == null) { - throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); - } - return (E) augmentation.get(augmentationType); - } - - - public ImportingContainerBuilder setMainGroupCont(final MainGroupCont value) { - this._mainGroupCont = value; - return this; - } - - public ImportingContainerBuilder addAugmentation(java.lang.Class> augmentationType, Augmentation augmentation) { - if (augmentation == null) { - return removeAugmentation(augmentationType); - } - - if (!(this.augmentation instanceof HashMap)) { - this.augmentation = new HashMap<>(); - } - - this.augmentation.put(augmentationType, augmentation); - return this; - } - - public ImportingContainerBuilder removeAugmentation(java.lang.Class> augmentationType) { - if (this.augmentation instanceof HashMap) { - this.augmentation.remove(augmentationType); - } - return this; - } - - public ImportingContainer build() { - return new ImportingContainerImpl(this); - } - - private static final class ImportingContainerImpl implements ImportingContainer { - - public java.lang.Class implementedInterface() { - return org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data.ImportingContainer.class; - } - - private final MainGroupCont _mainGroupCont; - - private Map>, Augmentation> augmentation = Collections.emptyMap(); - - private ImportingContainerImpl(ImportingContainerBuilder base) { - this._mainGroupCont = base.getMainGroupCont(); - switch (base.augmentation.size()) { - case 0: - this.augmentation = Collections.emptyMap(); - break; - case 1: - final Map.Entry>, Augmentation> e = base.augmentation.entrySet().iterator().next(); - this.augmentation = Collections.>, Augmentation>singletonMap(e.getKey(), e.getValue()); - break; - default : - this.augmentation = new HashMap<>(base.augmentation); - } - } - - @Override - public MainGroupCont getMainGroupCont() { - return _mainGroupCont; - } - - @SuppressWarnings("unchecked") - @Override - public > E getAugmentation(java.lang.Class augmentationType) { - if (augmentationType == null) { - throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); - } - return (E) augmentation.get(augmentationType); - } - - private int hash = 0; - private volatile boolean hashValid = false; - - @Override - public int hashCode() { - if (hashValid) { - return hash; - } - - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(_mainGroupCont); - result = prime * result + Objects.hashCode(augmentation); - - hash = result; - hashValid = true; - return result; - } - - @Override - public boolean equals(java.lang.Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof TreeNode)) { - return false; - } - if (!org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data.ImportingContainer.class.equals(((TreeNode)obj).implementedInterface())) { - return false; - } - org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data.ImportingContainer other = (org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data.ImportingContainer)obj; - if (!Objects.equals(_mainGroupCont, other.getMainGroupCont())) { - return false; - } - if (getClass() == obj.getClass()) { - // Simple case: we are comparing against self - ImportingContainerImpl otherImpl = (ImportingContainerImpl) obj; - if (!Objects.equals(augmentation, otherImpl.augmentation)) { - return false; - } - } else { - // Hard case: compare our augments with presence there... - for (Map.Entry>, Augmentation> e : augmentation.entrySet()) { - if (!e.getValue().equals(other.getAugmentation(e.getKey()))) { - return false; - } - } - // .. and give the other one the chance to do the same - if (!obj.equals(this)) { - return false; - } - } - return true; - } - - @Override - public java.lang.String toString() { - java.lang.StringBuilder builder = new java.lang.StringBuilder ("ImportingContainer ["); - boolean first = true; - - if (_mainGroupCont != null) { - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("_mainGroupCont="); - builder.append(_mainGroupCont); - } - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("augmentation="); - builder.append(augmentation.values()); - return builder.append(']').toString(); - } - } - -} diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/MainCont1.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/MainCont1.java deleted file mode 100644 index 4d101e3567..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/MainCont1.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data; -import org.opendaylight.yang.gen.v1.urn.test.mainyangtest.data.MainCont; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.binding.TreeNode; - - -public interface MainCont1 - extends - TreeNode, - Augmentation -{ - - - - - java.lang.String getImportedAugmentedLeaf1(); - -} - diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/MainCont1Builder.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/MainCont1Builder.java deleted file mode 100644 index 9399ac7a56..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/MainCont1Builder.java +++ /dev/null @@ -1,112 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data; -import org.opendaylight.yangtools.yang.binding.TreeNode; -import org.opendaylight.yangtools.concepts.Builder; -import java.util.Objects; - - -/** - * Class that builds {@link org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data.MainCont1} instances. - * - * @see org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data.MainCont1 - * - */ -public class MainCont1Builder implements Builder { - - private java.lang.String _importedAugmentedLeaf1; - - - public MainCont1Builder() { - } - - public MainCont1Builder(MainCont1 base) { - this._importedAugmentedLeaf1 = base.getImportedAugmentedLeaf1(); - } - - - public java.lang.String getImportedAugmentedLeaf1() { - return _importedAugmentedLeaf1; - } - - - public MainCont1Builder setImportedAugmentedLeaf1(final java.lang.String value) { - this._importedAugmentedLeaf1 = value; - return this; - } - - public MainCont1 build() { - return new MainCont1Impl(this); - } - - private static final class MainCont1Impl implements MainCont1 { - - public java.lang.Class implementedInterface() { - return org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data.MainCont1.class; - } - - private final java.lang.String _importedAugmentedLeaf1; - - - private MainCont1Impl(MainCont1Builder base) { - this._importedAugmentedLeaf1 = base.getImportedAugmentedLeaf1(); - } - - @Override - public java.lang.String getImportedAugmentedLeaf1() { - return _importedAugmentedLeaf1; - } - - private int hash = 0; - private volatile boolean hashValid = false; - - @Override - public int hashCode() { - if (hashValid) { - return hash; - } - - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(_importedAugmentedLeaf1); - - hash = result; - hashValid = true; - return result; - } - - @Override - public boolean equals(java.lang.Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof TreeNode)) { - return false; - } - if (!org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data.MainCont1.class.equals(((TreeNode)obj).implementedInterface())) { - return false; - } - org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data.MainCont1 other = (org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data.MainCont1)obj; - if (!Objects.equals(_importedAugmentedLeaf1, other.getImportedAugmentedLeaf1())) { - return false; - } - return true; - } - - @Override - public java.lang.String toString() { - java.lang.StringBuilder builder = new java.lang.StringBuilder ("MainCont1 ["); - boolean first = true; - - if (_importedAugmentedLeaf1 != null) { - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("_importedAugmentedLeaf1="); - builder.append(_importedAugmentedLeaf1); - } - return builder.append(']').toString(); - } - } - -} diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/MainCont2.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/MainCont2.java deleted file mode 100644 index c0f5b81cd3..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/MainCont2.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data; -import org.opendaylight.yang.gen.v1.urn.test.mainyangtest.data.MainCont; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.binding.TreeNode; - - -public interface MainCont2 - extends - TreeNode, - Augmentation -{ - - - - - java.lang.String getImportedAugmentedLeaf2(); - -} - diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/MainCont2Builder.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/MainCont2Builder.java deleted file mode 100644 index e41c7b950b..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/MainCont2Builder.java +++ /dev/null @@ -1,112 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data; -import org.opendaylight.yangtools.yang.binding.TreeNode; -import org.opendaylight.yangtools.concepts.Builder; -import java.util.Objects; - - -/** - * Class that builds {@link org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data.MainCont2} instances. - * - * @see org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data.MainCont2 - * - */ -public class MainCont2Builder implements Builder { - - private java.lang.String _importedAugmentedLeaf2; - - - public MainCont2Builder() { - } - - public MainCont2Builder(MainCont2 base) { - this._importedAugmentedLeaf2 = base.getImportedAugmentedLeaf2(); - } - - - public java.lang.String getImportedAugmentedLeaf2() { - return _importedAugmentedLeaf2; - } - - - public MainCont2Builder setImportedAugmentedLeaf2(final java.lang.String value) { - this._importedAugmentedLeaf2 = value; - return this; - } - - public MainCont2 build() { - return new MainCont2Impl(this); - } - - private static final class MainCont2Impl implements MainCont2 { - - public java.lang.Class implementedInterface() { - return org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data.MainCont2.class; - } - - private final java.lang.String _importedAugmentedLeaf2; - - - private MainCont2Impl(MainCont2Builder base) { - this._importedAugmentedLeaf2 = base.getImportedAugmentedLeaf2(); - } - - @Override - public java.lang.String getImportedAugmentedLeaf2() { - return _importedAugmentedLeaf2; - } - - private int hash = 0; - private volatile boolean hashValid = false; - - @Override - public int hashCode() { - if (hashValid) { - return hash; - } - - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(_importedAugmentedLeaf2); - - hash = result; - hashValid = true; - return result; - } - - @Override - public boolean equals(java.lang.Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof TreeNode)) { - return false; - } - if (!org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data.MainCont2.class.equals(((TreeNode)obj).implementedInterface())) { - return false; - } - org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data.MainCont2 other = (org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data.MainCont2)obj; - if (!Objects.equals(_importedAugmentedLeaf2, other.getImportedAugmentedLeaf2())) { - return false; - } - return true; - } - - @Override - public java.lang.String toString() { - java.lang.StringBuilder builder = new java.lang.StringBuilder ("MainCont2 ["); - boolean first = true; - - if (_importedAugmentedLeaf2 != null) { - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("_importedAugmentedLeaf2="); - builder.append(_importedAugmentedLeaf2); - } - return builder.append(']').toString(); - } - } - -} diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/MainGroupCont1.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/MainGroupCont1.java deleted file mode 100644 index d71ccaac7d..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/MainGroupCont1.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data; -import org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.MainGroupCont; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.binding.TreeNode; - - -public interface MainGroupCont1 - extends - TreeNode, - Augmentation -{ - - - - - java.lang.String getImportedAugmentedLeaf3(); - -} - diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/MainGroupCont1Builder.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/MainGroupCont1Builder.java deleted file mode 100644 index 842a30990c..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/data/MainGroupCont1Builder.java +++ /dev/null @@ -1,112 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data; -import org.opendaylight.yangtools.yang.binding.TreeNode; -import org.opendaylight.yangtools.concepts.Builder; -import java.util.Objects; - - -/** - * Class that builds {@link org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data.MainGroupCont1} instances. - * - * @see org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data.MainGroupCont1 - * - */ -public class MainGroupCont1Builder implements Builder { - - private java.lang.String _importedAugmentedLeaf3; - - - public MainGroupCont1Builder() { - } - - public MainGroupCont1Builder(MainGroupCont1 base) { - this._importedAugmentedLeaf3 = base.getImportedAugmentedLeaf3(); - } - - - public java.lang.String getImportedAugmentedLeaf3() { - return _importedAugmentedLeaf3; - } - - - public MainGroupCont1Builder setImportedAugmentedLeaf3(final java.lang.String value) { - this._importedAugmentedLeaf3 = value; - return this; - } - - public MainGroupCont1 build() { - return new MainGroupCont1Impl(this); - } - - private static final class MainGroupCont1Impl implements MainGroupCont1 { - - public java.lang.Class implementedInterface() { - return org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data.MainGroupCont1.class; - } - - private final java.lang.String _importedAugmentedLeaf3; - - - private MainGroupCont1Impl(MainGroupCont1Builder base) { - this._importedAugmentedLeaf3 = base.getImportedAugmentedLeaf3(); - } - - @Override - public java.lang.String getImportedAugmentedLeaf3() { - return _importedAugmentedLeaf3; - } - - private int hash = 0; - private volatile boolean hashValid = false; - - @Override - public int hashCode() { - if (hashValid) { - return hash; - } - - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(_importedAugmentedLeaf3); - - hash = result; - hashValid = true; - return result; - } - - @Override - public boolean equals(java.lang.Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof TreeNode)) { - return false; - } - if (!org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data.MainGroupCont1.class.equals(((TreeNode)obj).implementedInterface())) { - return false; - } - org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data.MainGroupCont1 other = (org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting.data.MainGroupCont1)obj; - if (!Objects.equals(_importedAugmentedLeaf3, other.getImportedAugmentedLeaf3())) { - return false; - } - return true; - } - - @Override - public java.lang.String toString() { - java.lang.StringBuilder builder = new java.lang.StringBuilder ("MainGroupCont1 ["); - boolean first = true; - - if (_importedAugmentedLeaf3 != null) { - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("_importedAugmentedLeaf3="); - builder.append(_importedAugmentedLeaf3); - } - return builder.append(']').toString(); - } - } - -} diff --git a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/package-info.java b/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/package-info.java deleted file mode 100644 index edb83a9688..0000000000 --- a/binding2/prototype/src/test/java/org/opendaylight/yang/gen/v1/urn/test/mainyangtestimporting/package-info.java +++ /dev/null @@ -1,9 +0,0 @@ -/** - * - */ - -/** - * @author tony - * - */ -package org.opendaylight.yang.gen.v1.urn.test.mainyangtestimporting; diff --git a/binding2/prototype/yang-binding2/pom.xml b/binding2/prototype/yang-binding2/pom.xml deleted file mode 100644 index a6e2400ca0..0000000000 --- a/binding2/prototype/yang-binding2/pom.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - org.opendaylight.mdsal - mdsal-binding - 0.15.0-SNAPSHOT - - - 4.0.0 - yang-binding2 - ${project.artifactId} - Java binding for YANG - bundle - - - - org.opendaylight.yangtools - concepts - - - org.opendaylight.yangtools - util - - - org.opendaylight.yangtools - yang-common - - - com.google.guava - guava - - - junit - junit - test - - - org.mockito - mockito-core - test - - - - diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/Augmentable.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/Augmentable.java deleted file mode 100644 index 8a6d6487a7..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/Augmentable.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding; - -/** - * Augmentable (extensible) object which could carry additional data defined by - * third-party extension, without introducing conflict between various - * extension. - * - * This interface uses extended version of ExtensibleInterface pattern which - * also adds marker interface for augmentations (extensions) - - * {@link Augmentable} - * - * @author Tony Tkacik - * @param - * Base class which should implements this interface and is target - * for augmentation. - */ -public interface Augmentable { - - /** - * Returns instance of augmentation. - * - * @param augmentationType - * Type of augmentation to be returned. - * @return instance of augmentation. - */ - > E getAugmentation(Class augmentationType); -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/Augmentation.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/Augmentation.java deleted file mode 100644 index cf109124d3..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/Augmentation.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding; - -/** - * Augmentation (extension) of other interface. - * - * This interface uniquely bounds Augmentation to generated - * interface. - * - * All interfaces generated from YANG Augmentation statement - * must implement this interface with parameter P - * which uniquely points to it's target class. - * - * - * - * @param Class to which this implementation is extension. - */ -public interface Augmentation { - -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/AugmentationHolder.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/AugmentationHolder.java deleted file mode 100644 index 9dc76eb845..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/AugmentationHolder.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding; - -import java.util.Map; - -/** - * - * Augmentable (extensible) object which could carry additional data defined by - * third-party extension, without introducing conflict between various - * extension. - * - * - * @author Tony Tkacik - * @param - * Base class which should is target - * for augmentations. - */ -public interface AugmentationHolder { - - /** - * Returns map of all augmentations. - * - * @return map of all augmentations. - */ - Map>,Augmentation> augmentations(); -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/BaseIdentity.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/BaseIdentity.java deleted file mode 100644 index 9ae1f22296..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/BaseIdentity.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding; - -/** - * Base Identity - * - */ -public abstract class BaseIdentity { - - public final static BaseIdentity INSTANCE = new BaseIdentity() { - }; - - protected BaseIdentity() { - - } - -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/BindingCodec.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/BindingCodec.java deleted file mode 100644 index 48e65e10ac..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/BindingCodec.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding; - -import org.opendaylight.yangtools.concepts.Codec; - -public interface BindingCodec extends BindingSerializer, BindingDeserializer, Codec { - - @Override - P serialize(I input); - - @Override - I deserialize(P input); - - I deserialize(P input, InstanceIdentifier bindingIdentifier); - -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/BindingDeserializer.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/BindingDeserializer.java deleted file mode 100644 index 7165291e56..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/BindingDeserializer.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding; - -public interface BindingDeserializer { - - P deserialize(I input); -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/BindingMapping.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/BindingMapping.java deleted file mode 100644 index 39cf3754c6..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/BindingMapping.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding; - -import static com.google.common.base.Preconditions.checkArgument; - -import com.google.common.base.CharMatcher; -import com.google.common.base.Splitter; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Interner; -import com.google.common.collect.Interners; -import java.text.SimpleDateFormat; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.QNameModule; - -public final class BindingMapping { - - public static final String VERSION = "0.6"; - - public static final Set JAVA_RESERVED_WORDS = ImmutableSet.of("abstract", "assert", "boolean", "break", - "byte", "case", "catch", "char", "class", "const", "continue", "default", "double", "do", "else", "enum", - "extends", "false", "final", "finally", "float", "for", "goto", "if", "implements", "import", "instanceof", - "int", "interface", "long", "native", "new", "null", "package", "private", "protected", "public", "return", - "short", "static", "strictfp", "super", "switch", "synchronized", "this", "throw", "throws", "transient", - "true", "try", "void", "volatile", "while"); - - public static final String DATA_ROOT_SUFFIX = "Data"; - public static final String RPC_SERVICE_SUFFIX = "Service"; - public static final String NOTIFICATION_LISTENER_SUFFIX = "Listener"; - public static final String QNAME_STATIC_FIELD_NAME = "QNAME"; - public static final String PACKAGE_PREFIX = "org.opendaylight.yang.gen.v1"; - public static final String AUGMENTATION_FIELD = "augmentation"; - - private static final Splitter CAMEL_SPLITTER = Splitter.on(CharMatcher.anyOf(" _.-").precomputed()) - .omitEmptyStrings().trimResults(); - private static final Pattern COLON_SLASH_SLASH = Pattern.compile("://", Pattern.LITERAL); - private static final String QUOTED_DOT = Matcher.quoteReplacement("."); - private static final Splitter DOT_SPLITTER = Splitter.on('.'); - - public static final String MODULE_INFO_CLASS_NAME = "$YangModuleInfoImpl"; - public static final String MODEL_BINDING_PROVIDER_CLASS_NAME = "$YangModelBindingProvider"; - - public static final String RPC_INPUT_SUFFIX = "Input"; - public static final String RPC_OUTPUT_SUFFIX = "Output"; - - private static final ThreadLocal PACKAGE_DATE_FORMAT = new ThreadLocal() { - - @Override - protected SimpleDateFormat initialValue() { - return new SimpleDateFormat("yyMMdd"); - } - - @Override - public void set(final SimpleDateFormat value) { - throw new UnsupportedOperationException(); - } - }; - - private static final Interner PACKAGE_INTERNER = Interners.newWeakInterner(); - - private BindingMapping() { - throw new UnsupportedOperationException("Utility class should not be instantiated"); - } - - public static String getRootPackageName(final QName module) { - return getRootPackageName(module.getModule()); - } - - public static String getRootPackageName(final QNameModule module) { - checkArgument(module != null, "Module must not be null"); - checkArgument(module.getRevision() != null, "Revision must not be null"); - checkArgument(module.getNamespace() != null, "Namespace must not be null"); - final StringBuilder packageNameBuilder = new StringBuilder(); - - packageNameBuilder.append(BindingMapping.PACKAGE_PREFIX); - packageNameBuilder.append('.'); - - String namespace = module.getNamespace().toString(); - namespace = COLON_SLASH_SLASH.matcher(namespace).replaceAll(QUOTED_DOT); - - final char[] chars = namespace.toCharArray(); - for (int i = 0; i < chars.length; ++i) { - switch (chars[i]) { - case '/': - case ':': - case '-': - case '@': - case '$': - case '#': - case '\'': - case '*': - case '+': - case ',': - case ';': - case '=': - chars[i] = '.'; - } - } - - packageNameBuilder.append(chars); - packageNameBuilder.append(".rev"); - packageNameBuilder.append(PACKAGE_DATE_FORMAT.get().format(module.getRevision())); - return normalizePackageName(packageNameBuilder.toString()); - } - - public static String normalizePackageName(final String packageName) { - if (packageName == null) { - return null; - } - - final StringBuilder builder = new StringBuilder(); - boolean first = true; - - for (String p : DOT_SPLITTER.split(packageName.toLowerCase())) { - if (first) { - first = false; - } else { - builder.append('.'); - } - - if (Character.isDigit(p.charAt(0)) || BindingMapping.JAVA_RESERVED_WORDS.contains(p)) { - builder.append('_'); - } - builder.append(p); - } - - // Prevent duplication of input string - return PACKAGE_INTERNER.intern(builder.toString()); - } - - public static String getMethodName(final QName name) { - checkArgument(name != null, "Name should not be null."); - return getMethodName(name.getLocalName()); - } - - public static String getClassName(final String localName) { - checkArgument(localName != null, "Name should not be null."); - return toFirstUpper(toCamelCase(localName)); - } - - public static String getMethodName(final String yangIdentifier) { - checkArgument(yangIdentifier != null,"Identifier should not be null"); - return toFirstLower(toCamelCase(yangIdentifier)); - } - - public static String getClassName(final QName name) { - checkArgument(name != null, "Name should not be null."); - return toFirstUpper(toCamelCase(name.getLocalName())); - } - - public static String getGetterSuffix(final QName name) { - checkArgument(name != null, "Name should not be null."); - final String candidate = toFirstUpper(toCamelCase(name.getLocalName())); - return ("Class".equals(candidate) ? "XmlClass" : candidate); - } - - public static String getPropertyName(final String yangIdentifier) { - final String potential = toFirstLower(toCamelCase(yangIdentifier)); - if ("class".equals(potential)) { - return "xmlClass"; - } - return potential; - } - - private static String toCamelCase(final String rawString) { - checkArgument(rawString != null, "String should not be null"); - Iterable components = CAMEL_SPLITTER.split(rawString); - StringBuilder builder = new StringBuilder(); - for (String comp : components) { - builder.append(toFirstUpper(comp)); - } - return checkNumericPrefix(builder.toString()); - } - - private static String checkNumericPrefix(final String rawString) { - if (rawString == null || rawString.isEmpty()) { - return rawString; - } - char firstChar = rawString.charAt(0); - if (firstChar >= '0' && firstChar <= '9') { - return "_" + rawString; - } else { - return rawString; - } - } - - /** - * Returns the {@link String} {@code s} with an - * {@link Character#isUpperCase(char) upper case} first character. This - * function is null-safe. - * - * @param s - * the string that should get an upper case first character. May - * be null. - * @return the {@link String} {@code s} with an upper case first character - * or null if the input {@link String} {@code s} was - * null. - */ - public static String toFirstUpper(final String s) { - if (s == null || s.length() == 0) { - return s; - } - if (Character.isUpperCase(s.charAt(0))) { - return s; - } - if (s.length() == 1) { - return s.toUpperCase(); - } - return s.substring(0, 1).toUpperCase() + s.substring(1); - } - - /** - * Returns the {@link String} {@code s} with an - * {@link Character#isLowerCase(char) lower case} first character. This - * function is null-safe. - * - * @param s - * the string that should get an lower case first character. May - * be null. - * @return the {@link String} {@code s} with an lower case first character - * or null if the input {@link String} {@code s} was - * null. - */ - private static String toFirstLower(final String s) { - if (s == null || s.length() == 0) { - return s; - } - if (Character.isLowerCase(s.charAt(0))) { - return s; - } - if (s.length() == 1) { - return s.toLowerCase(); - } - return s.substring(0, 1).toLowerCase() + s.substring(1); - } -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/BindingSerializer.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/BindingSerializer.java deleted file mode 100644 index a8a66b77a8..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/BindingSerializer.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding; - -public interface BindingSerializer { - P serialize(I input); -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/BindingStreamEventWriter.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/BindingStreamEventWriter.java deleted file mode 100644 index 811dc71f54..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/BindingStreamEventWriter.java +++ /dev/null @@ -1,471 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding; - -import java.io.Closeable; -import java.io.Flushable; -import java.io.IOException; - - -/** - * Event Stream Writer for Binding Representation - * - * - *

Emmiting Event Stream

- * - *
    - *
  • container - Container node representation, start event is - * emitted using {@link #startContainerNode(Class, int)} and node end event is - * emitted using {@link #endNode()}. Container node is implementing - * {@link TreeNode} interface. - * - *
  • list - YANG list statement has two representation in event - * stream - unkeyed list and map. Unkeyed list is YANG list which did not - * specify key. - * - *
      - *
    • Map - Map start event is emitted using - * {@link #startMapNode(Class, int)} and is ended using {@link #endNode()}. Each map - * entry start is emitted using {@link #startMapEntryNode(Identifier, int)} with Map of keys - * and finished using {@link #endNode()}.
    • - * - *
    • UnkeyedList - Unkeyed list represent list without keys, - * unkeyed list start is emitted using {@link #startUnkeyedList(Class, int)} list - * end is emitted using {@link #endNode()}. Each list item is emitted using - * {@link #startUnkeyedListItem(int)} and ended using {@link #endNode()}.
    • - *
  • - * - *
  • leaf - Leaf node event is emitted using - * {@link #leafNode(String, Object)}. {@link #endNode()} MUST be not emitted for - * leaf node.
  • - * - *
  • leaf-list - Leaf list start is emitted using - * {@link #startLeafSet(String, int)}. Leaf list end is emitted using - * {@link #endNode()}. Leaf list entries are emitted using - * {@link #leafSetEntryNode(Object)}. - * - *
  • anyxml - Anyxml node event is emitted using - * {@link #leafNode(String, Object)}. {@link #endNode()} MUST be not emitted - * for anyxml node.
  • - * - * - *
  • choice Choice node event is emitted by - * {@link #startChoiceNode(Class, int)} event and must be immediately followed by - * {@link #startCase(Class, int)} event. Choice node is finished by emitting an - * {@link #endNode()} event.
  • - * - *
  • - * case - Case node may be emitted only inside choice node by - * invoking {@link #startCase(Class, int)}. Case node is finished be emitting an - * {@link #endNode()} event.
  • - * - *
  • - * augment - Represents augmentation, augmentation node is started - * by invoking {@link #startAugmentationNode(Class)} and - * finished by invoking {@link #endNode()}.
  • - * - *
- * - *

Implementation notes

This interface is not intended to be - * implemented by users of generated Binding DTOs but to be used by utilities, - * which needs to emit NormalizedNode model from Binding DTOs. - *

- * This interface is intended as API definition of facade for real Event / - * Stream Writer, without explicitly requiring stream writer and related - * interfaces to be imported by all generated Binding DTOs. - *

- * Existence of this interface in base Java Binding package is required to - * support runtime generation of users of this interface in OSGI and OSGI-like - * environment, since this package is only package which is imported by all - * generated Binding DTOs and wired in OSGI. - * - * - */ -public interface BindingStreamEventWriter extends Closeable, Flushable { - - /** - * Methods in this interface allow users to hint the underlying - * implementation about the sizing of container-like constructors - * (leafLists, containers, etc.). These hints may be taken into account by a - * particular implementation to improve performance, but clients are not - * required to provide hints. This constant should be used by clients who - * either do not have the sizing information, or do not wish to divulge it - * (for whatever reasons). Implementations are free to ignore these hints - * completely, but if they do use them, they are expected to be resilient in - * face of missing and mismatched hints, which is to say the user can - * specify startLeafSet(..., 1) and then call leafNode() 15 times. - *

- * The acceptable hint values are non-negative integers and this constant, - * all other values will result, based on implementation preference, in the - * hint being completely ignored or IllegalArgumentException being thrown. - */ - int UNKNOWN_SIZE = -1; - - /** - * - * Emits a leaf node event with supplied value. - * - * @param localName - * name of node as defined in schema, namespace and revision are - * derived from parent node. - * @param value - * Value of leaf node. - * @throws IllegalArgumentException - * If emitted leaf node has invalid value in current context or - * was emitted multiple times. - * @throws IllegalStateException - * If node was emitted inside map, - * choice unkeyed list node. - * @throws IOException if an underlying IO error occurs - */ - void leafNode(String localName, Object value) throws IOException, IllegalArgumentException; - - /** - * - * Emits a start of leaf set (leaf-list). - *

- * Emits start of leaf set, during writing leaf set event, only - * {@link #leafSetEntryNode(Object)} calls are valid. Leaf set event is - * finished by calling {@link #endNode()}. - * - * @param localName - * name of node as defined in schema, namespace and revision are - * derived from parent node. - * @param childSizeHint - * Non-negative count of expected direct child nodes or - * {@link #UNKNOWN_SIZE} if count is unknown. This is only hint - * and should not fail writing of child events, if there are more - * events than count. - * @throws IllegalArgumentException - * If emitted leaf node is invalid in current context or was - * emitted multiple times. - * @throws IllegalStateException - * If node was emitted inside map, - * choice unkeyed list node. - * @throws IOException if an underlying IO error occurs - */ - void startLeafSet(String localName, int childSizeHint) throws IOException, IllegalArgumentException; - - /** - * - * Emits a start of leaf set (leaf-list). - *

- * Emits start of leaf set, during writing leaf set event, only - * {@link #leafSetEntryNode(Object)} calls are valid. Leaf set event is - * finished by calling {@link #endNode()}. - * - * @param localName - * name of node as defined in schema, namespace and revision are - * derived from parent node. - * @param childSizeHint - * Non-negative count of expected direct child nodes or - * {@link #UNKNOWN_SIZE} if count is unknown. This is only hint - * and should not fail writing of child events, if there are more - * events than count. - * @throws IllegalArgumentException - * If emitted leaf node is invalid in current context or was - * emitted multiple times. - * @throws IllegalStateException - * If node was emitted inside map, - * choice unkeyed list node. - * @throws IOException if an underlying IO error occurs - */ - void startOrderedLeafSet(String localName, int childSizeHint) throws IOException, IllegalArgumentException; - - /** - * Emits a leaf set entry node - * - * @param value - * Value of leaf set entry node. - * @throws IllegalArgumentException - * If emitted leaf node has invalid value. - * @throws IllegalStateException - * If node was emitted outside leaf set node. - * @throws IOException if an underlying IO error occurs - */ - void leafSetEntryNode(Object value) throws IOException, IllegalArgumentException; - - /** - * - * Emits start of new container. - * - *

- * End of container event is emitted by invoking {@link #endNode()}. - * - *

- * Valid sub-events are: - *

    - *
  • {@link #leafNode(String, Object)}
  • - *
  • {@link #startContainerNode(Class, int)}
  • - *
  • {@link #startChoiceNode(Class, int)}
  • - *
  • {@link #startLeafSet(String, int)}
  • - *
  • {@link #startMapNode(Class, int)}
  • - *
  • {@link #startUnkeyedList(Class, int)}
  • - *
  • {@link #startAugmentationNode(Class)}
  • - *
- * - * @param container - * name of node as defined in schema, namespace and revision are - * derived from parent node. - * @param childSizeHint - * Non-negative count of expected direct child nodes or - * {@link #UNKNOWN_SIZE} if count is unknown. This is only hint - * and should not fail writing of child events, if there are more - * events than count. - * @throws IllegalArgumentException - * If emitted node is invalid in current context or was emitted - * multiple times. - * @throws IllegalStateException - * If node was emitted inside map, - * choice unkeyed list node. - * @throws IOException if an underlying IO error occurs - */ - void startContainerNode(Class container, int childSizeHint) throws IOException, IllegalArgumentException; - - /** - * - * Emits start of unkeyed list node event. - * - *

- * End of unkeyed list event is emitted by invoking {@link #endNode()}. - * Valid subevents is only {@link #startUnkeyedListItem(int)}. All other - * methods will throw {@link IllegalArgumentException}. - * - * @param localName - * name of node as defined in schema, namespace and revision are - * derived from parent node. - * @param childSizeHint - * Non-negative count of expected direct child nodes or - * {@link #UNKNOWN_SIZE} if count is unknown. This is only hint - * and should not fail writing of child events, if there are more - * events than count. - * @throws IllegalArgumentException - * If emitted node is invalid in current context or was emitted - * multiple times. - * @throws IllegalStateException - * If node was emitted inside map, - * choice unkeyed list node. - * @throws IOException if an underlying IO error occurs - */ - void startUnkeyedList(Class localName, int childSizeHint) throws IOException, IllegalArgumentException; - - /** - * Emits start of new unkeyed list item. - * - *

- * Unkeyed list item event is finished by invoking {@link #endNode()}. Valid - * sub-events are: - *

- * Valid sub-events are: - * - *

    - *
  • {@link #leafNode(String, Object)}
  • - *
  • {@link #startContainerNode(Class, int)}
  • - *
  • {@link #startChoiceNode(Class, int)}
  • - *
  • {@link #startLeafSet(String, int)}
  • - *
  • {@link #startMapNode(Class, int)}
  • - *
  • {@link #startUnkeyedList(Class, int)}
  • - *
  • {@link #startAugmentationNode(Class)}
  • - *
- * - * - * @param childSizeHint - * Non-negative count of expected direct child nodes or - * {@link #UNKNOWN_SIZE} if count is unknown. This is only hint - * and should not fail writing of child events, if there are more - * events than count. - * @throws IllegalStateException - * If node was emitted outside unkeyed list node. - * @throws IOException if an underlying IO error occurs - */ - void startUnkeyedListItem(int childSizeHint) throws IOException, IllegalStateException; - - /** - * - * Emits start of unordered map node event. - * - *

- * End of map node event is emitted by invoking {@link #endNode()}. Valid - * subevents is only {@link #startMapEntryNode(Identifier, int)}. All other methods will - * throw {@link IllegalArgumentException}. - * - * @param mapEntryType - * Class of list item, which has defined key. - * @param childSizeHint - * Non-negative count of expected direct child nodes or - * {@link #UNKNOWN_SIZE} if count is unknown. This is only hint - * and should not fail writing of child events, if there are more - * events than count. - * @throws IllegalArgumentException - * @throws IllegalStateException - * If node was emitted inside map, - * choice unkeyed list node. - * @throws IOException if an underlying IO error occurs - */ - > void startMapNode(Class mapEntryType, int childSizeHint) - throws IOException, IllegalArgumentException; - - /** - * - * Emits start of ordered map node event. - * - *

- * End of map node event is emitted by invoking {@link #endNode()}. Valid - * subevents is only {@link #startMapEntryNode(Identifier, int)}. All other methods will - * throw {@link IllegalArgumentException}. - * - * @param mapEntryType - * Class of list item, which has defined key. - * @param childSizeHint - * Non-negative count of expected direct child nodes or - * {@link #UNKNOWN_SIZE} if count is unknown. This is only hint - * and should not fail writing of child events, if there are more - * events than count. - * @throws IllegalArgumentException - * @throws IllegalStateException - * If node was emitted inside map, - * choice unkeyed list node. - * @throws IOException if an underlying IO error occurs - */ - > void startOrderedMapNode(Class mapEntryType, int childSizeHint) - throws IOException, IllegalArgumentException; - - /** - * - * Emits start of map entry. - * - *

- * End of map entry event is emitted by invoking {@link #endNode()}. - * - *

- * Valid sub-events are: - *

    - *
  • {@link #leafNode(String, Object)}
  • - *
  • {@link #startContainerNode(Class, int)}
  • - *
  • {@link #startChoiceNode(Class, int)}
  • - *
  • {@link #startLeafSet(String, int)}
  • - *
  • {@link #startMapNode(Class, int)}
  • - *
  • {@link #startUnkeyedList(Class, int)}
  • - *
  • {@link #startAugmentationNode(Class)}
  • - *
- * - * @param keyValues - * Key of map entry node - * @param childSizeHint - * Non-negative count of expected direct child nodes or - * {@link #UNKNOWN_SIZE} if count is unknown. This is only hint - * and should not fail writing of child events, if there are more - * events than count. - * @throws IllegalArgumentException - * If key contains incorrect value. - * @throws IllegalStateException - * If node was emitted outside map entry node. - * @throws IOException if an underlying IO error occurs - */ - void startMapEntryNode(Identifier keyValues, int childSizeHint) throws IOException, IllegalArgumentException; - - /** - * Emits start of choice node. - * - *

- * Valid sub-event in {@link #startCase(Class, int)}, which selects case - * which should be written. - * - * @param choice - * Choice class. - * @param childSizeHint - * Non-negative count of expected direct child nodes or - * {@link #UNKNOWN_SIZE} if count is unknown. This is only hint - * and should not fail writing of child events, if there are more - * events than count. - * @throws IllegalArgumentException - * @throws IllegalStateException - * If node was emitted inside map, choice, - * unkeyed list node. - * @throws IOException if an underlying IO error occurs - */ - void startChoiceNode(Class choice, int childSizeHint) throws IOException, IllegalArgumentException; - - /** - * - * Starts a case node. - * - *

- * Valid sub-events are: - *

    - *
  • {@link #leafNode(String, Object)}
  • - *
  • {@link #startContainerNode(Class, int)}
  • - *
  • {@link #startChoiceNode(Class, int)}
  • - *
  • {@link #startLeafSet(String, int)}
  • - *
  • {@link #startMapNode(Class, int)}
  • - *
  • {@link #startUnkeyedList(Class, int)}
  • - *
  • {@link #startAugmentationNode(Class)}
  • - *
- * - * @param caze Case class - * @throws IllegalArgumentException - * @throws IOException if an underlying IO error occurs - */ - void startCase(Class caze, int childSizeHint) throws IOException, IllegalArgumentException; - - /** - * Emits start of augmentation node. - * - *

- * End of augmentation event is emitted by invoking {@link #endNode()}. - * - *

- * Valid sub-events are: - * - *

    - *
  • {@link #leafNode(String, Object)}
  • - *
  • {@link #startContainerNode(Class, int)}
  • - *
  • {@link #startChoiceNode(Class, int)}
  • - *
  • {@link #startLeafSet(String, int)}
  • - *
  • {@link #startMapNode(Class, int)}
  • - *
  • {@link #startUnkeyedList(Class, int)}
  • - *
- * - *

- * Note this is only method, which does not require childSizeHint, since - * maximum value is always size of possibleChildren. - * - * @param augmentationType augmentation class - * @throws IllegalArgumentException - * If augmentation is invalid in current context. - * @throws IOException if an underlying IO error occurs - */ - void startAugmentationNode(Class> augmentationType) throws IOException, IllegalArgumentException; - - /** - * Emits anyxml node event. - * - * @param name - * @param value - * @throws IllegalArgumentException - * @throws IllegalStateException - * If node was emitted inside map, - * choice unkeyed list node. - * @throws IOException if an underlying IO error occurs - */ - void anyxmlNode(String name, Object value) throws IOException, IllegalArgumentException; - - /** - * Emits end event for node. - * - * @throws IllegalStateException If there is no open node. - * @throws IOException if an underlying IO error occurs - */ - void endNode() throws IOException, IllegalStateException; - - @Override - void flush() throws IOException; - - @Override - void close() throws IOException; -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/ChildTreeNode.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/ChildTreeNode.java deleted file mode 100644 index 4084ebe579..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/ChildTreeNode.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding; - -/** - * Child of parent container - * - * Marker interface uniquelly bounding generated Java interfaces to their - * parent container. - * - * Any nested Java interface generated from YANG must implement this interface, - * where parameter P points to it's defining data node container - * (interface generated for List, Container, Case). - * - * In case of children added by augmentation (which implements {@link Augmentation}) - * interfaces representing nested container must implements {@link ChildTreeNode} with - * same argument as Augmentation. - * - * @param

Parent container - */ -public interface ChildTreeNode

extends TreeNode { - -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/DataObjectSerializer.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/DataObjectSerializer.java deleted file mode 100644 index bd3a2a465a..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/DataObjectSerializer.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding; - -import java.io.IOException; - -/** - * A serializer which writes DataObject to supplied stream event writer. - */ -public interface DataObjectSerializer { - /** - * Writes stream events representing object to supplied stream - * - * @param obj - * Source of stream events - * @param stream - * Stream to which events should be written. - */ - void serialize(TreeNode obj, BindingStreamEventWriter stream) throws IOException; -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/DataObjectSerializerImplementation.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/DataObjectSerializerImplementation.java deleted file mode 100644 index 229d9f223b..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/DataObjectSerializerImplementation.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding; - -import java.io.IOException; - -/** - * SPI-level contract for implementations of {@link DataObjectSerializer}. - * The contract is kept between implementation of {@link DataObjectSerializerRegistry}, - * which maintains the lookup context required for recursive serialization. - * - * FIXME: this interface needs to be moved into .spi, but due to classpath funkyness - * of OSGi, that change has to be carefully orchestrated to ensure proper imports - * exist in all generated packages. One avenue how to achieve that is to move - * {@link YangModuleInfo} and modify code generator to add a static field - * to all generated classes which will point to the per-model YangModuleInfo - * (currently all users of it have to walk the package hierarchy, so that - * is an improvement in and of itself). - * - */ -public interface DataObjectSerializerImplementation { - /** - * - * Writes stream events for supplied data object to provided stream. - * - * DataObjectSerializerRegistry may be used to lookup serializers - * for other generated classes in order to support writing - * their events. - * - */ - void serialize(DataObjectSerializerRegistry reg, TreeNode obj, BindingStreamEventWriter stream) throws IOException; -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/DataObjectSerializerRegistry.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/DataObjectSerializerRegistry.java deleted file mode 100644 index 6e2a67e8db..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/DataObjectSerializerRegistry.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding; - -/** - * SPI-level contract for registry of {@link DataObjectSerializer}. - * The contract is kept between implementation of {@link DataObjectSerializerImplementation}, - * Registry provides lookup for serializers to support recursive - * serialization of nested {@link TreeNode}s. - * - * FIXME: this interface needs to be moved into .spi, but due to classpath funkyness - * of OSGi, that change has to be carefully orchestrated to ensure proper imports - * exist in all generated pacakges. One avenue how to achieve that is to move - * {@link YangModuleInfo} and modify code generator to add a static field - * to all generated classes which will point to the per-model YangModuleInfo - * (currently all users of it have to walk the package hierarchy, so that - * is an improvement in and of itself). - * - */ -public interface DataObjectSerializerRegistry { - - DataObjectSerializer getSerializer(Class binding); - -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/IdentifiableListItem.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/IdentifiableListItem.java deleted file mode 100644 index 82a84259d3..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/IdentifiableListItem.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding; - - -/** - * IdentifiableListItem object, which could be identified by it's key - * - * @param Identifier class for this object - * - */ -public interface IdentifiableListItem>> { - - /** - * Returns an unique identifier for the object - * - * @return Identifier for the object - */ - T identifier(); -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/Identifier.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/Identifier.java deleted file mode 100644 index 9b2c0d56b6..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/Identifier.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding; - -/** - * - * Object is unique identifier for another object - * - * - * - * @param - * Class of object for which this object is identifier - * @author ttkacik - */ -public interface Identifier> extends org.opendaylight.yangtools.concepts.Identifier { - -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifier.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifier.java deleted file mode 100644 index 98392625ad..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifier.java +++ /dev/null @@ -1,717 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding; - -import com.google.common.base.MoreObjects; -import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableCollection; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; -import java.io.IOException; -import java.io.Serializable; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import org.opendaylight.yangtools.concepts.Builder; -import org.opendaylight.yangtools.concepts.Immutable; -import org.opendaylight.yangtools.concepts.Path; -import org.opendaylight.yangtools.util.HashCodeBuilder; - -/** - * - * This instance identifier uniquely identifies a specific DataObject in the data tree modeled by YANG. - * - * For Example let's say you were trying to refer to a node in inventory which was modeled in YANG as follows, - * - *

- * module opendaylight-inventory {
- *      ....
- *
- *      container nodes {
- *        list node {
- *            key "id";
- *            ext:context-instance "node-context";
- *
- *            uses node;
- *        }
- *    }
- *
- * }
- * 
- * - * You could create an instance identifier as follows to get to a node with id "openflow:1" - * - * InstanceIdentifierBuilder.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId("openflow:1")).build(); - * - * This would be the same as using a path like so, "/nodes/node/openflow:1" to refer to the openflow:1 node - * - */ -public class InstanceIdentifier implements Path>, Immutable, Serializable { - private static final Field PATHARGUMENTS_FIELD; - private static final long serialVersionUID = 2L; - /* - * Protected to differentiate internal and external access. Internal - * access is required never to modify the contents. References passed - * to outside entities have to be wrapped in an unmodifiable view. - */ - protected transient final Iterable pathArguments; - private final Class targetType; - private final boolean wildcarded; - private final int hash; - - static { - final Field f; - try { - f = InstanceIdentifier.class.getDeclaredField("pathArguments"); - } catch (NoSuchFieldException | SecurityException e) { - throw new ExceptionInInitializerError(e); - } - f.setAccessible(true); - PATHARGUMENTS_FIELD = f; - } - - InstanceIdentifier(final Class type, final Iterable pathArguments, final boolean wildcarded, final int hash) { - this.pathArguments = Preconditions.checkNotNull(pathArguments); - this.targetType = Preconditions.checkNotNull(type); - this.wildcarded = wildcarded; - this.hash = hash; - } - - /** - * Return the type of data which this InstanceIdentifier identifies. - * - * @return Target type - */ - public final Class getTargetType() { - return targetType; - } - - /** - * Return the path argument chain which makes up this instance identifier. - * - * @return Path argument chain. Immutable and does not contain nulls. - */ - public final Iterable getPathArguments() { - return Iterables.unmodifiableIterable(pathArguments); - } - - /** - * Check whether an instance identifier contains any wildcards. A wildcard - * is an path argument which has a null key. - * - * @return true if any of the path arguments has a null key. - */ - public final boolean isWildcarded() { - return wildcarded; - } - - @Override - public final int hashCode() { - return hash; - } - - @Override - public final boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - - final InstanceIdentifier other = (InstanceIdentifier) obj; - if (pathArguments == other.pathArguments) { - return true; - } - - /* - * We could now just go and compare the pathArguments, but that - * can be potentially expensive. Let's try to avoid that by - * checking various things that we have cached from pathArguments - * and trying to prove the identifiers are *not* equal. - */ - if (hash != other.hash) { - return false; - } - if (wildcarded != other.wildcarded) { - return false; - } - if (targetType != other.targetType) { - return false; - } - if (fastNonEqual(other)) { - return false; - } - - // Everything checks out so far, so we have to do a full equals - return Iterables.elementsEqual(pathArguments, other.pathArguments); - } - - /** - * Perform class-specific fast checks for non-equality. This allows - * subclasses to avoid iterating over the pathArguments by performing - * quick checks on their specific fields. - * - * @param other The other identifier, guaranteed to be the same class - * @return true if the other identifier cannot be equal to this one. - */ - protected boolean fastNonEqual(final InstanceIdentifier other) { - return false; - } - - @Override - public final String toString() { - return addToStringAttributes(MoreObjects.toStringHelper(this)).toString(); - } - - /** - * Add class-specific toString attributes. - * - * @param toStringHelper ToStringHelper instance - * @return ToStringHelper instance which was passed in - */ - protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) { - return toStringHelper.add("targetType", targetType).add("path", Iterables.toString(pathArguments)); - } - - /** - * Return an instance identifier trimmed at the first occurrence of a - * specific component type. - * - * For example let's say an instance identifier was built like so, - *
-     *      identifier = InstanceIdentifierBuilder.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId("openflow:1")).build();
-     * 
- * - * And you wanted to obtain the Instance identifier which represented Nodes you would do it like so, - * - *
-     *      identifier.firstIdentifierOf(Nodes.class)
-     * 
- * - * @param type component type - * @return trimmed instance identifier, or null if the component type - * is not present. - */ - public final InstanceIdentifier firstIdentifierOf(final Class type) { - int i = 1; - for (final PathArgument a : pathArguments) { - if (type.equals(a.getType())) { - @SuppressWarnings("unchecked") - final InstanceIdentifier ret = (InstanceIdentifier) internalCreate(Iterables.limit(pathArguments, i)); - return ret; - } - - ++i; - } - - return null; - } - - /** - * Return the key associated with the first component of specified type in - * an identifier. - * - * @param listItem component type - * @param listKey component key type - * @return key associated with the component, or null if the component type - * is not present. - * - * @deprecated Use {@link #firstKeyOf(Class)} instead. - */ - @Deprecated - public final & TreeNode, K extends Identifier> K firstKeyOf(final Class listItem, final Class listKey) { - return firstKeyOf(listItem); - } - - /** - * Return the key associated with the first component of specified type in - * an identifier. - * - * @param listItem component type - * @return key associated with the component, or null if the component type - * is not present. - */ - public final & TreeNode, K extends Identifier> K firstKeyOf(final Class listItem) { - for (final PathArgument i : pathArguments) { - if (listItem.equals(i.getType())) { - @SuppressWarnings("unchecked") - final K ret = ((IdentifiableItem)i).getKey(); - return ret; - } - } - - return null; - } - - /** - * Check whether an identifier is contained in this identifier. This is a strict subtree check, which requires all - * PathArguments to match exactly, e.g. - * - * - * The contains method checks if the other identifier is fully contained within the current identifier. It does this - * by looking at only the types of the path arguments and not by comparing the path arguments themselves. - * - * To illustrate here is an example which explains the working of this API. - * - * Let's say you have two instance identifiers as follows, - * - * this = /nodes/node/openflow:1 - * other = /nodes/node/openflow:2 - * - * then this.contains(other) will return false. - * - * @param other - * @return - */ - @Override - public final boolean contains(final InstanceIdentifier other) { - Preconditions.checkNotNull(other, "other should not be null"); - - final Iterator lit = pathArguments.iterator(); - final Iterator oit = other.pathArguments.iterator(); - - while (lit.hasNext()) { - if (!oit.hasNext()) { - return false; - } - - if (!lit.next().equals(oit.next())) { - return false; - } - } - - return true; - } - - /** - * Check whether this instance identifier contains the other identifier after wildcard expansion. This is similar - * to {@link #contains(InstanceIdentifier)}, with the exception that a wildcards are assumed to match the their - * non-wildcarded PathArgument counterpart. - * - * @param other Identifier which should be checked for inclusion. - * @return true if this identifier contains the other object - */ - public final boolean containsWildcarded(final InstanceIdentifier other) { - Preconditions.checkNotNull(other, "other should not be null"); - - final Iterator lit = pathArguments.iterator(); - final Iterator oit = other.pathArguments.iterator(); - - while (lit.hasNext()) { - if (!oit.hasNext()) { - return false; - } - - final PathArgument la = lit.next(); - final PathArgument oa = oit.next(); - - if (!la.getType().equals(oa.getType())) { - return false; - } - if (la instanceof IdentifiableItem && oa instanceof IdentifiableItem && !la.equals(oa)) { - return false; - } - } - - return true; - } - - /** - * Create a builder rooted at this key. - * - * @return A builder instance - */ - public InstanceIdentifierBuilder builder() { - return new InstanceIdentifierBuilderImpl(new Item(targetType), pathArguments, hash, isWildcarded()); - } - - private InstanceIdentifier childIdentifier(final PathArgument arg) { - return trustedCreate(arg, Iterables.concat(pathArguments, Collections.singleton(arg)), HashCodeBuilder.nextHashCode(hash, arg), isWildcarded()); - } - - @SuppressWarnings("unchecked") - public final > InstanceIdentifier child(final Class container) { - final PathArgument arg = new Item<>(container); - return (InstanceIdentifier) childIdentifier(arg); - } - - @SuppressWarnings("unchecked") - public final & ChildTreeNode, K extends Identifier> KeyedInstanceIdentifier child( - final Class listItem, final K listKey) { - final PathArgument arg = new IdentifiableItem<>(listItem, listKey); - return (KeyedInstanceIdentifier) childIdentifier(arg); - } - - @SuppressWarnings("unchecked") - public final > InstanceIdentifier augmentation( - final Class container) { - final PathArgument arg = new Item<>(container); - return (InstanceIdentifier) childIdentifier(arg); - } - - @Deprecated - private List legacyCache; - - /** - * @deprecated Use {@link #getPathArguments()} instead. - */ - @Deprecated - public final List getPath() { - if (legacyCache == null) { - legacyCache = ImmutableList.copyOf(pathArguments); - } - - return legacyCache; - } - - /** - * Create a new InstanceIdentifierBuilder given a base InstanceIdentifier - * - * @param base - * @param - * @return - * - * @deprecated Use {@link #builder()} instead. - */ - @Deprecated - public static InstanceIdentifierBuilder builder(final InstanceIdentifier base) { - return base.builder(); - } - - /** - * Create an InstanceIdentifierBuilder for a specific type of InstanceIdentifier as specified by container - * - * @param container - * @param - * @return - */ - public static > InstanceIdentifierBuilder builder(final Class container) { - return new InstanceIdentifierBuilderImpl().addNode(container); - } - - /** - * Create an InstanceIdentifierBuilder for a specific type of InstanceIdentifier which represents an IdentifiableItem - * - * @param listItem - * @param listKey - * @param - * @param - * @return - */ - public static & ChildTreeNode, K extends Identifier> InstanceIdentifierBuilder builder( - final Class listItem, final K listKey) { - return new InstanceIdentifierBuilderImpl().addNode(listItem, listKey); - } - - /** - * Create an instance identifier for a very specific object type. This method - * implements {@link #create(Iterable)} semantics, except it is used by internal - * callers, which have assured that the argument is an immutable Iterable. - * - * - * @param pathArguments The path to a specific node in the data tree - * @return InstanceIdentifier instance - * @throws IllegalArgumentException if pathArguments is empty or - * contains a null element. - */ - private static InstanceIdentifier internalCreate(final Iterable pathArguments) { - final Iterator it = Preconditions.checkNotNull(pathArguments, "pathArguments may not be null").iterator(); - final HashCodeBuilder hashBuilder = new HashCodeBuilder<>(); - boolean wildcard = false; - PathArgument a = null; - - while (it.hasNext()) { - a = it.next(); - Preconditions.checkArgument(a != null, "pathArguments may not contain null elements"); - - // TODO: sanity check ChildOf<>; - hashBuilder.addArgument(a); - - if (IdentifiableListItem.class.isAssignableFrom(a.getType()) && !(a instanceof IdentifiableItem)) { - wildcard = true; - } - } - Preconditions.checkArgument(a != null, "pathArguments may not be empty"); - - return trustedCreate(a, pathArguments, hashBuilder.build(), wildcard); - } - - /** - * Create an instance identifier for a very specific object type. - * - * Example - *
-     *  List<PathArgument> path = Arrays.asList(new Item(Nodes.class))
-     *  new InstanceIdentifier(path);
-     * 
- * - * @param pathArguments The path to a specific node in the data tree - * @return InstanceIdentifier instance - * @throws IllegalArgumentException if pathArguments is empty or - * contains a null element. - */ - public static InstanceIdentifier create(final Iterable pathArguments) { - if (pathArguments instanceof ImmutableCollection) { - @SuppressWarnings("unchecked") - final Iterable immutableArguments = (Iterable) pathArguments; - return internalCreate(immutableArguments); - } else { - return internalCreate(ImmutableList.copyOf(pathArguments)); - } - } - - /** - * Create an instance identifier for a very specific object type. - * - * For example - *
-     *      new InstanceIdentifier(Nodes.class)
-     * 
- * would create an InstanceIdentifier for an object of type Nodes - * - * @param type The type of the object which this instance identifier represents - * @return InstanceIdentifier instance - */ - @SuppressWarnings("unchecked") - public static InstanceIdentifier create(final Class type) { - return (InstanceIdentifier) create(Collections. singletonList(new Item<>(type))); - } - - /** - * Return the key associated with the last component of the specified identifier. - * - * @param id instance identifier - * @return key associated with the last component - * @throws IllegalArgumentException if the supplied identifier type cannot have a key. - * @throws NullPointerException if id is null. - */ - public static & TreeNode, K extends Identifier> K keyOf(final InstanceIdentifier id) { - Preconditions.checkNotNull(id); - Preconditions.checkArgument(id instanceof KeyedInstanceIdentifier, "%s does not have a key", id); - - @SuppressWarnings("unchecked") - final K ret = ((KeyedInstanceIdentifier)id).getKey(); - return ret; - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - static InstanceIdentifier trustedCreate(final PathArgument arg, final Iterable pathArguments, final int hash, boolean wildcarded) { - if (IdentifiableListItem.class.isAssignableFrom(arg.getType()) && !(wildcarded)) { - Identifier key = null; - if (arg instanceof IdentifiableItem) { - key = ((IdentifiableItem)arg).key; - } else { - wildcarded = true; - } - - return new KeyedInstanceIdentifier(arg.getType(), pathArguments, wildcarded, hash, key); - } else { - return new InstanceIdentifier(arg.getType(), pathArguments, wildcarded, hash); - } - } - - /** - * Path argument of {@link InstanceIdentifier}. - *

- * Interface which implementations are used as path components of the - * path in overall data tree. - */ - public interface PathArgument extends Comparable { - Class getType(); - } - - private static abstract class AbstractPathArgument implements PathArgument, Serializable { - private static final long serialVersionUID = 1L; - private final Class type; - - protected AbstractPathArgument(final Class type) { - this.type = Preconditions.checkNotNull(type, "Type may not be null."); - } - - @Override - public final Class getType() { - return type; - } - - @Override - public int hashCode() { - return type.hashCode(); - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final AbstractPathArgument other = (AbstractPathArgument) obj; - return type.equals(other.type); - } - - @Override - public int compareTo(final PathArgument arg) { - return type.getCanonicalName().compareTo(arg.getType().getCanonicalName()); - } - } - - /** - * An Item represents an object that probably is only one of it's kind. For example a Nodes object is only one of - * a kind. In YANG terms this would probably represent a container. - * - * @param - */ - public static final class Item extends AbstractPathArgument { - private static final long serialVersionUID = 1L; - - public Item(final Class type) { - super(type); - } - - @Override - public String toString() { - return getType().getName(); - } - } - - /** - * An IdentifiableItem represents a object that is usually present in a collection and can be identified uniquely - * by a key. In YANG terms this would probably represent an item in a list. - * - * @param An object that is identifiable by an identifier - * @param The identifier of the object - */ - public static final class IdentifiableItem & TreeNode, T extends Identifier> extends AbstractPathArgument { - private static final long serialVersionUID = 1L; - private final T key; - - public IdentifiableItem(final Class type, final T key) { - super(type); - this.key = Preconditions.checkNotNull(key, "Key may not be null."); - } - - public T getKey() { - return this.key; - } - - @Override - public boolean equals(final Object obj) { - return super.equals(obj) && key.equals(((IdentifiableItem) obj).getKey()); - } - - @Override - public int hashCode() { - return super.hashCode() * 31 + key.hashCode(); - } - - @Override - public String toString() { - return getType().getName() + "[key=" + key + "]"; - } - } - - - public interface InstanceIdentifierBuilder extends Builder> { - /** - * Append the specified container as a child of the current InstanceIdentifier referenced by the builder. - * - * This method should be used when you want to build an instance identifier by appending top-level - * elements - * - * Example, - *

-         *     InstanceIdentifier.builder().child(Nodes.class).build();
-         *
-         * 
- * - * NOTE :- The above example is only for illustration purposes InstanceIdentifier.builder() has been deprecated - * and should not be used. Use InstanceIdentifier.builder(Nodes.class) instead - * - * @param container - * @param - * @return - */ - > InstanceIdentifierBuilder child( - Class container); - - /** - * Append the specified listItem as a child of the current InstanceIdentifier referenced by the builder. - * - * This method should be used when you want to build an instance identifier by appending a specific list element - * to the identifier - * - * @param listItem - * @param listKey - * @param - * @param - * @return - */ - & ChildTreeNode, K extends Identifier> InstanceIdentifierBuilder child( - Class listItem, K listKey); - - /** - * Build an identifier which refers to a specific augmentation of the current InstanceIdentifier referenced by - * the builder - * - * @param container - * @param - * @return - */ - > InstanceIdentifierBuilder augmentation( - Class container); - - /** - * Build the instance identifier. - * - * @return - */ - @Override - InstanceIdentifier build(); - - /* - * @deprecated use #build() - */ - @Deprecated - InstanceIdentifier toInstance(); - } - - private void writeObject(final java.io.ObjectOutputStream out) throws IOException { - out.defaultWriteObject(); - out.writeInt(Iterables.size(pathArguments)); - for (Object o : pathArguments) { - out.writeObject(o); - } - } - - private void readObject(final java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - - final int size = in.readInt(); - final List args = new ArrayList<>(size); - for (int i = 0; i < size; ++i) { - args.add((PathArgument) in.readObject()); - } - - try { - PATHARGUMENTS_FIELD.set(this, ImmutableList.copyOf(args)); - } catch (IllegalArgumentException | IllegalAccessException e) { - throw new IOException(e); - } - } -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifierBuilderImpl.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifierBuilderImpl.java deleted file mode 100644 index 2f4ec1d282..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifierBuilderImpl.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding; - -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; -import org.opendaylight.yangtools.util.HashCodeBuilder; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.IdentifiableItem; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.Item; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument; - -final class InstanceIdentifierBuilderImpl implements InstanceIdentifier.InstanceIdentifierBuilder { - private final ImmutableList.Builder pathBuilder = ImmutableList.builder(); - private final HashCodeBuilder hashBuilder; - private final Iterable basePath; - private boolean wildcard = false; - private PathArgument arg = null; - - InstanceIdentifierBuilderImpl() { - this.hashBuilder = new HashCodeBuilder<>(); - this.basePath = null; - } - - InstanceIdentifierBuilderImpl(final PathArgument item, final Iterable pathArguments, final int hash, final boolean wildcard) { - this.hashBuilder = new HashCodeBuilder<>(hash); - this.basePath = pathArguments; - this.wildcard = wildcard; - this.arg = item; - } - - @Override - public int hashCode() { - return hashBuilder.build(); - } - - @SuppressWarnings("unchecked") - InstanceIdentifierBuilderImpl addNode(final Class container) { - arg = new Item(container); - hashBuilder.addArgument(arg); - pathBuilder.add(arg); - - if (IdentifiableListItem.class.isAssignableFrom(container)) { - wildcard = true; - } - - return (InstanceIdentifierBuilderImpl) this; - } - - @SuppressWarnings("unchecked") - , K extends Identifier> InstanceIdentifierBuilderImpl addNode(final Class listItem, final K listKey) { - arg = new IdentifiableItem(listItem, listKey); - hashBuilder.addArgument(arg); - pathBuilder.add(arg); - return (InstanceIdentifierBuilderImpl) this; - } - - @Override - public > InstanceIdentifierBuilderImpl child(final Class container) { - return addNode(container); - } - - @Override - public & ChildTreeNode, K extends Identifier> InstanceIdentifierBuilderImpl child(final Class listItem, final K listKey) { - return addNode(listItem, listKey); - } - - /** - * Build an identifier which refers to a specific augmentation of the current InstanceIdentifier referenced by - * the builder - * - * @param container - * @param - * @return - */ - @Override - public > InstanceIdentifierBuilderImpl augmentation(final Class container) { - return addNode(container); - } - - @Override - public InstanceIdentifier build() { - Preconditions.checkState(arg != null, "No path arguments present"); - - final Iterable pathArguments; - if (basePath == null) { - pathArguments = pathBuilder.build(); - } else { - pathArguments = Iterables.concat(basePath, pathBuilder.build()); - } - - @SuppressWarnings("unchecked") - final InstanceIdentifier ret = (InstanceIdentifier) InstanceIdentifier.trustedCreate(arg, pathArguments, hashBuilder.build(), wildcard); - return ret; - } - - /* - * @deprecated Use #build() instead. - */ - @Override - @Deprecated - public InstanceIdentifier toInstance() { - return build(); - } -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/InterfaceTyped.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/InterfaceTyped.java deleted file mode 100644 index 5528dcc9be..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/InterfaceTyped.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding; - -/** - * InterfaceTyped - object contains structured data - * - * Marker interface which must be implemented by all interfaces - * generated for YANG: - *
    - *
  • Rpc Input - *
  • Output - *
  • Notification - *
  • Container - *
  • List - *
  • Case - *
- */ -public interface InterfaceTyped { - //FIXME: add generics - - Class implementedInterface(); -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/KeyedInstanceIdentifier.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/KeyedInstanceIdentifier.java deleted file mode 100644 index 5d76ced0e5..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/KeyedInstanceIdentifier.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding; - -/** - * An {@link InstanceIdentifier}, which has a list key attached at its last path - * element. - * - * @param Target data type - * @param Target key type - */ -public class KeyedInstanceIdentifier & TreeNode, K extends Identifier> extends InstanceIdentifier { - private static final long serialVersionUID = 1L; - private final K key; - - KeyedInstanceIdentifier(final Class type, final Iterable pathArguments, final boolean wildcarded, final int hash, final K key) { - super(type, pathArguments, wildcarded, hash); - this.key = key; - } - - /** - * Return the key attached to this identifier. This method is equivalent to - * calling {@link InstanceIdentifier#keyOf(InstanceIdentifier)}. - * - * @return Key associated with this instance identifier. - */ - public final K getKey() { - return key; - } - - @Override - public final InstanceIdentifierBuilder builder() { - return new InstanceIdentifierBuilderImpl(new InstanceIdentifier.IdentifiableItem(getTargetType(), key), pathArguments, hashCode(), isWildcarded()); - } - - @Override - protected boolean fastNonEqual(final InstanceIdentifier other) { - final KeyedInstanceIdentifier kii = (KeyedInstanceIdentifier) other; - - /* - * We could do an equals() here, but that may actually be expensive. - * equals() in superclass falls back to a full compare, which will - * end up running that equals anyway, so do not bother here. - */ - return (key == null) != (kii.key == null); - } -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/Notification.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/Notification.java deleted file mode 100644 index 5903e5efbf..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/Notification.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding; - -/** - * Marker interface for YANG-defined notifications - * - * - */ -public interface Notification extends InterfaceTyped { - -} - diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/NotificationListener.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/NotificationListener.java deleted file mode 100644 index e896c9fd3d..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/NotificationListener.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding; - -import java.util.EventListener; - -/** - * Marker interface for generated notification listener interfaces. This interface - * exists solely as support for generated code. Users should never implement this - * interface directly, but rather implement one of the sub-interfaces generated - * from a YANG model. - * - *

- * The subclasses of this interface have callbacks for events, which are derived - * from {@link Notification} class in form void - * on{NotificationType}(NotificationType notification). - * - *

- * E.g. if we have notification SessionUp the callback will have signature: - * void onSessionUp(SessionUp notification) - */ -public interface NotificationListener extends EventListener { - -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/RpcImplementation.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/RpcImplementation.java deleted file mode 100644 index 229e35e1d8..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/RpcImplementation.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding; - -import java.util.Set; -import java.util.concurrent.Future; - -import org.opendaylight.yangtools.yang.common.RpcResult; - -public interface RpcImplementation { - - // Fixme: Change to RpcInput - Set> getSupportedInputs(); - - // Fixme: Change to RpcInput - Future> invoke(Class type, T input); -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/RpcInput.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/RpcInput.java deleted file mode 100644 index 89f4314602..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/RpcInput.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding; - -public interface RpcInput extends InterfaceTyped { - -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/RpcService.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/RpcService.java deleted file mode 100644 index f2f160a5a4..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/RpcService.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding; - -/** - * Marker interface for tagging generated YANG Modules - * - */ -public interface RpcService { - -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/TreeNode.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/TreeNode.java deleted file mode 100644 index c924285454..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/TreeNode.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding; - -/** - * - * Data container is an interface which has structured contents. - * - */ -public interface TreeNode extends InterfaceTyped { - - -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/TreeRoot.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/TreeRoot.java deleted file mode 100644 index e22b27d445..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/TreeRoot.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding; - -/** - * - * Root node without any parent - * - */ -public interface TreeRoot extends TreeNode { - -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/YangModelBindingProvider.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/YangModelBindingProvider.java deleted file mode 100644 index 9a5fd6397d..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/YangModelBindingProvider.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding; - -import java.util.ServiceLoader; - -/** - * - * Provider of YangModuleInfo for specified package / model. - * - * Implementation of this interface should be discoverable - * via {@link ServiceLoader} - * - * - * - */ -public interface YangModelBindingProvider { - - /** - * YangModuleInfo associated to package - * - * @return - */ - YangModuleInfo getModuleInfo(); - -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/YangModuleInfo.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/YangModuleInfo.java deleted file mode 100644 index 2affccedfb..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/YangModuleInfo.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding; - -import java.io.InputStream; -import java.io.IOException; -import java.util.Set; - -public interface YangModuleInfo { - - /** - * Returns yang module name - * - * @return - */ - String getName(); - - /** - * - * Returns revision of yang module. - * - * @return - */ - String getRevision(); - - /** - * Returns XML namespace associated to the YANG module - * - * @return XML namespace associated to the YANG module. - */ - String getNamespace(); - - InputStream getModuleSourceStream() throws IOException; - - Set getImportedModules(); - -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/annotations/ModuleQName.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/annotations/ModuleQName.java deleted file mode 100644 index fceccc7d4f..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/annotations/ModuleQName.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Maintains information about yang module from which class using this annotation was generated. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE, ElementType.PACKAGE}) -public @interface ModuleQName { - String namespace(); - String revision(); - String name(); -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/annotations/QName.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/annotations/QName.java deleted file mode 100644 index 49fb66f25a..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/annotations/QName.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding.annotations; - - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -@Retention(RetentionPolicy.RUNTIME) -public @interface QName { - - String namespace(); - String revision(); - String name(); - -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/annotations/RoutingContext.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/annotations/RoutingContext.java deleted file mode 100644 index 514945a04d..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/annotations/RoutingContext.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding.annotations; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.opendaylight.yangtools.yang.binding.BaseIdentity; - - -@Inherited -@Documented -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.RUNTIME) -public @interface RoutingContext { - - Class value(); -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/package-info.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/package-info.java deleted file mode 100644 index eee24a978e..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding; \ No newline at end of file diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/AbstractMappedRpcInvoker.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/AbstractMappedRpcInvoker.java deleted file mode 100644 index ac9777d3ae..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/AbstractMappedRpcInvoker.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding.util; - -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; -import java.lang.reflect.Method; -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.Future; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import org.opendaylight.yangtools.yang.binding.TreeNode; -import org.opendaylight.yangtools.yang.binding.RpcService; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -abstract class AbstractMappedRpcInvoker extends RpcServiceInvoker { - private static final Logger LOG = LoggerFactory.getLogger(AbstractMappedRpcInvoker.class); - private final Map map; - - protected AbstractMappedRpcInvoker(final Map map) { - final Builder b = ImmutableMap.builder(); - - for (Entry e : map.entrySet()) { - if (BindingReflections.isRpcMethod(e.getValue())) { - b.put(e.getKey(), RpcMethodInvoker.from(e.getValue())); - } else { - LOG.debug("Method {} is not an RPC method, ignoring it", e.getValue()); - } - } - - this.map = b.build(); - } - - protected abstract T qnameToKey(final QName qname); - - @Override - public final Future> invokeRpc(@Nonnull final RpcService impl, @Nonnull final QName rpcName, @Nullable final TreeNode input) { - Preconditions.checkNotNull(impl, "implemetation must be supplied"); - - RpcMethodInvoker invoker = map.get(qnameToKey(rpcName)); - Preconditions.checkArgument(invoker != null, "Supplied RPC is not valid for implementation %s", impl); - return invoker.invokeOn(impl, input); - } -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/AugmentationFieldGetter.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/AugmentationFieldGetter.java deleted file mode 100644 index ce86bb113a..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/AugmentationFieldGetter.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding.util; - -import com.google.common.base.Preconditions; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodHandles.Lookup; -import java.lang.invoke.MethodType; -import java.lang.reflect.Field; -import java.util.Collections; -import java.util.Map; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.binding.AugmentationHolder; -import org.opendaylight.yangtools.yang.binding.BindingMapping; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -abstract class AugmentationFieldGetter { - - private static final Logger LOG = LoggerFactory.getLogger(AugmentationFieldGetter.class); - - private static final AugmentationFieldGetter DUMMY = new AugmentationFieldGetter() { - @Override - protected Map>, Augmentation> getAugmentations(final Object input) { - return Collections.emptyMap(); - } - }; - - private static final AugmentationFieldGetter AUGMENTATION_HOLDER_GETTER = new AugmentationFieldGetter() { - - @Override - @SuppressWarnings({"unchecked", "rawtypes"}) - protected Map>, Augmentation> getAugmentations(final Object input) { - return (Map) ((AugmentationHolder) input).augmentations(); - } - }; - - /** - * - * Retrieves augmentations from supplied object - * - * @param input Input Data object, from which augmentations should be extracted - * @return Map of Augmentation class to augmentation - */ - protected abstract Map>, Augmentation> getAugmentations(final Object input); - - private static final LoadingCache, AugmentationFieldGetter> AUGMENTATION_GETTERS = CacheBuilder - .newBuilder().weakKeys().build(new AugmentationGetterLoader()); - - public static AugmentationFieldGetter getGetter(final Class clz) { - if(AugmentationHolder.class.isAssignableFrom(clz)) { - return AUGMENTATION_HOLDER_GETTER; - } - return AUGMENTATION_GETTERS.getUnchecked(clz); - } - - private static final class AugmentationGetterLoader extends CacheLoader, AugmentationFieldGetter> { - private static final MethodType GETTER_TYPE = MethodType.methodType(Map.class, Object.class); - private static final Lookup LOOKUP = MethodHandles.lookup(); - - @Override - public AugmentationFieldGetter load(final Class key) throws IllegalAccessException { - final Field field; - try { - field = key.getDeclaredField(BindingMapping.AUGMENTATION_FIELD); - field.setAccessible(true); - } catch (NoSuchFieldException | SecurityException e) { - LOG.warn("Failed to acquire augmentation field {}, ignoring augmentations in class {}", - BindingMapping.AUGMENTATION_FIELD, key, e); - return DUMMY; - } - if (!Map.class.isAssignableFrom(field.getType())) { - LOG.warn("Class {} field {} is not a Map, ignoring augmentations", key, - BindingMapping.AUGMENTATION_FIELD); - return DUMMY; - } - - return new ReflectionAugmentationFieldGetter(LOOKUP.unreflectGetter(field).asType(GETTER_TYPE)); - } - } - - private static final class ReflectionAugmentationFieldGetter extends AugmentationFieldGetter { - private final MethodHandle fieldGetter; - - ReflectionAugmentationFieldGetter(final MethodHandle mh) { - this.fieldGetter = Preconditions.checkNotNull(mh); - } - - @Override - protected Map>, Augmentation> getAugmentations(final Object input) { - try { - return (Map>, Augmentation>) fieldGetter.invokeExact(input); - } catch (Throwable e) { - throw new IllegalStateException("Failed to access augmentation field on " + input, e); - } - } - } -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/BindingReflections.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/BindingReflections.java deleted file mode 100644 index 1dc4706572..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/BindingReflections.java +++ /dev/null @@ -1,671 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding.util; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkState; - -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; -import com.google.common.collect.Sets; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Type; -import java.net.URI; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.ServiceLoader; -import java.util.concurrent.Callable; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.opendaylight.yangtools.util.ClassLoaderUtils; -import org.opendaylight.yangtools.yang.binding.Augmentable; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.binding.BaseIdentity; -import org.opendaylight.yangtools.yang.binding.BindingMapping; -import org.opendaylight.yangtools.yang.binding.ChildTreeNode; -import org.opendaylight.yangtools.yang.binding.InterfaceTyped; -import org.opendaylight.yangtools.yang.binding.TreeNode; -import org.opendaylight.yangtools.yang.binding.Notification; -import org.opendaylight.yangtools.yang.binding.RpcService; -import org.opendaylight.yangtools.yang.binding.YangModelBindingProvider; -import org.opendaylight.yangtools.yang.binding.YangModuleInfo; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.QNameModule; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class BindingReflections { - - private static final long EXPIRATION_TIME = 60; - private static final String ROOT_PACKAGE_PATTERN_STRING = "(org.opendaylight.yang.gen.v1.[a-z0-9_\\.]*\\.rev[0-9][0-9][0-1][0-9][0-3][0-9])"; - private static final Pattern ROOT_PACKAGE_PATTERN = Pattern.compile(ROOT_PACKAGE_PATTERN_STRING); - private static final Logger LOG = LoggerFactory.getLogger(BindingReflections.class); - - private static final LoadingCache, Optional> CLASS_TO_QNAME = CacheBuilder.newBuilder() // - .weakKeys() // - .expireAfterAccess(EXPIRATION_TIME, TimeUnit.SECONDS) // - .build(new ClassToQNameLoader()); - - private BindingReflections() { - throw new UnsupportedOperationException("Utility class."); - } - - /** - * Find augmentation target class from concrete Augmentation class - * - * This method uses first generic argument of implemented - * {@link Augmentation} interface. - * - * @param augmentation - * {@link Augmentation} subclass for which we want to determine - * augmentation target. - * @return Augmentation target - class which augmentation provides - * additional extensions. - */ - public static Class> findAugmentationTarget( - final Class> augmentation) { - return ClassLoaderUtils.findFirstGenericArgument(augmentation, Augmentation.class); - } - - /** - * Find data hierarchy parent from concrete Data class - * - * This method uses first generic argument of implemented {@link ChildTreeNode} - * interface. - * - * @param childClass - * child class for which we want to find the parent class. - * @return Parent class, e.g. class of which the childClass is ChildOf. - */ - public static Class findHierarchicalParent(final Class> childClass) { - return ClassLoaderUtils.findFirstGenericArgument(childClass, ChildTreeNode.class); - } - - /** - * Find data hierarchy parent from concrete Data class - * - * This method is shorthand which gets DataObject class by invoking - * {@link TreeNode#implementedInterface()} and uses - * {@link #findHierarchicalParent(Class)}. - * - * @param child - * Child object for which the parent needs to be located. - * @return Parent class, or null if a parent is not found. - */ - public static Class findHierarchicalParent(final TreeNode child) { - if (child instanceof ChildTreeNode) { - return ClassLoaderUtils.findFirstGenericArgument(child.implementedInterface(), ChildTreeNode.class); - } - return null; - } - - /** - * Returns a QName associated to supplied type - * - * @param dataType - * @return QName associated to supplied dataType. If dataType is - * Augmentation method does not return canonical QName, but QName - * with correct namespace revision, but virtual local name, since - * augmentations do not have name. - * - * May return null if QName is not present. - */ - public static final QName findQName(final Class dataType) { - return CLASS_TO_QNAME.getUnchecked(dataType).orNull(); - } - - /** - * Checks if method is RPC invocation - * - * - * - * @param possibleMethod - * Method to check - * @return true if method is RPC invocation, false otherwise. - */ - public static boolean isRpcMethod(final Method possibleMethod) { - return possibleMethod != null && RpcService.class.isAssignableFrom(possibleMethod.getDeclaringClass()) - && Future.class.isAssignableFrom(possibleMethod.getReturnType()) - && possibleMethod.getParameterTypes().length <= 1; - } - - /** - * - * Extracts Output class for RPC method - * - * @param targetMethod - * method to scan - * @return Optional.empty() if result type could not be get, or return type - * is Void. - */ - @SuppressWarnings("rawtypes") - public static Optional> resolveRpcOutputClass(final Method targetMethod) { - checkState(isRpcMethod(targetMethod), "Supplied method is not Rpc invocation method"); - Type futureType = targetMethod.getGenericReturnType(); - Type rpcResultType = ClassLoaderUtils.getFirstGenericParameter(futureType); - Type rpcResultArgument = ClassLoaderUtils.getFirstGenericParameter(rpcResultType); - if (rpcResultArgument instanceof Class && !Void.class.equals(rpcResultArgument)) { - return Optional.> of((Class) rpcResultArgument); - } - return Optional.empty(); - } - - /** - * - * Extracts input class for RPC method - * - * @param targetMethod - * method to scan - * @return Optional.empty() if rpc has no input, Rpc input type otherwise. - */ - @SuppressWarnings("unchecked") - public static Optional> resolveRpcInputClass(final Method targetMethod) { - @SuppressWarnings("rawtypes") - Class[] types = targetMethod.getParameterTypes(); - if (types.length == 0) { - return Optional.empty(); - } - if (types.length == 1) { - return Optional.> of(types[0]); - } - throw new IllegalArgumentException("Method has 2 or more arguments."); - } - - public static QName getQName(final Class context) { - return findQName(context); - } - - /** - * - * Checks if class is child of augmentation. - * - * - * @param clazz - * @return - */ - public static boolean isAugmentationChild(final Class clazz) { - // FIXME: Current resolver could be still confused when - // child node was added by grouping - checkArgument(clazz != null); - - @SuppressWarnings({ "rawtypes", "unchecked" }) - Class parent = findHierarchicalParent((Class) clazz); - if (parent == null) { - LOG.debug("Did not find a parent for class {}", clazz); - return false; - } - - String clazzModelPackage = getModelRootPackageName(clazz.getPackage()); - String parentModelPackage = getModelRootPackageName(parent.getPackage()); - - return !clazzModelPackage.equals(parentModelPackage); - } - - /** - * Returns root package name for suplied package. - * - * @param pkg - * Package for which find model root package. - * @return Package of model root. - */ - public static String getModelRootPackageName(final Package pkg) { - return getModelRootPackageName(pkg.getName()); - } - - /** - * Returns root package name for supplied package name. - * - * @param name - * Package for which find model root package. - * @return Package of model root. - */ - public static String getModelRootPackageName(final String name) { - checkArgument(name != null, "Package name should not be null."); - checkArgument(name.startsWith(BindingMapping.PACKAGE_PREFIX), "Package name not starting with %s, is: %s", - BindingMapping.PACKAGE_PREFIX, name); - Matcher match = ROOT_PACKAGE_PATTERN.matcher(name); - checkArgument(match.find(), "Package name '%s' does not match required pattern '%s'", name, - ROOT_PACKAGE_PATTERN_STRING); - return match.group(0); - } - - public static final QNameModule getQNameModule(final Class clz) { - if(InterfaceTyped.class.isAssignableFrom(clz) || BaseIdentity.class.isAssignableFrom(clz)) { - return findQName(clz).getModule(); - } - try { - YangModuleInfo modInfo = BindingReflections.getModuleInfo(clz); - return getQNameModule(modInfo); - } catch (Exception e) { - throw new IllegalStateException("Unable to get QName of defining model.", e); - } - } - - public static final QNameModule getQNameModule(final YangModuleInfo modInfo) { - return QNameModule.create(URI.create(modInfo.getNamespace()), QName.parseRevision(modInfo.getRevision())); - } - - /** - * - * Returns instance of {@link YangModuleInfo} of declaring model for - * specific class. - * - * @param cls - * @return Instance of {@link YangModuleInfo} associated with model, from - * which this class was derived. - * @throws Exception - */ - public static YangModuleInfo getModuleInfo(final Class cls) throws Exception { - checkArgument(cls != null); - String packageName = getModelRootPackageName(cls.getPackage()); - final String potentialClassName = getModuleInfoClassName(packageName); - return ClassLoaderUtils.withClassLoader(cls.getClassLoader(), new Callable() { - @Override - public YangModuleInfo call() throws ClassNotFoundException, IllegalAccessException, - IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { - Class moduleInfoClass = Thread.currentThread().getContextClassLoader().loadClass(potentialClassName); - return (YangModuleInfo) moduleInfoClass.getMethod("getInstance").invoke(null); - } - }); - } - - public static String getModuleInfoClassName(final String packageName) { - return packageName + "." + BindingMapping.MODULE_INFO_CLASS_NAME; - } - - /** - * - * Check if supplied class is derived from YANG model. - * - * @param cls - * Class to check - * @return true if class is derived from YANG model. - */ - public static boolean isBindingClass(final Class cls) { - if (InterfaceTyped.class.isAssignableFrom(cls) || Augmentation.class.isAssignableFrom(cls)) { - return true; - } - return (cls.getName().startsWith(BindingMapping.PACKAGE_PREFIX)); - } - - /** - * - * Checks if supplied method is callback for notifications. - * - * @param method - * @return true if method is notification callback. - */ - public static boolean isNotificationCallback(final Method method) { - checkArgument(method != null); - if (method.getName().startsWith("on") && method.getParameterTypes().length == 1) { - Class potentialNotification = method.getParameterTypes()[0]; - if (isNotification(potentialNotification) - && method.getName().equals("on" + potentialNotification.getSimpleName())) { - return true; - } - } - return false; - } - - /** - * - * Checks is supplied class is Notification. - * - * @param potentialNotification - * @return - */ - public static boolean isNotification(final Class potentialNotification) { - checkArgument(potentialNotification != null, "potentialNotification must not be null."); - return Notification.class.isAssignableFrom(potentialNotification); - } - - /** - * - * Loads {@link YangModuleInfo} infos available on current classloader. - * - * This method is shorthand for {@link #loadModuleInfos(ClassLoader)} with - * {@link Thread#getContextClassLoader()} for current thread. - * - * @return Set of {@link YangModuleInfo} available for current classloader. - */ - public static ImmutableSet loadModuleInfos() { - return loadModuleInfos(Thread.currentThread().getContextClassLoader()); - } - - /** - * - * Loads {@link YangModuleInfo} infos available on supplied classloader. - * - * {@link YangModuleInfo} are discovered using {@link ServiceLoader} for - * {@link YangModelBindingProvider}. {@link YangModelBindingProvider} are - * simple classes which holds only pointers to actual instance - * {@link YangModuleInfo}. - * - * When {@link YangModuleInfo} is available, all dependencies are - * recursivelly collected into returning set by collecting results of - * {@link YangModuleInfo#getImportedModules()}. - * - * - * @param loader - * Classloader for which {@link YangModuleInfo} should be - * retrieved. - * @return Set of {@link YangModuleInfo} available for supplied classloader. - */ - public static ImmutableSet loadModuleInfos(final ClassLoader loader) { - Builder moduleInfoSet = ImmutableSet. builder(); - ServiceLoader serviceLoader = ServiceLoader.load(YangModelBindingProvider.class, - loader); - for (YangModelBindingProvider bindingProvider : serviceLoader) { - YangModuleInfo moduleInfo = bindingProvider.getModuleInfo(); - checkState(moduleInfo != null, "Module Info for %s is not available.", bindingProvider.getClass()); - collectYangModuleInfo(bindingProvider.getModuleInfo(), moduleInfoSet); - } - return moduleInfoSet.build(); - } - - private static void collectYangModuleInfo(final YangModuleInfo moduleInfo, - final Builder moduleInfoSet) { - moduleInfoSet.add(moduleInfo); - for (YangModuleInfo dependency : moduleInfo.getImportedModules()) { - collectYangModuleInfo(dependency, moduleInfoSet); - } - } - - /** - * - * Checks if supplied class represents RPC Input / RPC Output. - * - * @param targetType - * Class to be checked - * @return true if class represents RPC Input or RPC Output class. - */ - public static boolean isRpcType(final Class targetType) { - return InterfaceTyped.class.isAssignableFrom(targetType) // - && !ChildTreeNode.class.isAssignableFrom(targetType) // - && !Notification.class.isAssignableFrom(targetType) // - && (targetType.getName().endsWith("Input") || targetType.getName().endsWith("Output")); - } - - /** - * - * Scans supplied class and returns an iterable of all data children - * classes. - * - * @param type - * YANG Modeled Entity derived from DataContainer - * @return Iterable of all data children, which have YANG modeled entity - */ - @SuppressWarnings("unchecked") - public static Iterable> getChildrenClasses(final Class type) { - checkArgument(type != null, "Target type must not be null"); - checkArgument(InterfaceTyped.class.isAssignableFrom(type), "Supplied type must be derived from DataContainer"); - List> ret = new LinkedList<>(); - for (Method method : type.getMethods()) { - Optional> entity = getYangModeledReturnType(method); - if (entity.isPresent()) { - ret.add((Class) entity.get()); - } - } - return ret; - } - - /** - * - * Scans supplied class and returns an iterable of all data children - * classes. - * - * @param type - * YANG Modeled Entity derived from DataContainer - * @return Iterable of all data children, which have YANG modeled entity - */ - public static Map, Method> getChildrenClassToMethod(final Class type) { - checkArgument(type != null, "Target type must not be null"); - checkArgument(InterfaceTyped.class.isAssignableFrom(type), "Supplied type must be derived from DataContainer"); - Map, Method> ret = new HashMap<>(); - for (Method method : type.getMethods()) { - Optional> entity = getYangModeledReturnType(method); - if (entity.isPresent()) { - ret.put(entity.get(), method); - } - } - return ret; - } - - @SuppressWarnings("unchecked") - private static Optional> getYangModeledReturnType(final Method method) { - if (method.getName().equals("getClass") || !method.getName().startsWith("get") - || method.getParameterTypes().length > 0) { - return Optional.empty(); - } - - @SuppressWarnings("rawtypes") - Class returnType = method.getReturnType(); - if (InterfaceTyped.class.isAssignableFrom(returnType)) { - return Optional.> of(returnType); - } else if (List.class.isAssignableFrom(returnType)) { - try { - return ClassLoaderUtils.withClassLoader(method.getDeclaringClass().getClassLoader(), - new Callable>>() { - @SuppressWarnings("rawtypes") - @Override - public Optional> call() { - Type listResult = ClassLoaderUtils.getFirstGenericParameter(method - .getGenericReturnType()); - if (listResult instanceof Class - && InterfaceTyped.class.isAssignableFrom((Class) listResult)) { - return Optional.> of((Class) listResult); - } - return Optional.empty(); - } - - }); - } catch (Exception e) { - /* - * - * It is safe to log this this exception on debug, since this - * method should not fail. Only failures are possible if the - * runtime / backing. - */ - LOG.debug("Unable to find YANG modeled return type for {}", method, e); - } - } - return Optional.empty(); - } - - private static class ClassToQNameLoader extends CacheLoader, Optional> { - - @Override - public Optional load(final Class key) throws Exception { - return resolveQNameNoCache(key); - } - } - - /** - * - * Tries to resolve QName for supplied class. - * - * Looks up for static field with name from constant - * {@link BindingMapping#QNAME_STATIC_FIELD_NAME} and returns value if - * present. - * - * If field is not present uses {@link #computeQName(Class)} to compute - * QName for missing types. - * - * @param key - * @return - */ - private static Optional resolveQNameNoCache(final Class key) { - try { - Field field = key.getField(BindingMapping.QNAME_STATIC_FIELD_NAME); - Object obj = field.get(null); - if (obj instanceof QName) { - return Optional.of((QName) obj); - } - - } catch (NoSuchFieldException e) { - return Optional.of(computeQName(key)); - - } catch (SecurityException | IllegalArgumentException | IllegalAccessException e) { - /* - * - * It is safe to log this this exception on debug, since this method - * should not fail. Only failures are possible if the runtime / - * backing. - */ - LOG.debug("Unexpected exception during extracting QName for {}", key, e); - } - return Optional.empty(); - } - - /** - * Computes QName for supplied class - * - * Namespace and revision are same as {@link YangModuleInfo} associated with - * supplied class. - *

- * If class is - *

    - *
  • rpc input: local name is "input". - *
  • rpc output: local name is "output". - *
  • augmentation: local name is "module name". - *
- * - * There is also fallback, if it is not possible to compute QName using - * following algorithm returns module QName. - * - * FIXME: Extend this algorithm to also provide QName for YANG modeled - * simple types. - * - * @throws IllegalStateException - * If YangModuleInfo could not be resolved - * @throws IllegalArgumentException - * If supplied class was not derived from YANG model. - * - */ - @SuppressWarnings({ "rawtypes", "unchecked" }) - private static QName computeQName(final Class key) { - if (isBindingClass(key)) { - YangModuleInfo moduleInfo; - try { - moduleInfo = getModuleInfo(key); - } catch (Exception e) { - throw new IllegalStateException("Unable to get QName for " + key + ". YangModuleInfo was not found.", e); - } - final QName module = getModuleQName(moduleInfo).intern(); - if (Augmentation.class.isAssignableFrom(key)) { - return module; - } else if (isRpcType(key)) { - final String className = key.getSimpleName(); - if (className.endsWith(BindingMapping.RPC_OUTPUT_SUFFIX)) { - return QName.create(module, "output").intern(); - } else { - return QName.create(module, "input").intern(); - } - } - /* - * Fallback for Binding types which do not have QNAME field - */ - return module; - } else { - throw new IllegalArgumentException("Supplied class " + key + "is not derived from YANG."); - } - } - - /** - * Given a {@link YangModuleInfo}, create a QName representing it. The QName - * is formed by reusing the module's namespace and revision using the - * module's name as the QName's local name. - * - * @param moduleInfo - * module information - * @return QName representing the module - */ - public static QName getModuleQName(final YangModuleInfo moduleInfo) { - checkArgument(moduleInfo != null, "moduleInfo must not be null."); - return QName.create(moduleInfo.getNamespace(), moduleInfo.getRevision(), moduleInfo.getName()); - } - - /** - * Extracts augmentation from Binding DTO field using reflection - * - * @param input - * Instance of DataObject which is augmentable and may contain - * augmentation - * @return Map of augmentations if read was successful, otherwise empty map. - */ - public static Map>, Augmentation> getAugmentations(final Augmentable input) { - return AugmentationFieldGetter.getGetter(input.getClass()).getAugmentations(input); - } - - /** - * - * Determines if two augmentation classes or case classes represents same - * data. - *

- * Two augmentations or cases could be substituted only if and if: - *

    - *
  • Both implements same interfaces
  • - *
  • Both have same children
  • - *
  • If augmentations: Both have same augmentation target class. Target - * class was generated for data node in grouping.
  • - *
  • If cases: Both are from same choice. Choice class was generated for - * data node in grouping.
  • - *
- *

- * Explanation: Binding Specification reuses classes generated for - * groupings as part of normal data tree, this classes from grouping could - * be used at various locations and user may not be aware of it and may use - * incorrect case or augmentation in particular subtree (via copy - * constructors, etc). - * - * @param potential - * Class which is potential substition - * @param target - * Class which should be used at particular subtree - * @return true if and only if classes represents same data. - */ - @SuppressWarnings({ "rawtypes", "unchecked" }) - public static boolean isSubstitutionFor(final Class potential, final Class target) { - HashSet subImplemented = Sets.newHashSet(potential.getInterfaces()); - HashSet targetImplemented = Sets.newHashSet(target.getInterfaces()); - if (!subImplemented.equals(targetImplemented)) { - return false; - } - if (Augmentation.class.isAssignableFrom(potential) - && !BindingReflections.findAugmentationTarget(potential).equals( - BindingReflections.findAugmentationTarget(target))) { - return false; - } - for (Method potentialMethod : potential.getMethods()) { - try { - Method targetMethod = target.getMethod(potentialMethod.getName(), potentialMethod.getParameterTypes()); - if (!potentialMethod.getReturnType().equals(targetMethod.getReturnType())) { - return false; - } - } catch (NoSuchMethodException e) { - // Counterpart method is missing, so classes could not be - // substituted. - return false; - } catch (SecurityException e) { - throw new IllegalStateException("Could not compare methods", e); - } - } - return true; - } -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/ClassBasedRpcServiceInvoker.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/ClassBasedRpcServiceInvoker.java deleted file mode 100644 index 806386939d..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/ClassBasedRpcServiceInvoker.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding.util; - -import com.google.common.base.Preconditions; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; -import org.opendaylight.yangtools.yang.binding.BindingMapping; -import org.opendaylight.yangtools.yang.binding.RpcService; -import org.opendaylight.yangtools.yang.common.QName; - -final class ClassBasedRpcServiceInvoker extends AbstractMappedRpcInvoker { - private static final LoadingCache, RpcServiceInvoker> INVOKERS = CacheBuilder.newBuilder() - .weakKeys() - .build(new CacheLoader, RpcServiceInvoker>() { - @Override - public RpcServiceInvoker load(final Class key) { - final Map ret = new HashMap<>(); - for (Method m : key.getMethods()) { - ret.put(m.getName(), m); - } - - return new ClassBasedRpcServiceInvoker(ret); - } - }); - - ClassBasedRpcServiceInvoker(final Map ret) { - super(ret); - } - - @Override - protected String qnameToKey(final QName qname) { - return BindingMapping.getMethodName(qname); - } - - static RpcServiceInvoker instanceFor(final Class type) { - Preconditions.checkArgument(type.isInterface()); - Preconditions.checkArgument(BindingReflections.isBindingClass(type)); - return INVOKERS.getUnchecked(type); - } -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/ClassLoaderUtils.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/ClassLoaderUtils.java deleted file mode 100644 index cfb23c0feb..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/ClassLoaderUtils.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding.util; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.Joiner; -import com.google.common.base.Preconditions; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.Callable; -import java.util.concurrent.locks.Lock; -import java.util.function.Supplier; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @deprecated Use {@link org.opendaylight.yangtools.util.ClassLoaderUtils} instead. - */ -@Deprecated -public final class ClassLoaderUtils { - private static final Logger LOG = LoggerFactory.getLogger(ClassLoaderUtils.class); - - private ClassLoaderUtils() { - throw new UnsupportedOperationException("Utility class"); - } - - /** - * - * Runs {@link Supplier} with provided {@link ClassLoader}. - * - * Invokes supplies function and makes sure that original {@link ClassLoader} - * is context {@link ClassLoader} after execution. - * - * @param cls {@link ClassLoader} to be used. - * @param function Function to be executed. - * @return Result of supplier invocation. - * - */ - public static V withClassLoader(final ClassLoader cls, final Supplier function) { - checkNotNull(cls, "Classloader should not be null"); - checkNotNull(function, "Function should not be null"); - - final ClassLoader oldCls = Thread.currentThread().getContextClassLoader(); - try { - Thread.currentThread().setContextClassLoader(cls); - return function.get(); - } finally { - Thread.currentThread().setContextClassLoader(oldCls); - } - } - - /** - * - * Runs {@link Callable} with provided {@link ClassLoader}. - * - * Invokes supplies function and makes sure that original {@link ClassLoader} - * is context {@link ClassLoader} after execution. - * - * @param cls {@link ClassLoader} to be used. - * @param function Function to be executed. - * @return Result of callable invocation. - * - */ - public static V withClassLoader(final ClassLoader cls, final Callable function) throws Exception { - checkNotNull(cls, "Classloader should not be null"); - checkNotNull(function, "Function should not be null"); - - final ClassLoader oldCls = Thread.currentThread().getContextClassLoader(); - try { - Thread.currentThread().setContextClassLoader(cls); - return function.call(); - } finally { - Thread.currentThread().setContextClassLoader(oldCls); - } - } - - /** - * - * Runs {@link Callable} with provided {@link ClassLoader} and Lock. - * - * Invokes supplies function after acquiring lock - * and makes sure that original {@link ClassLoader} - * is context {@link ClassLoader} and lock is unlocked - * after execution. - * - * @param cls {@link ClassLoader} to be used. - * @param function Function to be executed. - * @return Result of Callable invocation. - * - */ - public static V withClassLoaderAndLock(final ClassLoader cls, final Lock lock, final Supplier function) { - checkNotNull(lock, "Lock should not be null"); - - lock.lock(); - try { - return withClassLoader(cls, function); - } finally { - lock.unlock(); - } - } - - public static Object construct(final Constructor constructor, final List objects) - throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { - final Object[] initargs = objects.toArray(); - return constructor.newInstance(initargs); - } - - /** - * - * Loads class using this supplied classloader. - * - * - * @param cls - * @param name String name of class. - * @return - * @throws ClassNotFoundException - */ - public static Class loadClass(final ClassLoader cls, final String name) throws ClassNotFoundException { - if ("byte[]".equals(name)) { - return byte[].class; - } - if ("char[]".equals(name)) { - return char[].class; - } - - try { - return cls.loadClass(name); - } catch (ClassNotFoundException e) { - String[] components = name.split("\\."); - String potentialOuter; - int length = components.length; - if (length > 2 && (potentialOuter = components[length - 2]) != null && Character.isUpperCase(potentialOuter.charAt(0))) { - String outerName = Joiner.on(".").join(Arrays.asList(components).subList(0, length - 1)); - String innerName = outerName + "$" + components[length-1]; - return cls.loadClass(innerName); - } else { - throw e; - } - } - } - - public static Class loadClassWithTCCL(final String name) throws ClassNotFoundException { - return loadClass(Thread.currentThread().getContextClassLoader(), name); - } - - public static Class tryToLoadClassWithTCCL(final String fullyQualifiedName) { - try { - return loadClassWithTCCL(fullyQualifiedName); - } catch (ClassNotFoundException e) { - LOG.debug("Failed to load class {}", fullyQualifiedName, e); - return null; - } - } - - public static Class

findFirstGenericArgument(final Class scannedClass, final Class genericType) { - return withClassLoader(scannedClass.getClassLoader(), ClassLoaderUtils.findFirstGenericArgumentTask(scannedClass, genericType)); - } - - private static Supplier> findFirstGenericArgumentTask(final Class scannedClass, final Class genericType) { - return new Supplier>() { - @Override - @SuppressWarnings("unchecked") - public Class

get() { - final ParameterizedType augmentationGeneric = findParameterizedType(scannedClass, genericType); - if (augmentationGeneric != null) { - return (Class

) augmentationGeneric.getActualTypeArguments()[0]; - } - return null; - } - }; - } - - public static ParameterizedType findParameterizedType(final Class subclass, final Class genericType) { - Preconditions.checkNotNull(subclass); - Preconditions.checkNotNull(genericType); - - for (Type type : subclass.getGenericInterfaces()) { - if (type instanceof ParameterizedType && genericType.equals(((ParameterizedType) type).getRawType())) { - return (ParameterizedType) type; - } - } - - LOG.debug("Class {} does not declare interface {}", subclass, genericType); - return null; - } - - public static Type getFirstGenericParameter(final Type type) { - if (type instanceof ParameterizedType) { - return ((ParameterizedType) type).getActualTypeArguments()[0]; - } - return null; - } -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/DataObjectReadingUtil.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/DataObjectReadingUtil.java deleted file mode 100644 index 48159a5e1e..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/DataObjectReadingUtil.java +++ /dev/null @@ -1,349 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding.util; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkState; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Optional; -import org.opendaylight.yangtools.yang.binding.Augmentable; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.binding.InterfaceTyped; -import org.opendaylight.yangtools.yang.binding.TreeNode; -import org.opendaylight.yangtools.yang.binding.IdentifiableListItem; -import org.opendaylight.yangtools.yang.binding.Identifier; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.IdentifiableItem; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.Item; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument; - -public class DataObjectReadingUtil { - - private DataObjectReadingUtil() { - throw new UnsupportedOperationException("Utility class. Instantion is not allowed."); - } - - /** - * - * @param parent - * Parent object on which read operation will be performed - * @param parentPath - * Path, to parent object. - * @param childPath - * Path, which is nested to parent, and should be readed. - * @return Value of object. - */ - public static final Map, T> readData(final P parent, - final InstanceIdentifier

parentPath, final InstanceIdentifier childPath) { - checkArgument(parent != null, "Parent must not be null."); - checkArgument(parentPath != null, "Parent path must not be null"); - checkArgument(childPath != null, "Child path must not be null"); - checkArgument(parentPath.containsWildcarded(childPath), "Parent object must be parent of child."); - - List pathArgs = subList(parentPath.getPathArguments(), childPath.getPathArguments()); - @SuppressWarnings("rawtypes") - Map lastFound = Collections - . singletonMap(parentPath, parent); - for (PathArgument pathArgument : pathArgs) { - @SuppressWarnings("rawtypes") - final ImmutableMap.Builder potentialBuilder = ImmutableMap.builder(); - for (@SuppressWarnings("rawtypes") - Entry entry : lastFound.entrySet()) { - potentialBuilder.putAll(readData(entry, pathArgument)); - } - lastFound = potentialBuilder.build(); - if (lastFound.isEmpty()) { - return Collections.emptyMap(); - } - } - @SuppressWarnings({ "unchecked", "rawtypes" }) - final Map, T> result = (Map) lastFound; - return result; - } - - @SuppressWarnings("rawtypes") - private static Map readData(final Entry entry, - final PathArgument pathArgument) { - return readData(entry.getValue(), entry.getKey(), pathArgument); - } - - public static final Optional readData(final TreeNode source, final Class child) { - checkArgument(source != null, "Object should not be null."); - checkArgument(child != null, "Child type should not be null"); - Class parentClass = source.implementedInterface(); - - @SuppressWarnings("unchecked") - T potential = (T) resolveReadStrategy(parentClass, child).read(source, child); - return Optional.ofNullable(potential); - } - - @SuppressWarnings("rawtypes") - private static final Map readData(final InterfaceTyped parent, - final InstanceIdentifier parentPath, final PathArgument child) { - checkArgument(parent != null, "Object should not be null."); - checkArgument(child != null, "Child argument should not be null"); - Class parentClass = parent.implementedInterface(); - return resolveReadStrategy(parentClass, child.getType()).readUsingPathArgument(parent, child, parentPath); - } - - private static DataObjectReadingStrategy resolveReadStrategy(final Class parentClass, - final Class type) { - - DataObjectReadingStrategy strategy = createReadStrategy(parentClass, type); - // FIXME: Add caching of strategies - return strategy; - } - - private static DataObjectReadingStrategy createReadStrategy(final Class parent, - final Class child) { - - if (Augmentable.class.isAssignableFrom(parent) && Augmentation.class.isAssignableFrom(child)) { - return REAUSABLE_AUGMENTATION_READING_STRATEGY; - } - - /* - * FIXME Ensure that this strategies also works for children of cases. - * Possible edge-case is : Parent container uses grouping foo case is - * added by augmentation also uses foo. - */ - if (IdentifiableListItem.class.isAssignableFrom(child)) { - @SuppressWarnings("unchecked") - final Class> identifiableClass = (Class>) child; - return new ListItemReadingStrategy(parent, identifiableClass); - } - return new ContainerReadingStrategy(parent, child); - } - - private static Method resolveGetterMethod(final Class parent, final Class child) { - String methodName = "get" + child.getSimpleName(); - try { - return parent.getMethod(methodName); - } catch (NoSuchMethodException e) { - throw new IllegalArgumentException(e); - } catch (SecurityException e) { - throw new IllegalStateException(e); - } - } - - @SuppressWarnings("rawtypes") - private static abstract class DataObjectReadingStrategy { - - private final Class parentType; - private final Class childType; - private final Method getterMethod; - - @SuppressWarnings("unchecked") - public DataObjectReadingStrategy(final Class parentType, final Class childType) { - checkArgument(InterfaceTyped.class.isAssignableFrom(parentType)); - checkArgument(InterfaceTyped.class.isAssignableFrom(childType)); - this.parentType = parentType; - this.childType = childType; - this.getterMethod = resolveGetterMethod(parentType, childType); - } - - @SuppressWarnings("unchecked") - public DataObjectReadingStrategy(final Class parentType, final Class childType, final Method getter) { - this.parentType = parentType; - this.childType = childType; - this.getterMethod = getter; - } - - @SuppressWarnings("unused") - protected Class getParentType() { - return parentType; - } - - protected Class getChildType() { - return childType; - } - - protected Method getGetterMethod() { - return getterMethod; - } - - public abstract Map readUsingPathArgument(InterfaceTyped parent, - PathArgument childArgument, InstanceIdentifier targetBuilder); - - public abstract InterfaceTyped read(InterfaceTyped parent, Class childType); - - } - - @SuppressWarnings("rawtypes") - private static class ContainerReadingStrategy extends DataObjectReadingStrategy { - - public ContainerReadingStrategy(final Class parent, final Class child) { - super(parent, child); - checkArgument(child.isAssignableFrom(getGetterMethod().getReturnType())); - } - - @Override - public Map readUsingPathArgument(final InterfaceTyped parent, - final PathArgument childArgument, final InstanceIdentifier parentPath) { - final InterfaceTyped result = read(parent, childArgument.getType()); - if (result != null) { - @SuppressWarnings("unchecked") - InstanceIdentifier childPath = parentPath.child(childArgument.getType()); - return Collections.singletonMap(childPath, result); - } - return Collections.emptyMap(); - } - - @Override - public InterfaceTyped read(final InterfaceTyped parent, final Class childType) { - try { - Object potentialData = getGetterMethod().invoke(parent); - checkState(potentialData instanceof InterfaceTyped); - return (InterfaceTyped) potentialData; - - } catch (IllegalAccessException | InvocationTargetException e) { - throw new IllegalArgumentException(e); - } - } - } - - @SuppressWarnings("rawtypes") - private static class ListItemReadingStrategy extends DataObjectReadingStrategy { - - public ListItemReadingStrategy(final Class parent, final Class child) { - super(parent, child); - checkArgument(Iterable.class.isAssignableFrom(getGetterMethod().getReturnType())); - } - - @Override - public InterfaceTyped read(final InterfaceTyped parent, final Class childType) { - // This will always fail since we do not have key. - return null; - } - - @SuppressWarnings("unchecked") - @Override - public Map readUsingPathArgument(final InterfaceTyped parent, - final PathArgument childArgument, final InstanceIdentifier builder) { - try { - Object potentialList = getGetterMethod().invoke(parent); - if (potentialList instanceof Iterable) { - - final Iterable dataList = (Iterable) potentialList; - if (childArgument instanceof IdentifiableItem) { - return readUsingIdentifiableItem(dataList, (IdentifiableItem) childArgument, builder); - } else { - return readAll(dataList, builder); - } - } - } catch (InvocationTargetException e) { - throw new IllegalStateException(e); - } catch (IllegalAccessException e) { - throw new IllegalStateException(e); - } catch (IllegalArgumentException e) { - throw new IllegalStateException(e); - } - return Collections.emptyMap(); - } - - private Map readAll(final Iterable dataList, - final InstanceIdentifier parentPath) { - Builder result = ImmutableMap - . builder(); - for (IdentifiableListItem item : dataList) { - @SuppressWarnings("unchecked") - InstanceIdentifier childPath = parentPath.child(getChildType(), item.identifier()); - result.put(childPath, (InterfaceTyped) item); - } - return result.build(); - } - - @SuppressWarnings("unchecked") - private static Map readUsingIdentifiableItem(final Iterable dataList, - final IdentifiableItem childArgument, final InstanceIdentifier parentPath) { - final Identifier key = childArgument.getKey(); - for (IdentifiableListItem item : dataList) { - if (key.equals(item.identifier()) && item instanceof InterfaceTyped) { - checkState(childArgument.getType().isInstance(item), - "Found child is not instance of requested type"); - InstanceIdentifier childPath = parentPath - .child(childArgument.getType(), item.identifier()); - return Collections.singletonMap(childPath, (InterfaceTyped) item); - } - } - return Collections.emptyMap(); - } - - } - - private static final DataObjectReadingStrategy REAUSABLE_AUGMENTATION_READING_STRATEGY = new AugmentationReadingStrategy(); - - private static final class AugmentationReadingStrategy extends DataObjectReadingStrategy { - - public AugmentationReadingStrategy() { - super(Augmentable.class, Augmentation.class, null); - } - - @SuppressWarnings("rawtypes") - @Override - public Map readUsingPathArgument(final InterfaceTyped parent, - final PathArgument childArgument, final InstanceIdentifier builder) { - checkArgument(childArgument instanceof Item, "Path Argument must be Item without keys"); - InterfaceTyped aug = read(parent, childArgument.getType()); - if (aug != null) { - @SuppressWarnings("unchecked") - final InstanceIdentifier childPath = builder.child(childArgument.getType()); - return Collections.singletonMap(childPath, aug); - } else { - return Collections.emptyMap(); - } - } - - @Override - public InterfaceTyped read(final InterfaceTyped parent, final Class childType) { - checkArgument(Augmentation.class.isAssignableFrom(childType), "Parent must be Augmentable."); - checkArgument(parent instanceof Augmentable, "Parent must be Augmentable."); - - @SuppressWarnings({ "rawtypes", "unchecked" }) - Augmentation potential = ((Augmentable) parent).getAugmentation(childType); - checkState(potential instanceof InterfaceTyped, "Readed augmention must be data object"); - return (InterfaceTyped) potential; - } - } - - /** - * Create sublist view of child from element on [size-of-parent] position to - * last element. - * - * @param parent - * @param child - * @return sublist view of child argument - * @throws IllegalArgumentException - * if parent argument is bigger than child - */ - private static List subList(final Iterable

parent, final Iterable child) { - Iterator

iParent = parent.iterator(); - List result = new ArrayList<>(); - for (C arg : child) { - if (iParent.hasNext()) { - iParent.next(); - } else { - result.add(arg); - } - } - if (iParent.hasNext()) { - throw new IllegalArgumentException("Parent argument is bigger than child."); - } - return result; - } - -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/LocalNameRpcServiceInvoker.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/LocalNameRpcServiceInvoker.java deleted file mode 100644 index f55f3452b8..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/LocalNameRpcServiceInvoker.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding.util; - -import com.google.common.base.Preconditions; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.QNameModule; - -final class LocalNameRpcServiceInvoker extends AbstractMappedRpcInvoker { - private final QNameModule module; - - private LocalNameRpcServiceInvoker(final QNameModule module, final Map map) { - super(map); - this.module = Preconditions.checkNotNull(module); - } - - static RpcServiceInvoker instanceFor(final QNameModule module, final Map qnameToMethod) { - final Map map = new HashMap<>(); - for (Entry e : qnameToMethod.entrySet()) { - map.put(e.getKey().getLocalName(), e.getValue()); - } - - return new LocalNameRpcServiceInvoker(module, map); - } - - @Override - protected String qnameToKey(final QName qname) { - if (module.equals(qname.getModule())) { - return qname.getLocalName(); - } else { - return null; - } - } -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/NotificationListenerInvoker.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/NotificationListenerInvoker.java deleted file mode 100644 index 38f3038c07..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/NotificationListenerInvoker.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding.util; - -import com.google.common.base.Preconditions; -import com.google.common.base.Throwables; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodHandles.Lookup; -import java.lang.invoke.MethodType; -import java.lang.reflect.Method; -import java.util.Map; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import org.opendaylight.yangtools.yang.binding.InterfaceTyped; -import org.opendaylight.yangtools.yang.binding.NotificationListener; -import org.opendaylight.yangtools.yang.common.QName; - -/** - * Provides single method invocation of notificatoin callbacks on supplied instance. - * - * Notification Listener invoker provides common invocation interface for any subtype of {@link NotificationListener}. - * via {@link #invokeNotification(NotificationListener, QName, InterfaceTyped)} method. - * - */ -public final class NotificationListenerInvoker { - - private static final Lookup LOOKUP = MethodHandles.publicLookup(); - - private static final LoadingCache, NotificationListenerInvoker> INVOKERS = CacheBuilder - .newBuilder().weakKeys() - .build(new CacheLoader, NotificationListenerInvoker>() { - - @Override - public NotificationListenerInvoker load(final Class key) throws Exception { - return createInvoker(key); - } - - }); - - private final Map methodInvokers; - - public NotificationListenerInvoker(final Map map) { - this.methodInvokers = map; - } - - /** - * - * Creates RPCServiceInvoker for specified RpcService type - * - * @param type - * RpcService interface, which was generated from model. - * @return Cached instance of {@link NotificationListenerInvoker} for - * supplied RPC type. - * - */ - public static NotificationListenerInvoker from(final Class type) { - Preconditions.checkArgument(type.isInterface()); - Preconditions.checkArgument(BindingReflections.isBindingClass(type)); - return INVOKERS.getUnchecked(type); - } - - /** - * Invokes supplied RPC on provided implementation of RPC Service. - * - * @param impl - * Imlementation on which notifiaction callback should be - * invoked. - * @param rpcName - * Name of RPC to be invoked. - * @param input - * Input data for RPC. - * - */ - public void invokeNotification(@Nonnull final NotificationListener impl, @Nonnull final QName rpcName, - @Nullable final InterfaceTyped input) { - Preconditions.checkNotNull(impl, "implemetation must be supplied"); - final MethodHandle invoker = methodInvokers.get(rpcName); - Preconditions.checkArgument(invoker != null, "Supplied notification is not valid for implementation %s", impl); - try { - invoker.invokeExact(impl, input); - } catch (final Throwable e) { - throw Throwables.propagate(e); - } - } - - private static NotificationListenerInvoker createInvoker(final Class key) { - return new NotificationListenerInvoker(createInvokerMap(key)); - } - - private static Map createInvokerMap(final Class key) { - final Builder ret = ImmutableMap.builder(); - for (final Method method : key.getMethods()) { - if (BindingReflections.isNotificationCallback(method)) { - - final Class notification = method.getParameterTypes()[0]; - final QName name = BindingReflections.findQName(notification); - MethodHandle handle; - try { - handle = LOOKUP.unreflect(method).asType( - MethodType.methodType(void.class, NotificationListener.class, InterfaceTyped.class)); - ret.put(name, handle); - } catch (final IllegalAccessException e) { - throw new IllegalStateException("Can not access public method.", e); - } - } - - } - return ret.build(); - } - -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/QNameRpcServiceInvoker.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/QNameRpcServiceInvoker.java deleted file mode 100644 index 953e25de6c..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/QNameRpcServiceInvoker.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding.util; - -import java.lang.reflect.Method; -import java.util.Map; -import org.opendaylight.yangtools.yang.common.QName; - -final class QNameRpcServiceInvoker extends AbstractMappedRpcInvoker { - private QNameRpcServiceInvoker(final Map qnameToMethod) { - super(qnameToMethod); - } - - static RpcServiceInvoker instanceFor(final Map qnameToMethod) { - return new QNameRpcServiceInvoker(qnameToMethod); - } - - @Override - protected QName qnameToKey(final QName qname) { - return qname; - } -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/RpcMethodInvoker.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/RpcMethodInvoker.java deleted file mode 100644 index 6a25542b00..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/RpcMethodInvoker.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding.util; - -import static com.sun.xml.internal.ws.policy.sourcemodel.wspolicy.XmlToken.Optional; - -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodHandles.Lookup; -import java.lang.reflect.Method; -import java.util.Optional; -import java.util.concurrent.Future; -import org.opendaylight.yangtools.yang.binding.InterfaceTyped; -import org.opendaylight.yangtools.yang.binding.TreeNode; -import org.opendaylight.yangtools.yang.binding.RpcService; -import org.opendaylight.yangtools.yang.common.RpcResult; - -abstract class RpcMethodInvoker { - - private static final Lookup LOOKUP = MethodHandles.publicLookup(); - - protected abstract Future> invokeOn(RpcService impl, TreeNode input); - - protected static RpcMethodInvoker from(final Method method) { - Optional> input = BindingReflections.resolveRpcInputClass(method); - try { - MethodHandle methodHandle = LOOKUP.unreflect(method); - if (input.isPresent()) { - return new RpcMethodInvokerWithInput(methodHandle); - } - return new RpcMethodInvokerWithoutInput(methodHandle); - } catch (IllegalAccessException e) { - throw new IllegalStateException("Lookup on public method failed.",e); - } - - } -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/RpcMethodInvokerWithInput.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/RpcMethodInvokerWithInput.java deleted file mode 100644 index e2a6621a63..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/RpcMethodInvokerWithInput.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding.util; - -import com.google.common.base.Throwables; -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodType; -import java.util.concurrent.Future; -import org.opendaylight.yangtools.yang.binding.TreeNode; -import org.opendaylight.yangtools.yang.binding.RpcService; -import org.opendaylight.yangtools.yang.common.RpcResult; - -class RpcMethodInvokerWithInput extends RpcMethodInvoker { - - private static final MethodType INVOCATION_SIGNATURE = MethodType.methodType(Future.class, RpcService.class,TreeNode.class); - private final MethodHandle handle; - - RpcMethodInvokerWithInput(MethodHandle methodHandle) { - this.handle = methodHandle.asType(INVOCATION_SIGNATURE); - } - - @Override - public Future> invokeOn(RpcService impl, TreeNode input) { - try { - return (Future>) handle.invokeExact(impl,input); - } catch (Throwable e) { - throw Throwables.propagate(e); - } - } - -} \ No newline at end of file diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/RpcMethodInvokerWithoutInput.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/RpcMethodInvokerWithoutInput.java deleted file mode 100644 index a615eed7b6..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/RpcMethodInvokerWithoutInput.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding.util; - -import com.google.common.base.Throwables; -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodType; -import java.util.concurrent.Future; -import org.opendaylight.yangtools.yang.binding.TreeNode; -import org.opendaylight.yangtools.yang.binding.RpcService; -import org.opendaylight.yangtools.yang.common.RpcResult; - -class RpcMethodInvokerWithoutInput extends RpcMethodInvoker { - - private static final MethodType INVOCATION_SIGNATURE = MethodType.methodType(Future.class, RpcService.class); - private final MethodHandle handle; - - RpcMethodInvokerWithoutInput(MethodHandle methodHandle) { - this.handle = methodHandle.asType(INVOCATION_SIGNATURE); - } - - @Override - public Future> invokeOn(RpcService impl, TreeNode input) { - try { - return (Future>) handle.invokeExact(impl); - } catch (Throwable e) { - throw Throwables.propagate(e); - } - } - -} \ No newline at end of file diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/RpcServiceInvoker.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/RpcServiceInvoker.java deleted file mode 100644 index aaf1914b59..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/RpcServiceInvoker.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding.util; - -import com.google.common.base.Preconditions; -import java.lang.reflect.Method; -import java.util.Map; -import java.util.concurrent.Future; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import org.opendaylight.yangtools.yang.binding.TreeNode; -import org.opendaylight.yangtools.yang.binding.RpcService; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.QNameModule; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Provides single method invocation of RPCs on supplied instance. - * - * Rpc Service invoker provides common invocation interface for any subtype of {@link RpcService}. - * via {@link #invokeRpc(RpcService, QName, TreeNode)} method. - */ -public abstract class RpcServiceInvoker { - private static final Logger LOG = LoggerFactory.getLogger(RpcServiceInvoker.class); - - /** - * Creates RPCServiceInvoker for specified RpcService type - * - * @param type RpcService interface, which was generated from model. - * @return Cached instance of {@link RpcServiceInvoker} for supplied RPC type. - * - */ - public static RpcServiceInvoker from(final Class type) { - return ClassBasedRpcServiceInvoker.instanceFor(type); - } - - /** - * Creates an RPCServiceInvoker for specified QName-<Method mapping. - * - * @param qnameToMethod translation mapping, must not be null nor empty. - * @return An {@link RpcMethodInvoker} instance. - */ - public static RpcServiceInvoker from(final Map qnameToMethod) { - Preconditions.checkArgument(!qnameToMethod.isEmpty()); - QNameModule module = null; - - for (QName qname : qnameToMethod.keySet()) { - if (module != null) { - if (!module.equals(qname.getModule())) { - LOG.debug("QNames from different modules {} and {}, falling back to QName map", module, qname.getModule()); - return QNameRpcServiceInvoker.instanceFor(qnameToMethod); - } - } else { - module = qname.getModule(); - } - } - - // All module are equal, which means we can use localName only - return LocalNameRpcServiceInvoker.instanceFor(module, qnameToMethod); - } - - /** - * Invokes supplied RPC on provided implementation of RPC Service. - * - * @param impl Imlementation on which RPC should be invoked. - * @param rpcName Name of RPC to be invoked. - * @param input Input data for RPC. - * @return Future which will complete once rpc procesing is finished. - */ - public abstract Future> invokeRpc(@Nonnull final RpcService impl, @Nonnull final QName rpcName, @Nullable final TreeNode input); -} diff --git a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/StringValueObjectFactory.java b/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/StringValueObjectFactory.java deleted file mode 100644 index 0955681442..0000000000 --- a/binding2/prototype/yang-binding2/src/main/java/org/opendaylight/yangtools/yang/binding/util/StringValueObjectFactory.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding.util; - -import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; -import com.google.common.base.Throwables; -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodHandles.Lookup; -import java.lang.invoke.MethodType; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Utility class for instantiating value-type generated objects with String being the base type. Unlike the normal - * constructor, instances of this class bypass string validation. - * - * THE USE OF THIS CLASS IS DANGEROUS AND SHOULD ONLY BE USED TO IMPLEMENT WELL-AUDITED AND CORRECT UTILITY METHODS - * SHIPPED WITH MODELS TO PROVIDE INSTANTIATION FROM TYPES DIFFERENT THAN STRING. - * - * APPLICATION CODE MUST NOT USE THIS CLASS DIRECTLY. VIOLATING THIS CONSTRAINT HAS SECURITY AND CORRECTNESS - * IMPLICATIONS ON EVERY USER INTERACTING WITH THE RESULTING OBJECTS. - * - * @param Resulting object type - */ -@Beta -public final class StringValueObjectFactory { - private static final MethodType CONSTRUCTOR_METHOD_TYPE = MethodType.methodType(Object.class, Object.class); - private static final MethodType SETTER_METHOD_TYPE = MethodType.methodType(void.class, Object.class, String.class); - private static final Logger LOG = LoggerFactory.getLogger(StringValueObjectFactory.class); - private static final Lookup LOOKUP = MethodHandles.lookup(); - - private final MethodHandle constructor; - private final MethodHandle setter; - private final T template; - - private StringValueObjectFactory(final T template, final MethodHandle constructor, final MethodHandle setter) { - this.template = Preconditions.checkNotNull(template); - this.constructor = constructor.bindTo(template); - this.setter = Preconditions.checkNotNull(setter); - } - - public static StringValueObjectFactory create(final Class clazz, final String templateString) { - final Constructor stringConstructor; - try { - stringConstructor = clazz.getConstructor(String.class); - } catch (NoSuchMethodException e) { - throw new IllegalArgumentException(String.format("%s does not have a String constructor", clazz), e); - } - - final T template; - try { - template = stringConstructor.newInstance(templateString); - } catch (InstantiationException | InvocationTargetException | IllegalAccessException e) { - throw new IllegalArgumentException(String.format("Failed to instantiate template %s for '%s'", clazz, - templateString), e); - } - - final Constructor copyConstructor; - try { - copyConstructor = clazz.getConstructor(clazz); - } catch (NoSuchMethodException e) { - throw new IllegalArgumentException(String.format("%s does not have a copy constructor", clazz), e); - } - - final Field f; - try { - f = clazz.getDeclaredField("_value"); - } catch (NoSuchFieldException e) { - throw new IllegalArgumentException(String.format("%s does not have required internal field", clazz), e); - } - f.setAccessible(true); - - final StringValueObjectFactory ret; - try { - ret = new StringValueObjectFactory<>(template, - LOOKUP.unreflectConstructor(copyConstructor).asType(CONSTRUCTOR_METHOD_TYPE), - LOOKUP.unreflectSetter(f).asType(SETTER_METHOD_TYPE)); - } catch (IllegalAccessException e) { - throw new IllegalStateException("Failed to instantiate method handles", e); - } - - // Let us be very defensive and scream loudly if the invocation does not come from the same package. This - // is far from perfect, but better than nothing. - final Throwable t = new Throwable("Invocation stack"); - t.fillInStackTrace(); - if (matchesPackage(clazz.getPackage().getName(), t.getStackTrace())) { - LOG.info("Instantiated factory for {}", clazz); - } else { - LOG.warn("Instantiated factory for {} outside its package", clazz, t); - } - - return ret; - } - - private static boolean matchesPackage(final String pkg, final StackTraceElement[] stackTrace) { - for (StackTraceElement e : stackTrace) { - final String sp = e.getClassName(); - if (sp.startsWith(pkg) && sp.lastIndexOf('.') == pkg.length()) { - return true; - } - } - - return false; - } - - public T newInstance(final String string) { - Preconditions.checkNotNull(string, "Argument may not be null"); - - try { - final T ret = (T) constructor.invokeExact(); - setter.invokeExact(ret, string); - LOG.trace("Instantiated new object {} value {}", ret.getClass(), string); - return ret; - } catch (Throwable e) { - throw Throwables.propagate(e); - } - } - - public T getTemplate() { - return template; - } -} diff --git a/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifierTest.java b/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifierTest.java deleted file mode 100644 index 13730188d4..0000000000 --- a/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifierTest.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import org.junit.Test; -import org.opendaylight.yangtools.yang.binding.test.mock.FooChild; -import org.opendaylight.yangtools.yang.binding.test.mock.InstantiatedFoo; -import org.opendaylight.yangtools.yang.binding.test.mock.Node; -import org.opendaylight.yangtools.yang.binding.test.mock.NodeChild; -import org.opendaylight.yangtools.yang.binding.test.mock.NodeChildKey; -import org.opendaylight.yangtools.yang.binding.test.mock.NodeKey; -import org.opendaylight.yangtools.yang.binding.test.mock.Nodes; - -public class InstanceIdentifierTest { - - @Test - public void constructWithPredicates() { - - InstanceIdentifier nodes = InstanceIdentifier.builder(Nodes.class).build(); - - assertNotNull(nodes); - assertEquals(Nodes.class, nodes.getTargetType()); - - - InstanceIdentifier node = nodes.builder().child(Node.class).build(); - - assertNotNull(node); - assertEquals(Node.class, node.getTargetType()); - - assertTrue(nodes.contains(node)); - } - - @Test - public void fluentConstruction() { - - InstanceIdentifier nodes = InstanceIdentifier.builder(Nodes.class).build(); - InstanceIdentifier node = InstanceIdentifier.builder(Nodes.class).child(Node.class,new NodeKey(10)).build(); - - assertNotNull(node); - assertEquals(Node.class, node.getTargetType()); - - assertTrue(nodes.contains(node)); - } - - - @Test - public void negativeContains() { - InstanceIdentifier fooChild = InstanceIdentifier.builder(Nodes.class).child(InstantiatedFoo.class).child(FooChild.class).build(); - - InstanceIdentifier nodeTen = InstanceIdentifier.builder(Nodes.class) // - .child(Node.class,new NodeKey(10)).build(); - InstanceIdentifier nodeOne = InstanceIdentifier.builder(Nodes.class) // - .child(Node.class,new NodeKey(1)).build(); - InstanceIdentifier nodes = InstanceIdentifier.builder(Nodes.class).build(); - - assertFalse(fooChild.contains(nodeTen)); - assertFalse(nodeTen.contains(nodes)); - - assertFalse(nodeOne.contains(nodes)); - assertTrue(nodes.contains(nodeOne)); - - assertTrue(nodes.containsWildcarded(nodeOne)); - assertFalse(nodeOne.containsWildcarded(nodes)); - } - - @Test - public void containsWildcarded() { - InstanceIdentifier nodes = InstanceIdentifier.builder(Nodes.class).build(); - InstanceIdentifier wildcarded = InstanceIdentifier.builder(Nodes.class).child(Node.class).build(); - InstanceIdentifier wildcardedChildren = InstanceIdentifier.builder(Nodes.class) // - .child(Node.class) // - .child(NodeChild.class).build(); - - assertTrue(wildcarded.isWildcarded()); - assertTrue(wildcardedChildren.isWildcarded()); - - - InstanceIdentifier nodeTen = InstanceIdentifier.builder(Nodes.class) // - .child(Node.class,new NodeKey(10)).build(); - InstanceIdentifier nodeOne = InstanceIdentifier.builder(Nodes.class) // - .child(Node.class,new NodeKey(1)).build(); - - assertFalse(nodeTen.isWildcarded()); - assertFalse(nodeOne.isWildcarded()); - assertTrue(nodes.containsWildcarded(nodeOne)); - assertTrue(wildcarded.containsWildcarded(nodeOne)); - assertTrue(wildcarded.containsWildcarded(nodeTen)); - - - InstanceIdentifier nodeTenChildWildcarded = InstanceIdentifier.builder(Nodes.class) // - .child(Node.class,new NodeKey(10)).child(NodeChild.class).build(); - - assertTrue(nodeTenChildWildcarded.isWildcarded()); - - InstanceIdentifier nodeTenChild = InstanceIdentifier.builder(Nodes.class) // - .child(Node.class,new NodeKey(10)).child(NodeChild.class, new NodeChildKey(10)).build(); - InstanceIdentifier nodeOneChild = InstanceIdentifier.builder(Nodes.class) // - .child(Node.class,new NodeKey(1)).child(NodeChild.class, new NodeChildKey(1)).build(); - - - assertFalse(nodeTenChildWildcarded.containsWildcarded(nodeOneChild)); - assertTrue(nodeTenChildWildcarded.containsWildcarded(nodeTenChild)); - - } - - void childOfTest() { - InstanceIdentifier.builder(Nodes.class).child(InstantiatedFoo.class).child(FooChild.class); - } - - @Test - public void basicTests() { - InstanceIdentifier instanceIdentifier1 = InstanceIdentifier.create(TreeNode.class); - InstanceIdentifier instanceIdentifier2 = InstanceIdentifier.create(TreeNode.class); - Object object = new Object(); - - assertTrue(instanceIdentifier1.equals(instanceIdentifier1)); - assertFalse(instanceIdentifier1.equals(null)); - assertFalse(instanceIdentifier1.equals(object)); - assertTrue(instanceIdentifier1.equals(instanceIdentifier2)); - - assertNotNull(instanceIdentifier1.hashCode()); - - assertNotNull(instanceIdentifier1.toString()); - } - - @Test - public void firstIdentifierOfTest() { - InstanceIdentifier instanceIdentifier = InstanceIdentifier.builder(Nodes.class).child(Node.class,new NodeKey(10)).build(); - - InstanceIdentifier nodesIdentifier = instanceIdentifier.firstIdentifierOf(Nodes.class); - assertNotNull(nodesIdentifier); - InstanceIdentifier dataObjectIdentifier = instanceIdentifier.firstIdentifierOf(TreeNode.class); - assertNull(dataObjectIdentifier); - } -} diff --git a/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/FooChild.java b/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/FooChild.java deleted file mode 100644 index 1d71b3ebb0..0000000000 --- a/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/FooChild.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding.test.mock; - -import org.opendaylight.yangtools.yang.binding.ChildTreeNode; - -public interface FooChild extends ChildTreeNode { - -} diff --git a/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/GroupingFoo.java b/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/GroupingFoo.java deleted file mode 100644 index ff852854e7..0000000000 --- a/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/GroupingFoo.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding.test.mock; - -public interface GroupingFoo { - -} diff --git a/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/InstantiatedFoo.java b/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/InstantiatedFoo.java deleted file mode 100644 index f98bd2736e..0000000000 --- a/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/InstantiatedFoo.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding.test.mock; - -import org.opendaylight.yangtools.yang.binding.ChildTreeNode; -import org.opendaylight.yangtools.yang.binding.TreeNode; - -public interface InstantiatedFoo extends TreeNode, GroupingFoo, ChildTreeNode { - -} diff --git a/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/Node.java b/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/Node.java deleted file mode 100644 index 77efb70761..0000000000 --- a/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/Node.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding.test.mock; - -import org.opendaylight.yangtools.yang.binding.ChildTreeNode; -import org.opendaylight.yangtools.yang.binding.TreeNode; -import org.opendaylight.yangtools.yang.binding.IdentifiableListItem; - -public interface Node extends // - TreeNode, // - IdentifiableListItem, // - ChildTreeNode { - -} diff --git a/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/NodeChild.java b/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/NodeChild.java deleted file mode 100644 index ff79703c2a..0000000000 --- a/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/NodeChild.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding.test.mock; - -import org.opendaylight.yangtools.yang.binding.ChildTreeNode; -import org.opendaylight.yangtools.yang.binding.TreeNode; -import org.opendaylight.yangtools.yang.binding.IdentifiableListItem; - -public interface NodeChild extends // - TreeNode, // - IdentifiableListItem, // - ChildTreeNode { - -} diff --git a/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/NodeChildKey.java b/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/NodeChildKey.java deleted file mode 100644 index 53d3a96401..0000000000 --- a/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/NodeChildKey.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding.test.mock; - -import org.opendaylight.yangtools.yang.binding.Identifier; - -public class NodeChildKey implements // - Identifier { - private static final long serialVersionUID = 1L; - private final int id; - - public NodeChildKey(int id) { - this.id = id; - } - - public int getId() { - return id; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + id; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - NodeChildKey other = (NodeChildKey) obj; - if (id != other.id) - return false; - return true; - } -} diff --git a/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/NodeKey.java b/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/NodeKey.java deleted file mode 100644 index 1914d5d62b..0000000000 --- a/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/NodeKey.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding.test.mock; - -import org.opendaylight.yangtools.yang.binding.Identifier; - -public class NodeKey implements // - Identifier { - private static final long serialVersionUID = 1L; - private final int id; - - public NodeKey(int id) { - this.id = id; - } - - public int getId() { - return id; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + id; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - NodeKey other = (NodeKey) obj; - if (id != other.id) - return false; - return true; - } -} diff --git a/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/Nodes.java b/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/Nodes.java deleted file mode 100644 index 73e9b5d3b4..0000000000 --- a/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/test/mock/Nodes.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding.test.mock; - -import org.opendaylight.yangtools.yang.binding.ChildTreeNode; -import org.opendaylight.yangtools.yang.binding.TreeNode; -import org.opendaylight.yangtools.yang.binding.TreeRoot; - -public interface Nodes extends // - ChildTreeNode, // - TreeNode { - -} diff --git a/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/util/BindingReflectionsTest.java b/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/util/BindingReflectionsTest.java deleted file mode 100644 index b2245e8438..0000000000 --- a/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/util/BindingReflectionsTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding.util; - -import org.junit.Test; -import org.opendaylight.yangtools.yang.binding.TreeNode; - -import java.util.Collections; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -public class BindingReflectionsTest { - - @Test - public void testBindingWithDummyObject() { - assertEquals("Package name should be equal to string", "org.opendaylight.yang.gen.v1.test.rev990939", - BindingReflections.getModelRootPackageName("org.opendaylight.yang.gen.v1.test.rev990939")); - assertEquals("ModuleInfoClassName should be equal to string", "test.$YangModuleInfoImpl", - BindingReflections.getModuleInfoClassName("test")); - assertEquals("Module info should be empty Set", Collections.EMPTY_SET, - BindingReflections.loadModuleInfos()); - assertFalse("Should not be RpcType", BindingReflections.isRpcType(TreeNode.class)); - assertFalse("Should not be AugmentationChild", BindingReflections.isAugmentationChild(TreeNode.class)); - assertTrue("Should be BindingClass", BindingReflections.isBindingClass(TreeNode.class)); - assertFalse("Should not be Notification", BindingReflections.isNotification(TreeNode.class)); - } -} \ No newline at end of file diff --git a/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/util/DataObjectReadingUtilTest.java b/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/util/DataObjectReadingUtilTest.java deleted file mode 100644 index f9edd00333..0000000000 --- a/binding2/prototype/yang-binding2/src/test/java/org/opendaylight/yangtools/yang/binding/util/DataObjectReadingUtilTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding.util; - -import static com.sun.xml.internal.ws.dump.LoggingDumpTube.Position.Before; -import static org.junit.Assert.assertTrue; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.UnmodifiableIterator; -import java.util.Map; -import java.util.Map.Entry; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.yangtools.yang.binding.TreeNode; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.test.mock.Nodes; - -public class DataObjectReadingUtilTest { - @Mock private InstanceIdentifier pathNull; - @Mock private Map.Entry, TreeNode> entryNull; - @Mock private TreeNode mockedTreeNode; - private InstanceIdentifier path; - private Map.Entry, TreeNode> entry; - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - - path = InstanceIdentifier.builder(Nodes.class).build(); - ImmutableMap, TreeNode> map = - ImmutableMap., TreeNode>builder() - .put(path, mockedTreeNode).build(); - - ImmutableSet, TreeNode>> entries = map.entrySet(); - UnmodifiableIterator, TreeNode>> it = entries.iterator(); - while(it.hasNext()) { - entry = it.next(); - } - } - - @SuppressWarnings("unchecked") - @Test(expected = IllegalArgumentException.class) - public void testReadDataParentNull() { - DataObjectReadingUtil.readData(entryNull.getValue(), (InstanceIdentifier) entryNull.getKey(), pathNull); - } - - @SuppressWarnings("unchecked") - @Test(expected = IllegalArgumentException.class) - public void testReadDataParentPathNull() { - DataObjectReadingUtil.readData(entry.getValue(), (InstanceIdentifier) entryNull.getKey(), pathNull); - } - - @SuppressWarnings("unchecked") - @Test - public void testReadDataWithThreeParams() { - assertTrue("Check if contains key", - DataObjectReadingUtil.readData(entry.getValue(), - (InstanceIdentifier) entry.getKey(), path).containsKey(entry.getKey())); - - assertTrue("Check if contains value", - DataObjectReadingUtil.readData(entry.getValue(), - (InstanceIdentifier) entry.getKey(), path).containsValue(entry.getValue())); - } - - @Test(expected = NullPointerException.class) - public void testReadDataWithTwoParams() { - DataObjectReadingUtil.readData(mockedTreeNode, TreeNode.class); - } -} \ No newline at end of file -- 2.36.6