Update CHANGELOG and README and add JDK 12 to jenkins (#63)

* [changelog] convert to org-mode and update

* [readme] adjust header levels

* [readme] Remove sonarcloud and codacy badges

* [jenkins] Remove sonarcloud

* [jenkins] Add test build for JDK 12
This commit is contained in:
Paul Campbell 2019-01-06 11:39:44 +00:00 committed by GitHub
parent 662e71f0d3
commit 7f5657e8e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 1032 additions and 1062 deletions

133
CHANGELOG
View file

@ -1,133 +0,0 @@
CHANGELOG
=========
2.0.0
-----
* [BREAKING] [tree] Tree.item() now returns a Maybe
* [tree] Add TreeBuilder
* [maybe] Add static Maybe.findFirst(Stream)
* [maybe] Add matchValue(Function, Supplier)
* Bump kemitix-parent from 5.1.1 to 5.2.0 (#55)
* Bump junit from 4.12 to 5.3.1 [#56)
1.2.0
-----
* [result] orElseThrow() throws error within a CheckedErrorResultException
1.1.0
-----
* [result] add orElseThrow(Class) and orElseThrowUnchecked()
1.0.0
-----
* [lazy] Add a lazy evaluator
* [tree] Add a generalised tree
* Bump kemitix-checkstyle-ruleset from 4.1.1 to 5.0.0
* Bump kemitix-maven-tiles from 0.8.1 to 1.2.0
0.12.0
------
* Add Maybe.or(Supplier<Maybe>)
* Add Result.reduce(Result,BinaryOperator)
* Rename Result.invert() as Result.swap()
* [admin] pom: update urls to github
* [admin] travis: don't use maven wrapper
* [admin] Remove maven wrapper
* Bump lombok from 1.18.0 to 1.18.2
* Bump assertj-core from 3.10.0 to 3.11.0
* Bump tiles-maven-plugin from 2.11 to 2.12
0.11.0
------
* Rename `Result.maybeThen()` as `Result.flatMapMaybe()`
* Add `Maybe.match(Consumer,Runnable)`
* Add `Maybe.isJust()`
* Add `Maybe.isNothing()`
* BUG: `Maybe.orElseThrow()` now returns value when a Just
* Rewrite README
* Add `Either` (experimental)
* Add `flatMap` to `TypeAlias`
0.10.0
------
* Add `Result.andThen(Function)`
* Add `Result.thenWith(Function)`
* Add `Result.maybeThen(Result<Maybe<T>>, Function)`
0.9.0
-----
* Add `Maybe.ifNothing(Runnable)`
* Add `Result.recover(Function)`
* Add `Result.onError(Consumer)`
0.8.0
-----
* Add `Result.of(Callable)`
0.7.0
-----
* Remove `Identity`
* Add `Result`
* Moved `Maybe` to `net.kemitix.mon.maybe.Maybe`
* `Maybe` is now a Monad
* Add `Maybe.stream()`
0.6.0
-----
* Java 9 compatible
* Upgrade `assertj` to 3.9.1
* jenkins: add Coverage stage
* jenkins: split Reporting stage into Test Results and Archiving
* jenkins: remove java 9 testing from `develop` branch
0.5.1
-----
* Fix accidental merge with SNAPSHOT version in to master
0.5.0
-----
* Add `Before`, `After` and `Around` combinators
* Use `kemitix-maven-tiles`
* Add `BeanBuilder` experiment
* Upgrade `lombok` to 1.16.20
* Upgrade assertj to 3.9.1
0.4.0
-----
* Restore public access for `TypeAlias.getValue()`
* Add `Maybe`, `Just`, `Nothing`
0.3.0
-----
* `TypeAlias.getValue()` removed in favour of using `map()`
0.2.0
-----
* `TypeAlias.getValue()` is not `final`
* Added `TypeAlias.map()`
* `Mon.map()` and `Mon.flatMap()` are `final`
* Codacy Quality clean up
0.1.0
-----
* Add `TypeAlias<T>`
* Add `Functor<T>`
* Add `Identity<T>`
* Add `Mon<T>`

129
CHANGELOG.org Normal file
View file

@ -0,0 +1,129 @@
* 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]].
* 2.0.1
** Dependencies
- Bump pitest-junit5-plugin from 0.7 to 0.8 (#58)
- Bump lombok from 1.18.2 to 1.18.4 (#59)
- Bump mockito-junit-jupiter from 2.23.0 to 2.23.4 (#60)
- Bump junit-bom from 5.3.1 to 5.3.2 (#61)
* 2.0.0
- [BREAKING] [tree] Tree.item() now returns a Maybe
- [tree] Add TreeBuilder
- [maybe] Add static Maybe.findFirst(Stream)
- [maybe] Add matchValue(Function, Supplier)
- Bump kemitix-parent from 5.1.1 to 5.2.0 (#55)
- Bump junit from 4.12 to 5.3.1 [#56)
* 1.2.0
- [result] orElseThrow() throws error within a CheckedErrorResultException
* 1.1.0
- [result] add orElseThrow(Class) and orElseThrowUnchecked()
* 1.0.0
- [lazy] Add a lazy evaluator
- [tree] Add a generalised tree
- Bump kemitix-checkstyle-ruleset from 4.1.1 to 5.0.0
- Bump kemitix-maven-tiles from 0.8.1 to 1.2.0
* 0.12.0
- Add Maybe.or(Supplier<Maybe>)
- Add Result.reduce(Result,BinaryOperator)
- Rename Result.invert() as Result.swap()
- [admin] pom: update urls to github
- [admin] travis: don't use maven wrapper
- [admin] Remove maven wrapper
- Bump lombok from 1.18.0 to 1.18.2
- Bump assertj-core from 3.10.0 to 3.11.0
- Bump tiles-maven-plugin from 2.11 to 2.12
* 0.11.0
- Rename `Result.maybeThen()` as `Result.flatMapMaybe()`
- Add `Maybe.match(Consumer,Runnable)`
- Add `Maybe.isJust()`
- Add `Maybe.isNothing()`
- BUG: `Maybe.orElseThrow()` now returns value when a Just
- Rewrite README
- Add `Either` (experimental)
- Add `flatMap` to `TypeAlias`
* 0.10.0
- Add `Result.andThen(Function)`
- Add `Result.thenWith(Function)`
- Add `Result.maybeThen(Result<Maybe<T>>, Function)`
* 0.9.0
- Add `Maybe.ifNothing(Runnable)`
- Add `Result.recover(Function)`
- Add `Result.onError(Consumer)`
* 0.8.0
- Add `Result.of(Callable)`
* 0.7.0
- Remove `Identity`
- Add `Result`
- Moved `Maybe` to `net.kemitix.mon.maybe.Maybe`
- `Maybe` is now a Monad
- Add `Maybe.stream()`
* 0.6.0
- Java 9 compatible
- Upgrade `assertj` to 3.9.1
- jenkins: add Coverage stage
- jenkins: split Reporting stage into Test Results and Archiving
- jenkins: remove java 9 testing from `develop` branch
* 0.5.1
- Fix accidental merge with SNAPSHOT version in to master
* 0.5.0
- Add `Before`, `After` and `Around` combinators
- Use `kemitix-maven-tiles`
- Add `BeanBuilder` experiment
- Upgrade `lombok` to 1.16.20
- Upgrade assertj to 3.9.1
* 0.4.0
- Restore public access for `TypeAlias.getValue()`
- Add `Maybe`, `Just`, `Nothing`
* 0.3.0
- `TypeAlias.getValue()` removed in favour of using `map()`
* 0.2.0
- `TypeAlias.getValue()` is not `final`
- Added `TypeAlias.map()`
- `Mon.map()` and `Mon.flatMap()` are `final`
- Codacy Quality clean up
* 0.1.0
- Add `TypeAlias<T>`
- Add `Functor<T>`
- Add `Identity<T>`
- Add `Mon<T>`

View file

@ -27,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 {
@ -58,6 +48,13 @@ pipeline {
}
}
}
stage('Build Java 12') {
steps {
withMaven(maven: 'maven', jdk: 'JDK 12') {
sh "${mvn} clean verify -Djava.version=12"
}
}
}
}
}

View file

@ -1,23 +1,8 @@
* Mon
** TypeAlias, Maybe and Result for Java.
* TypeAlias, Maybe and Result for Java.
[[https://oss.sonatype.org/content/repositories/releases/net/kemitix/mon][file:https://img.shields.io/nexus/r/https/oss.sonatype.org/net.kemitix/mon.svg?style=for-the-badge]]
[[https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22net.kemitix%22%20AND%20a%3A%22mon%22][file:https://img.shields.io/maven-central/v/net.kemitix/mon.svg?style=for-the-badge]]
[[https://sonarcloud.io/dashboard?id=net.kemitix%3Amon][file:https://img.shields.io/sonar/https/sonarcloud.io/net.kemitix%3Amon/coverage.svg?style=for-the-badge#.svg]]
[[https://sonarcloud.io/dashboard?id=net.kemitix%3Amon][file:https://img.shields.io/sonar/https/sonarcloud.io/net.kemitix%3Amon/tech_debt.svg?style=for-the-badge#.svg]]
[[https://sonarcloud.io/dashboard?id=net.kemitix%3Amon][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Amon&metric=sqale_rating#.svg]]
[[https://sonarcloud.io/dashboard?id=net.kemitix%3Amon][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Amon&metric=alert_status#.svg]]
[[https://sonarcloud.io/dashboard?id=net.kemitix%3Amon][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Amon&metric=reliability_rating#.svg]]
[[https://sonarcloud.io/dashboard?id=net.kemitix%3Amon][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Amon&metric=security_rating#.svg]]
[[https://sonarcloud.io/dashboard?id=net.kemitix%3Amon][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Amon&metric=sqale_index#.svg]]
[[https://sonarcloud.io/dashboard?id=net.kemitix%3Amon][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Amon&metric=vulnerabilities#.svg]]
[[https://sonarcloud.io/dashboard?id=net.kemitix%3Amon][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Amon&metric=bugs#.svg]]
[[https://sonarcloud.io/dashboard?id=net.kemitix%3Amon][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Amon&metric=code_smells#.svg]]
[[https://sonarcloud.io/dashboard?id=net.kemitix%3Amon][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Amon&metric=ncloc#.svg]]
[[https://app.codacy.com/project/kemitix/mon/dashboard][file:https://img.shields.io/codacy/grade/d57096b0639d496aba9a7e43e7cf5b4c.svg?style=for-the-badge]]
[[http://i.jpeek.org/net.kemitix/mon/index.html][file:http://i.jpeek.org/net.kemitix/mon/badge.svg]]
- [Maven Usage]
@ -28,8 +13,7 @@
- [Lazy]
- [Either]
** Maven Usage
* Maven Usage
#+BEGIN_SRC xml
<dependency>
@ -42,8 +26,7 @@
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]].
** TypeAlias
* TypeAlias
In Haskell it is possible to create an alias for a Type, and to then use
that alias with the same behaviour as the original, except that the compiler
@ -127,7 +110,7 @@
}
#+END_SRC
*** =TypeAlias= *can* be a Monad
** =TypeAlias= *can* be a Monad
#+BEGIN_SRC java
package net.kemitix.mon;
@ -198,9 +181,9 @@
#+END_SRC
*** Instance Methods
** Instance Methods
**** =final <R> R map(final Function<T, R> f)=
*** =final <R> R map(final Function<T, R> f)=
Map the TypeAlias into another value.
@ -219,7 +202,7 @@
#+END_SRC
**** =final <R, U extends TypeAlias<R>> U flatMap(final Function<T, U> f)=
*** =final <R, U extends TypeAlias<R>> U flatMap(final Function<T, U> f)=
Map the TypeAlias into another TypeAlias.
@ -238,7 +221,7 @@
#+END_SRC
**** =T getValue()=
*** =T getValue()=
Get the value of the TypeAlias.
@ -246,8 +229,7 @@
final String name = studentName.getValue();
#+END_SRC
** Maybe
* Maybe
Allows specifying that a value may or may not be present. Similar to
=Optional=. =Maybe= provides additional methods that =Optional= doesn't:
@ -297,7 +279,7 @@
=nothing= drops straight through the map and triggers the Runnable parameter
in the =match= call.
*** =Maybe= is a Monad:
** =Maybe= is a Monad:
#+BEGIN_SRC java
package net.kemitix.mon;
@ -349,9 +331,9 @@
#+END_SRC
*** Static Constructors
** Static Constructors
**** =static <T> Maybe<T> maybe(T value)=
*** =static <T> Maybe<T> maybe(T value)=
Create a Maybe for the value that may or may not be present.
@ -363,7 +345,7 @@
#+END_SRC
**** =static <T> Maybe<T> just(T value)=
*** =static <T> Maybe<T> just(T value)=
Create a Maybe for the value that is present.
@ -376,7 +358,7 @@
#+END_SRC
**** =static <T> Maybe<T> nothing()=
*** =static <T> Maybe<T> nothing()=
Create a Maybe for a lack of a value.
@ -385,7 +367,7 @@
#+END_SRC
**** =static <T> Maybe<T> findFirst(Stream<T> stream)=
*** =static <T> Maybe<T> findFirst(Stream<T> stream)=
Creates a Maybe from the first item in the stream, or nothing if the stream is empty.
@ -395,9 +377,9 @@
#+END_SRC
*** Instance Methods
** Instance Methods
**** =Maybe<T> filter(Predicate<T> predicate)=
*** =Maybe<T> filter(Predicate<T> predicate)=
Filter a Maybe by the predicate, replacing with Nothing when it fails.
@ -407,7 +389,7 @@
#+END_SRC
**** =<R> Maybe<R> map(Function<T,R> f)=
*** =<R> Maybe<R> map(Function<T,R> f)=
Applies the function to the value within the Maybe, returning the result within another Maybe.
@ -417,7 +399,7 @@
#+END_SRC
**** =<R> Maybe<R> flatMap(Function<T,Maybe<R>> f)=
*** =<R> Maybe<R> flatMap(Function<T,Maybe<R>> f)=
Applies the function to the value within the =Maybe=, resulting in another =Maybe=, then flattens the resulting =Maybe<Maybe<T>>= into =Maybe<T>=.
@ -429,7 +411,7 @@
#+END_SRC
**** =void match(Consumer<T> just, Runnable nothing)=
*** =void match(Consumer<T> just, Runnable nothing)=
Matches the Maybe, either just or nothing, and performs either the
Consumer, for Just, or Runnable for nothing.
@ -443,7 +425,7 @@
#+END_SRC
**** =<R> R matchValue(Function<T, R> justMatcher, Supplier<R> nothingMatcher)=
*** =<R> R matchValue(Function<T, R> justMatcher, Supplier<R> nothingMatcher)=
Matches the Maybe, either just or nothing, and performs either the
Function, for Just, or Supplier for nothing.
@ -457,7 +439,7 @@
#+END_SRC
**** =T orElse(T otherValue)=
*** =T orElse(T otherValue)=
A value to use when Maybe is Nothing.
@ -467,7 +449,7 @@
#+END_SRC
**** =T orElseGet(Supplier<T> otherValueSupplier)=
*** =T orElseGet(Supplier<T> otherValueSupplier)=
Provide a value to use when Maybe is Nothing.
@ -477,7 +459,7 @@
#+END_SRC
**** =T or(Supplier<Maybe<T> alternative)=
*** =T or(Supplier<Maybe<T> alternative)=
Provide an alternative Maybe to use when Maybe is Nothing.
@ -487,7 +469,7 @@
#+END_SRC
**** =void orElseThrow(Supplier<Exception> error)=
*** =void orElseThrow(Supplier<Exception> error)=
Throw the exception if the Maybe is a Nothing.
@ -497,7 +479,7 @@
#+END_SRC
**** =Maybe<T> peek(Consumer<T> consumer)=
*** =Maybe<T> peek(Consumer<T> consumer)=
Provide the value within the Maybe, if it exists, to the Consumer, and returns this Maybe. Conceptually equivalent to the idea of =ifPresent(...)=.
@ -507,7 +489,7 @@
#+END_SRC
**** =void ifNothing(Runnable runnable)=
*** =void ifNothing(Runnable runnable)=
Run the runnable if the Maybe is a Nothing, otherwise do nothing.
@ -517,7 +499,7 @@
#+END_SRC
**** =Stream<T> stream()=
*** =Stream<T> stream()=
Converts the Maybe into either a single value stream or an empty stream.
@ -527,7 +509,7 @@
#+END_SRC
**** =boolean isJust()=
*** =boolean isJust()=
Checks if the Maybe is a Just.
@ -537,7 +519,7 @@
#+END_SRC
**** =boolean isNothing()=
*** =boolean isNothing()=
Checks if the Maybe is Nothing.
@ -547,7 +529,7 @@
#+END_SRC
**** =Optional<T> toOptional()=
*** =Optional<T> toOptional()=
Convert the Maybe to an Optional.
@ -556,8 +538,7 @@
.toOptional();
#+END_SRC
** Result
* Result
Allows handling error conditions without the need to catch exceptions.
@ -609,7 +590,7 @@
Result would have ignored the =flatMap= and skipped to the =match()= when it
would have called the error =Consumer=.
*** =Result= is a Monad
** =Result= is a Monad
#+BEGIN_SRC java
package net.kemitix.mon;
@ -661,9 +642,9 @@
#+END_SRC
*** Static Constructors
** Static Constructors
**** =static <T> Result<T> of(Callable<T> callable)=
*** =static <T> Result<T> of(Callable<T> callable)=
Create a Result for a output of the Callable.
@ -679,7 +660,7 @@
#+END_SRC
**** =static <T> Result<T> ok(T value)=
*** =static <T> Result<T> ok(T value)=
Create a Result for a success.
@ -690,7 +671,7 @@
#+END_SRC
**** =static <T> Result<T> error(Throwable error)=
*** =static <T> Result<T> error(Throwable error)=
Create a Result for an error.
@ -699,14 +680,14 @@
#+END_SRC
*** Static Methods
** Static Methods
These static methods provide integration with the =Maybe= class.
#+BEGIN_SRC java
#+END_SRC
**** =static <T> Maybe<T> toMaybe(Result<T> result)=
*** =static <T> Maybe<T> toMaybe(Result<T> result)=
Creates a =Maybe= from the =Result=, where the =Result= is a success, then
the =Maybe= will contain the value. However, if the =Result= is an error
@ -718,7 +699,7 @@
#+END_SRC
**** =static <T> Result<T> fromMaybe(Maybe<T> maybe, Supplier<Throwable> error)=
*** =static <T> Result<T> fromMaybe(Maybe<T> maybe, Supplier<Throwable> error)=
Creates a =Result= from the =Maybe=, where the =Result= will be an error
if the =Maybe= is nothing. Where the =Maybe= is nothing, then the
@ -730,7 +711,7 @@
#+END_SRC
**** =static <T> Result<Maybe<T>> invert(Maybe<Result<T>> maybeResult)=
*** =static <T> Result<Maybe<T>> invert(Maybe<Result<T>> maybeResult)=
Swaps the =Result= within a =Maybe=, so that =Result= contains a =Maybe=.
@ -740,7 +721,7 @@
#+END_SRC
**** =static <T,R> Result<Maybe<R>> flatMapMaybe(Result<Maybe<T>> maybeResult, Function<Maybe<T>,Result<Maybe<R>>> f)=
*** =static <T,R> Result<Maybe<R>> flatMapMaybe(Result<Maybe<T>> maybeResult, Function<Maybe<T>,Result<Maybe<R>>> f)=
Applies the function to the contents of a Maybe within the Result.
@ -750,9 +731,9 @@
#+END_SRC
*** Instance Methods
** Instance Methods
**** =<R> Result<R> map(Function<T,R> f)=
*** =<R> Result<R> map(Function<T,R> f)=
Applies the function to the value within the Functor, returning the result
within a Functor.
@ -763,7 +744,7 @@
#+END_SRC
**** =<R> Result<R> flatMap(Function<T,Result<R>> f)=
*** =<R> Result<R> flatMap(Function<T,Result<R>> f)=
Returns a new Result consisting of the result of applying the function to
the contents of the Result.
@ -774,7 +755,7 @@
#+END_SRC
**** =<R> Result<R> andThen(Function<T,Callable<R>> f)=
*** =<R> Result<R> andThen(Function<T,Callable<R>> f)=
Maps a Success Result to another Result using a Callable that is able to
throw a checked exception.
@ -785,7 +766,7 @@
#+END_SRC
**** =void match(Consumer<T> onSuccess, Consumer<Throwable> onError)=
*** =void match(Consumer<T> onSuccess, Consumer<Throwable> onError)=
Matches the Result, either success or error, and supplies the appropriate
Consumer with the value or error.
@ -799,7 +780,7 @@
#+END_SRC
**** =Result<T> recover(Function<Throwable,Result<T>> f)=
*** =Result<T> recover(Function<Throwable,Result<T>> f)=
Provide a way to attempt to recover from an error state.
@ -809,7 +790,7 @@
#+END_SRC
**** =Result<T> peek(Consumer<T> consumer)=
*** =Result<T> peek(Consumer<T> consumer)=
Provide the value within the Result, if it is a success, to the Consumer,
and returns this Result.
@ -820,7 +801,7 @@
#+END_SRC
**** =Result<T> thenWith(Function<T,WithResultContinuation<T>> f)=
*** =Result<T> thenWith(Function<T,WithResultContinuation<T>> f)=
Perform the continuation with the current Result value then return the
current Result, assuming there was no error in the continuation.
@ -832,7 +813,7 @@
#+END_SRC
**** =Result<Maybe<T>> maybe(Predicate<T> predicate)=
*** =Result<Maybe<T>> maybe(Predicate<T> predicate)=
Wraps the value within the Result in a Maybe, either a Just if the
predicate is true, or Nothing.
@ -843,7 +824,7 @@
#+END_SRC
**** =T orElseThrow()=
*** =T orElseThrow()=
Extracts the successful value from the result, or throws the error
within a =CheckedErrorResultException=.
@ -854,7 +835,7 @@
#+END_SRC
**** =<E extends Exception> T orElseThrow(Class<E> type) throws E=
*** =<E extends Exception> T orElseThrow(Class<E> type) throws E=
Extracts the successful value from the result, or throws the error when it
is of the given type. Any other errors will be thrown inside an
@ -866,7 +847,7 @@
#+END_SRC
**** =T orElseThrowUnchecked()=
*** =T orElseThrowUnchecked()=
Extracts the successful value from the result, or throws the error within
an =ErrorResultException=.
@ -877,7 +858,7 @@
#+END_SRC
**** =void onError(Consumer<Throwable> errorConsumer)=
*** =void onError(Consumer<Throwable> errorConsumer)=
A handler for error states.
@ -887,7 +868,7 @@
#+END_SRC
**** =boolean isOkay()=
*** =boolean isOkay()=
Checks if the Result is a success.
@ -897,7 +878,7 @@
#+END_SRC
**** =boolean isError()=
*** =boolean isError()=
Checks if the Result is an error.
@ -906,15 +887,14 @@
.isError();
#+END_SRC
** Tree
* Tree
A Generalised tree, where each node may or may not have an item, and may have
any number of sub-trees. Leaf nodes are Trees with zero sub-trees.
*** Static Constructors
** Static Constructors
**** =static <R> Tree<R> leaf(R item)=
*** =static <R> Tree<R> leaf(R item)=
Create a leaf containing the item. The leaf has no sub-trees.
@ -923,7 +903,7 @@
#+END_SRC
**** =static<R> Tree<R> of(R item, Collection<Tree<R>> subtrees)=
*** =static<R> Tree<R> of(R item, Collection<Tree<R>> subtrees)=
Create a tree containing the item and sub-trees.
@ -932,7 +912,7 @@
#+END_SRC
**** =static <B> TreeBuilder<B> builder(final Class<B> type)=
*** =static <B> TreeBuilder<B> builder(final Class<B> type)=
Create a new TreeBuilder starting with an empty tree.
@ -941,7 +921,7 @@
#+END_SRC
**** =static <B> TreeBuilder<B> builder(final Tree<B> tree)=
*** =static <B> TreeBuilder<B> builder(final Tree<B> tree)=
Create a new TreeBuilder for the given tree.
@ -951,9 +931,9 @@
#+END_SRC
*** Instance Methods
** Instance Methods
**** =<R> Tree<R> map(Function<T, R> f)=
*** =<R> Tree<R> map(Function<T, R> f)=
Applies the function to the item within the Tree and to all sub-trees,
returning a new Tree.
@ -964,7 +944,7 @@
#+END_SRC
**** =Maybe<T> item()=
*** =Maybe<T> item()=
Returns the contents of the Tree node within a Maybe.
@ -974,7 +954,7 @@
#+END_SRC
**** =int count()=
*** =int count()=
Returns the total number of items in the tree, including sub-trees. Null
items don't count.
@ -985,7 +965,7 @@
#+END_SRC
**** =List<Tree<T> subTrees()=
*** =List<Tree<T> subTrees()=
Returns a list of sub-trees within the tree.
@ -994,8 +974,7 @@
final List<Tree<Item>> result = tree.subTrees();
#+END_SRC
** TreeBuilder
* TreeBuilder
A mutable builder for a Tree. Each TreeBuilder allows modification of a
single Tree node. You can use the =select(childItem)= method to get a
@ -1014,13 +993,13 @@
[[file:images/treebuilder-example.svg]]
*** Static Constructors
** Static Constructors
None. The TreeBuilder is instantiated by =Tree.builder()=.
*** Instance Methods
** Instance Methods
**** =Tree<T> build()=
*** =Tree<T> build()=
Create the immutable Tree.
@ -1030,7 +1009,7 @@
#+END_SRC
**** =TreeBuilder<T> item(T item)=
*** =TreeBuilder<T> item(T item)=
Set the current Tree's item and return the TreeBuilder.
@ -1038,7 +1017,7 @@
#+END_SRC
**** =TreeBuilder<T> add(Tree<T> subtree)=
*** =TreeBuilder<T> add(Tree<T> subtree)=
Adds the subtree to the current tree.
@ -1046,7 +1025,7 @@
#+END_SRC
**** =TreeBuilder<T> addChild(T childItem)=
*** =TreeBuilder<T> addChild(T childItem)=
Add the Child item as a sub-Tree.
@ -1054,7 +1033,7 @@
#+END_SRC
**** =TreeBuilder<T> addChildren(List<T> children)=
*** =TreeBuilder<T> addChildren(List<T> children)=
Add all the child items as subTrees.
@ -1062,7 +1041,7 @@
#+END_SRC
**** =Maybe<TreeBuilder<T>> select(T childItem)=
*** =Maybe<TreeBuilder<T>> select(T childItem)=
Create a TreeBuilder for the subTree of the current Tree that has the
childItem.
@ -1070,15 +1049,14 @@
#+BEGIN_SRC java
#+END_SRC
** Lazy
* Lazy
A Lazy evaluated expression. Using a Supplier to provide the value, only
evaluates the value when required, and never more than once.
*** Static Constructors
** Static Constructors
**** =static <R> Lazy<R> of(Supplier<R> supplier)=
*** =static <R> Lazy<R> of(Supplier<R> supplier)=
Create a new Lazy value from the supplier.
@ -1087,9 +1065,9 @@
final Lazy<UUID> lazy = Lazy.of(supplier);
#+END_SRC
*** Instance Methods
** Instance Methods
**** =boolean isEvaluated()=
*** =boolean isEvaluated()=
Checks if the value has been evaluated.
@ -1098,7 +1076,7 @@
final boolean isEvaluated = lazy.isEvaluated();
#+END_SRC
**** =T value()=
*** =T value()=
The value, evaluating it if necessary.
@ -1107,7 +1085,7 @@
final UUID value = lazy.value();
#+END_SRC
**** =<R> Lazy<R> map(Function<T, R> f)=
*** =<R> Lazy<R> map(Function<T, R> f)=
Maps the Lazy instance into a new Lazy instance using the function.
@ -1116,8 +1094,7 @@
final Lazy<String> stringLazy = uuidLazy.map(v -> v.toString());
#+END_SRC
** Either
* Either
Allows handling a value that can be one of two types, a left value/type or a
right value/type.
@ -1129,11 +1106,11 @@
convention, used to indicate the error, and right the success. An alternative
is to use the =Result= which more clearly distinguishes success from failure.
*** =Either= *is not* a Monad.
** =Either= *is not* a Monad.
*** Static Constructors
** Static Constructors
**** =static <L, R> Either<L, R> left(final L l)=
*** =static <L, R> Either<L, R> left(final L l)=
Create a new Either holding a left value.
@ -1142,7 +1119,7 @@
#+END_SRC
**** =static <L, R> Either<L, R> right(final R r)=
*** =static <L, R> Either<L, R> right(final R r)=
Create a new Either holding a right value.
@ -1151,9 +1128,9 @@
#+END_SRC
*** Instance Methods
** Instance Methods
**** =boolean isLeft()=
*** =boolean isLeft()=
Checks if the Either holds a left value.
@ -1163,7 +1140,7 @@
#+END_SRC
**** =boolean isRight()=
*** =boolean isRight()=
Checks if the Either holds a right value.
@ -1173,7 +1150,7 @@
#+END_SRC
**** =void match(Consumer<L> onLeft, Consumer<R> onRight)=
*** =void match(Consumer<L> onLeft, Consumer<R> onRight)=
Matches the Either, invoking the correct Consumer.
@ -1186,7 +1163,7 @@
#+END_SRC
**** =<T> Either<T, R> mapLeft(Function<L, T> f)=
*** =<T> Either<T, R> mapLeft(Function<L, T> f)=
Map the function across the left value.
@ -1196,7 +1173,7 @@
#+END_SRC
**** =<T> Either<L, T> mapRight(Function<R, T> f)=
*** =<T> Either<L, T> mapRight(Function<R, T> f)=
Map the function across the right value.