Add ImmutableMapTemplate 99/78099/2
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 22 Nov 2018 17:43:42 +0000 (18:43 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 23 Nov 2018 16:53:20 +0000 (17:53 +0100)
commit6ce1221b48e7ef7ac6ef0d439ee8ec127565bf12
tree43f2e9d3641a011dec19767323d132d0e3eb8eee
parent7704e400ae2aa45f65309a1fee7de3820e85a1ab
Add ImmutableMapTemplate

We have couple some hot paths where we know the keySet of an immutable
map we want to instantiate. For these, using
ImmutableOffsetMap.*copyOf() is wasteful, as it performs unnecessary
cache looks and map lookups.

ImmutableMapTemplate can be used to amortize these preparatory steps,
so that an ImmutableOffsetMap (or SharedSingletonMap) can efficiently
be produced by either transforming values of some other map, or by
supplying values in the correct order.

Since we are in the area, improve documentation and @NonNull
annotations of both ImmutableOffsetMap and SharedSingletonMap.

JIRA: YANGTOOLS-917
Change-Id: I8e7808b9bfe751885b842715f7e0346c0e7485b2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 048042bd88cc9b1f481c018363c331bca83e4e1f)
common/util/src/main/java/org/opendaylight/yangtools/util/ImmutableMapTemplate.java [new file with mode: 0644]
common/util/src/main/java/org/opendaylight/yangtools/util/ImmutableOffsetMap.java
common/util/src/main/java/org/opendaylight/yangtools/util/MutableOffsetMap.java
common/util/src/main/java/org/opendaylight/yangtools/util/OffsetMapCache.java
common/util/src/main/java/org/opendaylight/yangtools/util/SharedSingletonMap.java
common/util/src/test/java/org/opendaylight/yangtools/util/ImmutableMapTemplateTest.java [new file with mode: 0644]
common/util/src/test/java/org/opendaylight/yangtools/util/OffsetMapTest.java