Factor out {SharedSingleton,ImmutableOffset}MapTemplate 08/78108/4
authorRobert Varga <robert.varga@pantheon.tech>
Sun, 25 Nov 2018 10:19:25 +0000 (11:19 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Sun, 25 Nov 2018 13:50:48 +0000 (14:50 +0100)
commitbd16b6161802322cb33c39642ddeb8a59b3e5d48
tree9f3a57a4fe68d4f393571030a7c4f3437aeffa82
parente31b3dc700002b19d92ecc68463ab2711d8af99c
Factor out {SharedSingleton,ImmutableOffset}MapTemplate

Exposing the single-entry map case has the advantage of providing
instantiateWithValue(Object) method, side-stepping the need for
a temporary array. Split it out of ImmutableMapTemplate, so that
users can provide customized handling as needed.

The same holds true if the keyset is known to contain more than
one key, in which case using ImmutableOffsetMapTemplate can be
faster.

JIRA: YANGTOOLS-917
Change-Id: If08f492ff59bc89f3826a4122cfbcf34657c2210
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
common/util/src/main/java/org/opendaylight/yangtools/util/ImmutableMapTemplate.java
common/util/src/main/java/org/opendaylight/yangtools/util/ImmutableOffsetMap.java
common/util/src/main/java/org/opendaylight/yangtools/util/ImmutableOffsetMapTemplate.java [new file with mode: 0644]
common/util/src/main/java/org/opendaylight/yangtools/util/SharedSingletonMap.java
common/util/src/main/java/org/opendaylight/yangtools/util/SharedSingletonMapTemplate.java [new file with mode: 0644]
common/util/src/test/java/org/opendaylight/yangtools/util/ImmutableMapTemplateTest.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/YangInstanceIdentifier.java