diff --git a/CHANGELOG b/CHANGELOG deleted file mode 100644 index d97a90f..0000000 --- a/CHANGELOG +++ /dev/null @@ -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)` 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 ` Value.where(boolean, Supplier, Supplier)` -* Add `Optional Value.where(boolean, Supplier)` -* 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 diff --git a/CHANGELOG.org b/CHANGELOG.org new file mode 100644 index 0000000..45f0927 --- /dev/null +++ b/CHANGELOG.org @@ -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)` 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 ` Value.where(boolean, Supplier, Supplier)` + - Add `Optional Value.where(boolean, Supplier)` + - 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 diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index 2116f16..60b94b3 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -8,12 +8,6 @@ pipeline { steps { withMaven(maven: 'maven', jdk: 'JDK 1.8') { 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 jacoco exclusionPattern: '**/*{Test|IT|Main|Application|Immutable}.class' // 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)') { when { expression { @@ -64,6 +48,13 @@ pipeline { } } } + stage('Build Java 12') { + steps { + withMaven(maven: 'maven', jdk: 'JDK 12') { + sh "${mvn} clean verify -Djava.version=12" + } + } + } } } diff --git a/README.org b/README.org index 07983ee..43a9282 100644 --- a/README.org +++ b/README.org @@ -1,259 +1,243 @@ * 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]] - [[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]] +* Maven - [[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]] - [[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]] - [[https://sonarcloud.io/dashboard?id=net.kemitix%3Aconditional][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Aconditional&metric=sqale_rating#.svg]] - [[https://sonarcloud.io/dashboard?id=net.kemitix%3Aconditional][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Aconditional&metric=alert_status#.svg]] - [[https://sonarcloud.io/dashboard?id=net.kemitix%3Aconditional][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Aconditional&metric=reliability_rating#.svg]] - [[https://sonarcloud.io/dashboard?id=net.kemitix%3Aconditional][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Aconditional&metric=security_rating#.svg]] - [[https://sonarcloud.io/dashboard?id=net.kemitix%3Aconditional][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Aconditional&metric=sqale_index#.svg]] - [[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]] + #+BEGIN_SRC xml + + net.kemitix + conditional + RELEASE + + #+END_SRC - [[https://app.codacy.com/project/kemitix/conditional/dashboard][file:https://img.shields.io/codacy/grade/1188742d676e457da91415d2b3a5faf1.svg?style=for-the-badge]] - [[http://i.jpeek.org/net.kemitix/conditional/index.html][file:http://i.jpeek.org/net.kemitix/conditional/badge.svg]] + The latest version should be shown above with the nexus and maven-central + 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 - - net.kemitix - conditional - RELEASE - - #+END_SRC + The `if ... then` and `if ... then ... else` constructs can't be used in a + lambda without being wrapped in a code block. - The latest version should be shown above with the nexus and maven-central - 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]]. + Using `Condition` allows the use of an if-style expression without needing to + wrap it in a code block -** Condition +** if-then - The `if ... then` and `if ... then ... else` constructs can't be used in a - lambda without being wrapped in a code block. + #+BEGIN_SRC java + if (isTrue()) { + doSomething(); + } - Using `Condition` allows the use of an if-style expression without needing to - wrap it in a code block + Condition.where(isTrue()) + .then(() -> doSomething()); + #+END_SRC -*** if-then +** if-then-else - #+BEGIN_SRC java - if (isTrue()) { - doSomething(); - } + #+BEGIN_SRC java + if (isTrue()) { + doSomething(); + } else { + doSomethingElse(); + } - Condition.where(isTrue()) - .then(() -> doSomething()); - #+END_SRC + Condition.where(isTrue()) + .then(() -> doSomething()) + .otherwise(() -> doSomethingElse()); + #+END_SRC -*** if-then-else +** isTrue() / isFalse() / not() - #+BEGIN_SRC java - if (isTrue()) { - doSomething(); - } else { - doSomethingElse(); - } + #+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 - Condition.where(isTrue()) - .then(() -> doSomething()) - .otherwise(() -> doSomethingElse()); - #+END_SRC +** flatMap(Function) -*** 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) + #+BEGIN_SRC java + if (isTrue() && isAlsoTrue()) { + doSomething(); + } else { + doSomethingElse(); + } - #+BEGIN_SRC java - final Condition condition = Condition.where(isTrue()) - .flatMap(b -> Condition.where(b)); - #+END_SRC + Condition.where(isTrue()) + .and(() -> isAlsoTrue()) + .then(() -> doSomething()) + .otherwise(() -> doSomethingElse()); + #+END_SRC -*** if-and-then-else +** if-or-then-else - #+BEGIN_SRC java - if (isTrue() && isAlsoTrue()) { - doSomething(); - } else { - doSomethingElse(); - } + #+BEGIN_SRC java + if (isTrue() || alternativeIsTrue()) { + doSomething(); + } else { + doSomethingElse(); + } - Condition.where(isTrue()) - .and(() -> isAlsoTrue()) - .then(() -> doSomething()) - .otherwise(() -> doSomethingElse()); - #+END_SRC + Condition.where(isTrue()) + .or(() -> alternativeIsTrue()) + .then(() -> doSomething()) + .otherwise(() -> doSomethingElse()); + #+END_SRC -*** if-or-then-else +** if-then-else-if - #+BEGIN_SRC java - if (isTrue() || alternativeIsTrue()) { - doSomething(); - } else { - doSomethingElse(); - } + #+BEGIN_SRC java + if (isFalse()) { + doSomething(); + } else if (isTrue()) { + doSomethingElse(); + } - Condition.where(isTrue()) - .or(() -> alternativeIsTrue()) - .then(() -> doSomething()) - .otherwise(() -> doSomethingElse()); - #+END_SRC + Condition.where(isFalse()) + .then(() -> doSomething()) + .otherwise(() -> isTrue()) + .then(() -> doSomethingElse()); + #+END_SRC -*** if-then-else-if +** if-then-if-then - #+BEGIN_SRC java - if (isFalse()) { - doSomething(); - } else if (isTrue()) { - doSomethingElse(); - } + #+BEGIN_SRC java + if (isTrue()) { + doSomething(); + if (isAlsoTrue()) { + doSomethingElse(); + } + } - Condition.where(isFalse()) - .then(() -> doSomething()) - .otherwise(() -> isTrue()) - .then(() -> doSomethingElse()); - #+END_SRC + Condition.where(isTrue()) + .then(() -> doSomething()) + .and(() -> isAlsoTrue()) + .then(() -> doSomethingElse()); + #+END_SRC -*** if-then-if-then +* Value - #+BEGIN_SRC java - if (isTrue()) { - doSomething(); - if (isAlsoTrue()) { - doSomethingElse(); - } - } + Values from an if-then-else in a functional-style. - Condition.where(isTrue()) - .then(() -> doSomething()) - .and(() -> isAlsoTrue()) - .then(() -> doSomethingElse()); - #+END_SRC + Functional, and verbose, alternative to the ternary operator (=?:=). -** 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 - String result; - if (isTrue()) { - result = TRUE; - } else { - result = FALSE; - } + final Optional result = Value.where(isTrue(), () -> TRUE); - String result = isTrue() ? TRUE : FALSE; + final String result = Value.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 result = Value.where(isTrue(), () -> TRUE); + #+BEGIN_SRC java + String result; + if (isTrue() && alternativeIsTrue()) { + result = TRUE; + } else { + result = FALSE; + } - final String result = Value.where(isTrue()) - .not() - .then(() -> FALSE) - .otherwise(() -> TRUE); - #+END_SRC + final String result = Value.where(isTrue()) + .and(() -> alternativeIsTrue()) + .then(() -> TRUE) + .otherwise(() -> FALSE); + #+END_SRC -*** if-and-then-else +** if-or-then-else - #+BEGIN_SRC java - String result; - if (isTrue() && alternativeIsTrue()) { - result = TRUE; - } else { - result = FALSE; - } + #+BEGIN_SRC java + String result; + if (isTrue() || alternativeIsTrue()) { + result = TRUE; + } else { + result = FALSE; + } - final String result = Value.where(isTrue()) - .and(() -> alternativeIsTrue()) - .then(() -> TRUE) - .otherwise(() -> FALSE); - #+END_SRC + final String result = Value.where(isTrue()) + .or(() -> alternativeIsTrue()) + .then(() -> TRUE) + .otherwise(() -> FALSE); + #+END_SRC -*** if-or-then-else +** if-or-not-then-else - #+BEGIN_SRC java - String result; - if (isTrue() || alternativeIsTrue()) { - result = TRUE; - } else { - result = FALSE; - } + #+BEGIN_SRC java + String result; + if (isTrue() || !isFalse()) { + result = TRUE; + } else { + result = FALSE; + } - final String result = Value.where(isTrue()) - .or(() -> alternativeIsTrue()) - .then(() -> TRUE) - .otherwise(() -> FALSE); - #+END_SRC + final String result = Value.where(isTrue()) + .orNot(() -> isFalse()) + .then(() -> TRUE) + .otherwise(() -> FALSE); + #+END_SRC -*** if-or-not-then-else +** if-then - #+BEGIN_SRC java - String result; - if (isTrue() || !isFalse()) { - result = TRUE; - } else { - result = FALSE; - } + #+BEGIN_SRC java + Optional result; + if (isTrue()) { + result = Optional.of(TRUE); + } else { + result = Optional.empty(); + } - final String result = Value.where(isTrue()) - .orNot(() -> isFalse()) - .then(() -> TRUE) - .otherwise(() -> FALSE); - #+END_SRC - - -*** if-then - - #+BEGIN_SRC java - Optional result; - if (isTrue()) { - result = Optional.of(TRUE); - } else { - result = Optional.empty(); - } - - final Optional result = Value.where(isTrue()) - .then(() -> TRUE) - .optional(); - #+END_SRC + final Optional result = Value.where(isTrue()) + .then(() -> TRUE) + .optional(); + #+END_SRC