]> gerrit.simantics Code Review - simantics/platform.git/commit
Introduce utility class org.simantics.db.function.DbOptional<T>. 70/170/2
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 25 Nov 2016 10:03:27 +0000 (12:03 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 25 Nov 2016 13:49:05 +0000 (15:49 +0200)
commitfbeeb3e2a52430fa90563d2d033008cc0bd0d754
tree2023ba4ec4ee0148a8e5d655fb9f96ae74ab1b9f
parentae2de5015f654b89f424b22637a4690fbebc9587
Introduce utility class org.simantics.db.function.DbOptional<T>.

The class is a direct copy of java.util.Optional<T> but it uses
DbConsumer, DbFunction, DbPredicate and DbSupplier instead of the
standard Java 1.8 functional interfaces to allow the DbOptional methods
to throw DatabaseExceptions for cleaner database code in certain
situations.

The rationale behind this class is much the same as with the standard
optional. See e.g.
http://www.oracle.com/technetwork/articles/java/java8-optional-2175753.html.

refs #6829

Change-Id: Ibf62a56eb227264cbfac359aca99d87570b68a47
bundles/org.simantics.db/src/org/simantics/db/function/DbOptional.java [new file with mode: 0644]