BUG-592: Rework instance identifier 78/5778/6
authorRobert Varga <rovarga@cisco.com>
Wed, 26 Mar 2014 14:18:50 +0000 (15:18 +0100)
committerTony Tkacik <ttkacik@cisco.com>
Wed, 16 Apr 2014 13:57:56 +0000 (13:57 +0000)
commit0abb86477bb0cf5e50b1b6dd72e77c8d776aee72
treefabe9856857bd9d106681fd8de6a20fdefb09ec2
parent8e3bc4731ef4fd1302cfc8b7241c9ef6515c1490
BUG-592: Rework instance identifier

This patch reworks the way InstanceIdentifier is implemented, gearing it
up for performance.

The entire implementation is based on Iterables instead of Lists, which
allows us to avoid copying them over and over as we construct new
identifiers. Simple .child() operation is a lot quicker, saving
instantiation of two intermediate classes.

The implementation gets rid of constructors, such that there is no
direct construction, but rather all paths are validated for content.
This also acts as a gate-keeper, enforcing the immutable nature of the
identifier.

Another optimization is that the hashCode() value is now built
incrementally as more members are added and cached.

InstanceIdentifierBuilder, now a full class, does not explictly copy the
base identifier, but reuses it -- there is no reason not to, as the base
identifier is immutable.

Change-Id: I0826ed3169a107c8f4b6e3026569e87387305ce0
Signed-off-by: Robert Varga <rovarga@cisco.com>
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/InstanceIdentifierCodecImpl.java
yang/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/HashCodeBuilder.java [new file with mode: 0644]
yang/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifier.java
yang/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifierBuilderImpl.java [new file with mode: 0644]
yang/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/KeyedInstanceIdentifier.java [new file with mode: 0644]
yang/yang-binding/src/test/java/org/opendaylight/yangtools/yang/binding/test/InstanceIdentifierTest.java