Add yangtools.concepts.CheckedValue 65/70265/13
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 3 Apr 2018 07:42:21 +0000 (09:42 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 16 Apr 2018 23:41:30 +0000 (01:41 +0200)
commitb63f01cde253e7f721494b583680bfc3814d2750
tree388c3b1971564dc0868280758ab3f79a3318e3b1
parent26ea9e4accf4b19ba2d2bf4d2f6771df9b12cd72
Add yangtools.concepts.CheckedValue

There are quite a few places where we would like to conditionally
create a value or report an error. These currently rely on thrown
exceptions, which has a performance penalty.

Introduce CheckedValue, which acts as a combined holder object
for either a value or an Exception. These objects can act as
intermediaries between callers and callees.

The underlying concept here is that of a variant value, which contains
either a value of type A or a value of type B. This patch adds
the concept as a utility Variant<T, U>.

Change-Id: Ibc6f562e22805b38402436cd9c0368dfcbb775fa
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
common/concepts/pom.xml
common/concepts/src/main/java/org/opendaylight/yangtools/concepts/CheckedValue.java [new file with mode: 0644]
common/concepts/src/main/java/org/opendaylight/yangtools/concepts/Variant.java [new file with mode: 0644]
common/concepts/src/test/java/org/opendaylight/yangtools/concepts/CheckedValueTest.java [new file with mode: 0644]