README: update Condition examples for 0.6.0
This commit is contained in:
parent
888123b722
commit
47d3832a14
1 changed files with 22 additions and 47 deletions
69
README.org
69
README.org
|
@ -72,6 +72,28 @@
|
|||
#+END_SRC
|
||||
|
||||
|
||||
*** isTrue() / isFalse() / not()
|
||||
|
||||
#+BEGIN_SRC java
|
||||
final Condition condition = Condition.where(isTrue());
|
||||
final boolean isTrue = condition.isTrue();
|
||||
final boolean isFalse = condition.isFalse();
|
||||
final Condition not = condition.not();
|
||||
final Condition andCondition1 = condition.and(Condition.where(isAlsoTrue()));
|
||||
final Condition andCondition2 = condition.and(isAlsoTrue());
|
||||
final Condition orCondition1 = condition.or(Condition.where(isAlsoTrue()));
|
||||
final Condition orCondition2 = condition.or(isAlsoTrue());
|
||||
#+END_SRC
|
||||
|
||||
|
||||
*** flatMap(Function<Boolean, Condition>)
|
||||
|
||||
#+BEGIN_SRC java
|
||||
final Condition condition = Condition.where(isTrue())
|
||||
.flatMap(b -> Condition.where(b));
|
||||
#+END_SRC
|
||||
|
||||
|
||||
*** if-and-then-else
|
||||
|
||||
#+BEGIN_SRC java
|
||||
|
@ -104,53 +126,6 @@
|
|||
#+END_SRC
|
||||
|
||||
|
||||
*** if-not-then-else
|
||||
|
||||
#+BEGIN_SRC java
|
||||
if (!isFalse()) {
|
||||
doSomething();
|
||||
} else {
|
||||
doSomethingElse();
|
||||
}
|
||||
|
||||
Condition.whereNot(isFalse())
|
||||
.then(() -> doSomething())
|
||||
.otherwise(() -> doSomethingElse());
|
||||
#+END_SRC
|
||||
|
||||
|
||||
*** if-and-not-then-else
|
||||
|
||||
#+BEGIN_SRC java
|
||||
if (isTrue() || !isFalse()) {
|
||||
doSomething();
|
||||
} else {
|
||||
doSomethingElse();
|
||||
}
|
||||
|
||||
Condition.where(isTrue())
|
||||
.andNot(() -> isFalse())
|
||||
.then(() -> doSomething())
|
||||
.otherwise(() -> doSomethingElse());
|
||||
#+END_SRC
|
||||
|
||||
|
||||
*** if-or-not-then-else
|
||||
|
||||
#+BEGIN_SRC java
|
||||
if (isFalse() || !isAlsoFalse()) {
|
||||
doSomething();
|
||||
} else {
|
||||
doSomethingElse();
|
||||
}
|
||||
|
||||
Condition.where(isFalse())
|
||||
.orNot(() -> isAlsoFalse())
|
||||
.then(() -> doSomething())
|
||||
.otherwise(() -> doSomethingElse());
|
||||
#+END_SRC
|
||||
|
||||
|
||||
*** if-then-else-if
|
||||
|
||||
#+BEGIN_SRC java
|
||||
|
|
Loading…
Reference in a new issue