Factor out {SharedSingleton,ImmutableOffset}MapTemplate 13/78113/1
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 16:57:10 +0000 (17:57 +0100)
commit43e10f8bd776c905c5e709b90e710570567f1618
tree294c759ca7b74123afeebb7c3ccdde910df7ef7d
parent27cb0ab92721e17a14dea60fcfee8bb9a0e0ae4b
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>
(cherry picked from commit bd16b6161802322cb33c39642ddeb8a59b3e5d48)
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