Add ImmutableMapTemplate 59/78059/18
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 10:14:08 +0000 (11:14 +0100)
commit048042bd88cc9b1f481c018363c331bca83e4e1f
tree1f5806ed988d8f194dd572a6c159570ad8a8d70f
parent00189066ebfd963523f29bd68cfc84129d19625b
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>
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