Changelog readme jenkins (#42)
* [changelog] convert to org-mode format * [readme] remove sonarcloud and codacy badges * [readme] adjust heading levels * [jenkins] Remove codacy * [jenkins] remove sonarcloud * [jenkins] try build with JDK 12
This commit is contained in:
parent
2e40176f6d
commit
1fa6a3c05a
4 changed files with 260 additions and 289 deletions
83
CHANGELOG
83
CHANGELOG
|
@ -1,83 +0,0 @@
|
||||||
CHANGELOG
|
|
||||||
=========
|
|
||||||
|
|
||||||
0.7.1
|
|
||||||
-----
|
|
||||||
|
|
||||||
* Bump assertj-core from 3.11.0 to 3.11.1 (#38)
|
|
||||||
* Bump kemitix-maven-tiles from 0.9.0 to 1.3.1 (#40)
|
|
||||||
* [jenkins] Compatibility build against java 11 (#40)
|
|
||||||
* Bump kemitix-parent from 5.1.1 to 5.2.0 (#39)
|
|
||||||
|
|
||||||
0.7.0
|
|
||||||
-----
|
|
||||||
|
|
||||||
* Deprecate Value.andNot(Supplier)
|
|
||||||
* pom: Remove redundant properties
|
|
||||||
* Remove deprecated methods
|
|
||||||
* pom: rearrange entries
|
|
||||||
* Bump assertj-core from 3.10.0 to 3.11.0
|
|
||||||
* Bump lombok from 1.18.0 to 1.18.2
|
|
||||||
* Bump tiles-maven-plugin from 2.11 to 2.12
|
|
||||||
* README: update Value examples
|
|
||||||
* README: update Condition examples
|
|
||||||
* Value: cleanup deprecated whereNot()
|
|
||||||
* README: convert to orgmode format
|
|
||||||
|
|
||||||
0.6.0
|
|
||||||
-----
|
|
||||||
|
|
||||||
* Remove `.travis-support`
|
|
||||||
* Add `Condition.isTrue()`
|
|
||||||
* Add `Condition.isFalse()`
|
|
||||||
* Add `Condition.not()`
|
|
||||||
* Add `Condition.and(Condition)`
|
|
||||||
* Add `Condition.or(Condition)`
|
|
||||||
* Add `Condition.not()`
|
|
||||||
* Deprecate `Condition.whereNot(boolean)`
|
|
||||||
* Deprecate `Condition.andNot(boolean)`
|
|
||||||
* Deprecate `Condition.orNot(boolean)`
|
|
||||||
* Add `Condition.flatMap(Function<Boolean, Condition>)` to make `Condition` a monad
|
|
||||||
* Add `Value.where(Condition, Supplier, Supplier)`
|
|
||||||
* Add `Value.where(Condition, Supplier)`
|
|
||||||
* Add `Value.where(Condition)`
|
|
||||||
* Deprecate `Value.whereNot(boolean)`
|
|
||||||
* Add `ValueClause.not()`
|
|
||||||
|
|
||||||
0.5.0
|
|
||||||
-----
|
|
||||||
|
|
||||||
* Add `thenThrow(Exception)`
|
|
||||||
* Add `otherwiseThrow(Exception)`
|
|
||||||
|
|
||||||
0.4.0
|
|
||||||
-----
|
|
||||||
|
|
||||||
* Building with Jenkins
|
|
||||||
* Upgrade `kemitix-parent` to 5.0.3
|
|
||||||
|
|
||||||
0.3.0
|
|
||||||
-----
|
|
||||||
|
|
||||||
* Add `<T> Value.where(boolean, Supplier<T>, Supplier<T>)`
|
|
||||||
* Add `Optional<T> Value.where(boolean, Supplier<T>)`
|
|
||||||
* Add `.travis-support`
|
|
||||||
* Avoid danger of JVM-level deadlock during `Value` initialisation
|
|
||||||
* Avoid danger of JVM-level deadlock during `Condition` initialisation
|
|
||||||
* Upgrade `kemitix-parent` to 3.2.0
|
|
||||||
* Upgrade `kemitix-checkstyle-parent` to 3.2.0
|
|
||||||
* Upgrade `assertj` to 3.8.0
|
|
||||||
* Set `jacoco` to 100% line and instruction coverage required
|
|
||||||
* Set `pitest` to 100% mutation and coverage required
|
|
||||||
* Use `lombok.val` in `ValueTest`
|
|
||||||
* Move `assertThat` calls to individual test methods in `ValueTest`
|
|
||||||
|
|
||||||
0.2.0
|
|
||||||
-----
|
|
||||||
|
|
||||||
* Added `Value`
|
|
||||||
|
|
||||||
0.1.0
|
|
||||||
-----
|
|
||||||
|
|
||||||
* Initial release
|
|
79
CHANGELOG.org
Normal file
79
CHANGELOG.org
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
* CHANGELOG
|
||||||
|
|
||||||
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
The format is based on [[https://keepachangelog.com/en/1.0.0/][Keep a Changelog]], and this project adheres to
|
||||||
|
[[https://semver.org/spec/v2.0.0.html][Semantic Versioning]].
|
||||||
|
|
||||||
|
* 0.7.1
|
||||||
|
|
||||||
|
- Bump assertj-core from 3.11.0 to 3.11.1 (#38)
|
||||||
|
- Bump kemitix-maven-tiles from 0.9.0 to 1.3.1 (#40)
|
||||||
|
- [jenkins] Compatibility build against java 11 (#40)
|
||||||
|
- Bump kemitix-parent from 5.1.1 to 5.2.0 (#39)
|
||||||
|
|
||||||
|
* 0.7.0
|
||||||
|
|
||||||
|
- Deprecate Value.andNot(Supplier)
|
||||||
|
- pom: Remove redundant properties
|
||||||
|
- Remove deprecated methods
|
||||||
|
- pom: rearrange entries
|
||||||
|
- Bump assertj-core from 3.10.0 to 3.11.0
|
||||||
|
- Bump lombok from 1.18.0 to 1.18.2
|
||||||
|
- Bump tiles-maven-plugin from 2.11 to 2.12
|
||||||
|
- README: update Value examples
|
||||||
|
- README: update Condition examples
|
||||||
|
- Value: cleanup deprecated whereNot()
|
||||||
|
- README: convert to orgmode format
|
||||||
|
|
||||||
|
* 0.6.0
|
||||||
|
|
||||||
|
- Remove `.travis-support`
|
||||||
|
- Add `Condition.isTrue()`
|
||||||
|
- Add `Condition.isFalse()`
|
||||||
|
- Add `Condition.not()`
|
||||||
|
- Add `Condition.and(Condition)`
|
||||||
|
- Add `Condition.or(Condition)`
|
||||||
|
- Add `Condition.not()`
|
||||||
|
- Deprecate `Condition.whereNot(boolean)`
|
||||||
|
- Deprecate `Condition.andNot(boolean)`
|
||||||
|
- Deprecate `Condition.orNot(boolean)`
|
||||||
|
- Add `Condition.flatMap(Function<Boolean, Condition>)` to make `Condition` a monad
|
||||||
|
- Add `Value.where(Condition, Supplier, Supplier)`
|
||||||
|
- Add `Value.where(Condition, Supplier)`
|
||||||
|
- Add `Value.where(Condition)`
|
||||||
|
- Deprecate `Value.whereNot(boolean)`
|
||||||
|
- Add `ValueClause.not()`
|
||||||
|
|
||||||
|
* 0.5.0
|
||||||
|
|
||||||
|
- Add `thenThrow(Exception)`
|
||||||
|
- Add `otherwiseThrow(Exception)`
|
||||||
|
|
||||||
|
* 0.4.0
|
||||||
|
|
||||||
|
- Building with Jenkins
|
||||||
|
- Upgrade `kemitix-parent` to 5.0.3
|
||||||
|
|
||||||
|
* 0.3.0
|
||||||
|
|
||||||
|
- Add `<T> Value.where(boolean, Supplier<T>, Supplier<T>)`
|
||||||
|
- Add `Optional<T> Value.where(boolean, Supplier<T>)`
|
||||||
|
- Add `.travis-support`
|
||||||
|
- Avoid danger of JVM-level deadlock during `Value` initialisation
|
||||||
|
- Avoid danger of JVM-level deadlock during `Condition` initialisation
|
||||||
|
- Upgrade `kemitix-parent` to 3.2.0
|
||||||
|
- Upgrade `kemitix-checkstyle-parent` to 3.2.0
|
||||||
|
- Upgrade `assertj` to 3.8.0
|
||||||
|
- Set `jacoco` to 100% line and instruction coverage required
|
||||||
|
- Set `pitest` to 100% mutation and coverage required
|
||||||
|
- Use `lombok.val` in `ValueTest`
|
||||||
|
- Move `assertThat` calls to individual test methods in `ValueTest`
|
||||||
|
|
||||||
|
* 0.2.0
|
||||||
|
|
||||||
|
- Added `Value`
|
||||||
|
|
||||||
|
* 0.1.0
|
||||||
|
|
||||||
|
- Initial release
|
|
@ -8,12 +8,6 @@ pipeline {
|
||||||
steps {
|
steps {
|
||||||
withMaven(maven: 'maven', jdk: 'JDK 1.8') {
|
withMaven(maven: 'maven', jdk: 'JDK 1.8') {
|
||||||
sh "${mvn} clean compile checkstyle:checkstyle pmd:pmd test"
|
sh "${mvn} clean compile checkstyle:checkstyle pmd:pmd test"
|
||||||
// Code Coverage to Codacy
|
|
||||||
sh "${mvn} jacoco:report com.gavinmogan:codacy-maven-plugin:coverage " +
|
|
||||||
"-DcoverageReportFile=target/site/jacoco/jacoco.xml " +
|
|
||||||
"-DprojectToken=`$JENKINS_HOME/codacy/token` " +
|
|
||||||
"-DapiToken=`$JENKINS_HOME/codacy/apitoken` " +
|
|
||||||
"-Dcommit=`git rev-parse HEAD`"
|
|
||||||
// Code Coverage to Jenkins
|
// Code Coverage to Jenkins
|
||||||
jacoco exclusionPattern: '**/*{Test|IT|Main|Application|Immutable}.class'
|
jacoco exclusionPattern: '**/*{Test|IT|Main|Application|Immutable}.class'
|
||||||
// PMD to Jenkins
|
// PMD to Jenkins
|
||||||
|
@ -33,16 +27,6 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('SonarQube (published)') {
|
|
||||||
when { expression { isPublished(publicRepo) } }
|
|
||||||
steps {
|
|
||||||
withSonarQubeEnv('sonarqube') {
|
|
||||||
withMaven(maven: 'maven', jdk: 'JDK 1.8') {
|
|
||||||
sh "${mvn} org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('Deploy (published release branch)') {
|
stage('Deploy (published release branch)') {
|
||||||
when {
|
when {
|
||||||
expression {
|
expression {
|
||||||
|
@ -64,6 +48,13 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
stage('Build Java 12') {
|
||||||
|
steps {
|
||||||
|
withMaven(maven: 'maven', jdk: 'JDK 12') {
|
||||||
|
sh "${mvn} clean verify -Djava.version=12"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
364
README.org
364
README.org
|
@ -1,259 +1,243 @@
|
||||||
* Conditional
|
* Conditional
|
||||||
|
|
||||||
|
* Functional Condition and Value.
|
||||||
|
|
||||||
** Functional Condition and Value.
|
[[https://oss.sonatype.org/content/repositories/releases/net/kemitix/conditional][file:https://img.shields.io/nexus/r/https/oss.sonatype.org/net.kemitix/conditional.svg?style=for-the-badge]]
|
||||||
|
[[https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22net.kemitix%22%20AND%20a%3A%22conditional%22][file:https://img.shields.io/maven-central/v/net.kemitix/conditional.svg?style=for-the-badge]]
|
||||||
|
[[http://i.jpeek.org/net.kemitix/conditional/index.html][file:http://i.jpeek.org/net.kemitix/conditional/badge.svg]]
|
||||||
|
|
||||||
[[https://oss.sonatype.org/content/repositories/releases/net/kemitix/conditional][file:https://img.shields.io/nexus/r/https/oss.sonatype.org/net.kemitix/conditional.svg?style=for-the-badge]]
|
* Maven
|
||||||
[[https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22net.kemitix%22%20AND%20a%3A%22conditional%22][file:https://img.shields.io/maven-central/v/net.kemitix/conditional.svg?style=for-the-badge]]
|
|
||||||
|
|
||||||
[[https://sonarcloud.io/dashboard?id=net.kemitix%3Aconditional][file:https://img.shields.io/sonar/https/sonarcloud.io/net.kemitix%3Aconditional/coverage.svg?style=for-the-badge#.svg]]
|
#+BEGIN_SRC xml
|
||||||
[[https://sonarcloud.io/dashboard?id=net.kemitix%3Aconditional][file:https://img.shields.io/sonar/https/sonarcloud.io/net.kemitix%3Aconditional/tech_debt.svg?style=for-the-badge#.svg]]
|
<dependency>
|
||||||
[[https://sonarcloud.io/dashboard?id=net.kemitix%3Aconditional][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Aconditional&metric=sqale_rating#.svg]]
|
<groupId>net.kemitix</groupId>
|
||||||
[[https://sonarcloud.io/dashboard?id=net.kemitix%3Aconditional][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Aconditional&metric=alert_status#.svg]]
|
<artifactId>conditional</artifactId>
|
||||||
[[https://sonarcloud.io/dashboard?id=net.kemitix%3Aconditional][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Aconditional&metric=reliability_rating#.svg]]
|
<version>RELEASE</version>
|
||||||
[[https://sonarcloud.io/dashboard?id=net.kemitix%3Aconditional][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Aconditional&metric=security_rating#.svg]]
|
</dependency>
|
||||||
[[https://sonarcloud.io/dashboard?id=net.kemitix%3Aconditional][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Aconditional&metric=sqale_index#.svg]]
|
#+END_SRC
|
||||||
[[https://sonarcloud.io/dashboard?id=net.kemitix%3Aconditional][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Aconditional&metric=vulnerabilities#.svg]]
|
|
||||||
[[https://sonarcloud.io/dashboard?id=net.kemitix%3Aconditional][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Aconditional&metric=bugs#.svg]]
|
|
||||||
[[https://sonarcloud.io/dashboard?id=net.kemitix%3Aconditional][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Aconditional&metric=code_smells#.svg]]
|
|
||||||
[[https://sonarcloud.io/dashboard?id=net.kemitix%3Aconditional][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Aconditional&metric=ncloc#.svg]]
|
|
||||||
|
|
||||||
[[https://app.codacy.com/project/kemitix/conditional/dashboard][file:https://img.shields.io/codacy/grade/1188742d676e457da91415d2b3a5faf1.svg?style=for-the-badge]]
|
The latest version should be shown above with the nexus and maven-central
|
||||||
[[http://i.jpeek.org/net.kemitix/conditional/index.html][file:http://i.jpeek.org/net.kemitix/conditional/badge.svg]]
|
badges or can be found on [[https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22net.kemitix%22%20AND%20a%3A%22mon%22][Maven Central]].
|
||||||
|
|
||||||
|
|
||||||
** Maven
|
* Condition
|
||||||
|
|
||||||
#+BEGIN_SRC xml
|
The `if ... then` and `if ... then ... else` constructs can't be used in a
|
||||||
<dependency>
|
lambda without being wrapped in a code block.
|
||||||
<groupId>net.kemitix</groupId>
|
|
||||||
<artifactId>conditional</artifactId>
|
|
||||||
<version>RELEASE</version>
|
|
||||||
</dependency>
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
The latest version should be shown above with the nexus and maven-central
|
Using `Condition` allows the use of an if-style expression without needing to
|
||||||
badges or can be found on [[https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22net.kemitix%22%20AND%20a%3A%22mon%22][Maven Central]].
|
wrap it in a code block
|
||||||
|
|
||||||
|
|
||||||
** Condition
|
** if-then
|
||||||
|
|
||||||
The `if ... then` and `if ... then ... else` constructs can't be used in a
|
#+BEGIN_SRC java
|
||||||
lambda without being wrapped in a code block.
|
if (isTrue()) {
|
||||||
|
doSomething();
|
||||||
|
}
|
||||||
|
|
||||||
Using `Condition` allows the use of an if-style expression without needing to
|
Condition.where(isTrue())
|
||||||
wrap it in a code block
|
.then(() -> doSomething());
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
|
||||||
*** if-then
|
** if-then-else
|
||||||
|
|
||||||
#+BEGIN_SRC java
|
#+BEGIN_SRC java
|
||||||
if (isTrue()) {
|
if (isTrue()) {
|
||||||
doSomething();
|
doSomething();
|
||||||
}
|
} else {
|
||||||
|
doSomethingElse();
|
||||||
|
}
|
||||||
|
|
||||||
Condition.where(isTrue())
|
Condition.where(isTrue())
|
||||||
.then(() -> doSomething());
|
.then(() -> doSomething())
|
||||||
#+END_SRC
|
.otherwise(() -> doSomethingElse());
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
|
||||||
*** if-then-else
|
** isTrue() / isFalse() / not()
|
||||||
|
|
||||||
#+BEGIN_SRC java
|
#+BEGIN_SRC java
|
||||||
if (isTrue()) {
|
final Condition condition = Condition.where(isTrue());
|
||||||
doSomething();
|
final boolean isTrue = condition.isTrue();
|
||||||
} else {
|
final boolean isFalse = condition.isFalse();
|
||||||
doSomethingElse();
|
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
|
||||||
|
|
||||||
Condition.where(isTrue())
|
|
||||||
.then(() -> doSomething())
|
|
||||||
.otherwise(() -> doSomethingElse());
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
|
** flatMap(Function<Boolean, Condition>)
|
||||||
|
|
||||||
*** isTrue() / isFalse() / not()
|
#+BEGIN_SRC java
|
||||||
|
final Condition condition = Condition.where(isTrue())
|
||||||
|
.flatMap(b -> Condition.where(b));
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
#+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
|
|
||||||
|
|
||||||
|
** if-and-then-else
|
||||||
|
|
||||||
*** flatMap(Function<Boolean, Condition>)
|
#+BEGIN_SRC java
|
||||||
|
if (isTrue() && isAlsoTrue()) {
|
||||||
|
doSomething();
|
||||||
|
} else {
|
||||||
|
doSomethingElse();
|
||||||
|
}
|
||||||
|
|
||||||
#+BEGIN_SRC java
|
Condition.where(isTrue())
|
||||||
final Condition condition = Condition.where(isTrue())
|
.and(() -> isAlsoTrue())
|
||||||
.flatMap(b -> Condition.where(b));
|
.then(() -> doSomething())
|
||||||
#+END_SRC
|
.otherwise(() -> doSomethingElse());
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
|
||||||
*** if-and-then-else
|
** if-or-then-else
|
||||||
|
|
||||||
#+BEGIN_SRC java
|
#+BEGIN_SRC java
|
||||||
if (isTrue() && isAlsoTrue()) {
|
if (isTrue() || alternativeIsTrue()) {
|
||||||
doSomething();
|
doSomething();
|
||||||
} else {
|
} else {
|
||||||
doSomethingElse();
|
doSomethingElse();
|
||||||
}
|
}
|
||||||
|
|
||||||
Condition.where(isTrue())
|
Condition.where(isTrue())
|
||||||
.and(() -> isAlsoTrue())
|
.or(() -> alternativeIsTrue())
|
||||||
.then(() -> doSomething())
|
.then(() -> doSomething())
|
||||||
.otherwise(() -> doSomethingElse());
|
.otherwise(() -> doSomethingElse());
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
|
||||||
*** if-or-then-else
|
** if-then-else-if
|
||||||
|
|
||||||
#+BEGIN_SRC java
|
#+BEGIN_SRC java
|
||||||
if (isTrue() || alternativeIsTrue()) {
|
if (isFalse()) {
|
||||||
doSomething();
|
doSomething();
|
||||||
} else {
|
} else if (isTrue()) {
|
||||||
doSomethingElse();
|
doSomethingElse();
|
||||||
}
|
}
|
||||||
|
|
||||||
Condition.where(isTrue())
|
Condition.where(isFalse())
|
||||||
.or(() -> alternativeIsTrue())
|
.then(() -> doSomething())
|
||||||
.then(() -> doSomething())
|
.otherwise(() -> isTrue())
|
||||||
.otherwise(() -> doSomethingElse());
|
.then(() -> doSomethingElse());
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
|
||||||
*** if-then-else-if
|
** if-then-if-then
|
||||||
|
|
||||||
#+BEGIN_SRC java
|
#+BEGIN_SRC java
|
||||||
if (isFalse()) {
|
if (isTrue()) {
|
||||||
doSomething();
|
doSomething();
|
||||||
} else if (isTrue()) {
|
if (isAlsoTrue()) {
|
||||||
doSomethingElse();
|
doSomethingElse();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Condition.where(isFalse())
|
Condition.where(isTrue())
|
||||||
.then(() -> doSomething())
|
.then(() -> doSomething())
|
||||||
.otherwise(() -> isTrue())
|
.and(() -> isAlsoTrue())
|
||||||
.then(() -> doSomethingElse());
|
.then(() -> doSomethingElse());
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
|
||||||
*** if-then-if-then
|
* Value
|
||||||
|
|
||||||
#+BEGIN_SRC java
|
Values from an if-then-else in a functional-style.
|
||||||
if (isTrue()) {
|
|
||||||
doSomething();
|
|
||||||
if (isAlsoTrue()) {
|
|
||||||
doSomethingElse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Condition.where(isTrue())
|
Functional, and verbose, alternative to the ternary operator (=?:=).
|
||||||
.then(() -> doSomething())
|
|
||||||
.and(() -> isAlsoTrue())
|
|
||||||
.then(() -> doSomethingElse());
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
|
|
||||||
** Value
|
** if-then-else
|
||||||
|
|
||||||
Values from an if-then-else in a functional-style.
|
#+BEGIN_SRC java
|
||||||
|
String result;
|
||||||
|
if (isTrue()) {
|
||||||
|
result = TRUE;
|
||||||
|
} else {
|
||||||
|
result = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
Functional, and verbose, alternative to the ternary operator (=?:=).
|
String result = isTrue() ? TRUE : FALSE;
|
||||||
|
|
||||||
|
final String result = Value.where(isTrue(), () -> TRUE, () -> FALSE);
|
||||||
|
|
||||||
*** if-then-else
|
final String result = Value.where(Condition.where(isTrue), () -> TRUE, () -> FALSE);
|
||||||
|
|
||||||
#+BEGIN_SRC java
|
final Optional<String> result = Value.where(isTrue(), () -> TRUE);
|
||||||
String result;
|
|
||||||
if (isTrue()) {
|
|
||||||
result = TRUE;
|
|
||||||
} else {
|
|
||||||
result = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
String result = isTrue() ? TRUE : FALSE;
|
final String result = Value.<String>where(isTrue())
|
||||||
|
.not()
|
||||||
|
.then(() -> FALSE)
|
||||||
|
.otherwise(() -> TRUE);
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
final String result = Value.where(isTrue(), () -> TRUE, () -> FALSE);
|
|
||||||
|
|
||||||
final String result = Value.where(Condition.where(isTrue), () -> TRUE, () -> FALSE);
|
** if-and-then-else
|
||||||
|
|
||||||
final Optional<String> result = Value.where(isTrue(), () -> TRUE);
|
#+BEGIN_SRC java
|
||||||
|
String result;
|
||||||
|
if (isTrue() && alternativeIsTrue()) {
|
||||||
|
result = TRUE;
|
||||||
|
} else {
|
||||||
|
result = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
final String result = Value.<String>where(isTrue())
|
final String result = Value.<String>where(isTrue())
|
||||||
.not()
|
.and(() -> alternativeIsTrue())
|
||||||
.then(() -> FALSE)
|
.then(() -> TRUE)
|
||||||
.otherwise(() -> TRUE);
|
.otherwise(() -> FALSE);
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
|
||||||
*** if-and-then-else
|
** if-or-then-else
|
||||||
|
|
||||||
#+BEGIN_SRC java
|
#+BEGIN_SRC java
|
||||||
String result;
|
String result;
|
||||||
if (isTrue() && alternativeIsTrue()) {
|
if (isTrue() || alternativeIsTrue()) {
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
} else {
|
} else {
|
||||||
result = FALSE;
|
result = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String result = Value.<String>where(isTrue())
|
final String result = Value.<String>where(isTrue())
|
||||||
.and(() -> alternativeIsTrue())
|
.or(() -> alternativeIsTrue())
|
||||||
.then(() -> TRUE)
|
.then(() -> TRUE)
|
||||||
.otherwise(() -> FALSE);
|
.otherwise(() -> FALSE);
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
|
||||||
*** if-or-then-else
|
** if-or-not-then-else
|
||||||
|
|
||||||
#+BEGIN_SRC java
|
#+BEGIN_SRC java
|
||||||
String result;
|
String result;
|
||||||
if (isTrue() || alternativeIsTrue()) {
|
if (isTrue() || !isFalse()) {
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
} else {
|
} else {
|
||||||
result = FALSE;
|
result = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String result = Value.<String>where(isTrue())
|
final String result = Value.<String>where(isTrue())
|
||||||
.or(() -> alternativeIsTrue())
|
.orNot(() -> isFalse())
|
||||||
.then(() -> TRUE)
|
.then(() -> TRUE)
|
||||||
.otherwise(() -> FALSE);
|
.otherwise(() -> FALSE);
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
|
||||||
*** if-or-not-then-else
|
** if-then
|
||||||
|
|
||||||
#+BEGIN_SRC java
|
#+BEGIN_SRC java
|
||||||
String result;
|
Optional<String> result;
|
||||||
if (isTrue() || !isFalse()) {
|
if (isTrue()) {
|
||||||
result = TRUE;
|
result = Optional.of(TRUE);
|
||||||
} else {
|
} else {
|
||||||
result = FALSE;
|
result = Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
final String result = Value.<String>where(isTrue())
|
final Optional<String> result = Value.<String>where(isTrue())
|
||||||
.orNot(() -> isFalse())
|
.then(() -> TRUE)
|
||||||
.then(() -> TRUE)
|
.optional();
|
||||||
.otherwise(() -> FALSE);
|
#+END_SRC
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
|
|
||||||
*** if-then
|
|
||||||
|
|
||||||
#+BEGIN_SRC java
|
|
||||||
Optional<String> result;
|
|
||||||
if (isTrue()) {
|
|
||||||
result = Optional.of(TRUE);
|
|
||||||
} else {
|
|
||||||
result = Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
final Optional<String> result = Value.<String>where(isTrue())
|
|
||||||
.then(() -> TRUE)
|
|
||||||
.optional();
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue