Created
November 29, 2017 14:00
-
-
Save attacco/7ad602d9ead3a5b7ade40e2c67b33ea0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// variant A: | |
if (fromDateTimeMs != null) { | |
where.and(timeColumn.goe(new Timestamp(fromDateTimeMs))); | |
} | |
if (tillDateTimeMs != null) { | |
where.and(timeColumn.lt(new Timestamp(tillDateTimeMs))); | |
} | |
// variant B: | |
Stream.of( | |
fromDateTimeMs == null ? null : timeColumn.goe(new Timestamp(fromDateTimeMs)), | |
tillDateTimeMs == null ? null : timeColumn.lt(new Timestamp(tillDateTimeMs)) | |
).filter(Objects::nonNull).reduce(BooleanExpression::and).ifPresent(where::and); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment