Commit graph

115 commits

Author SHA1 Message Date
b23337f25c
Remove Deprecated methods (#226)
* Result.andThen: remove deprecated method

Replace uses with `map`.

* Result.swap: remove deprecated method

* Remove unused imports

* ResultTest: add tests for ResultVoid.andThen()
2021-08-19 13:03:30 +01:00
892e3ec9f5
Result.match should return Result/ResultVoid (#225)
* ResultTest: group match tests and add missing errorVoid test

* Result{Void}.match() returns Result/ResultVoid
2021-08-19 11:47:02 +01:00
d1f4c61f00
Result.onSuccess should return Result/ResultVoid (#224)
* Version set to 3.2.0

* Result{Void}.onSuccess() now returns a Result<T>/ResultVoid
2021-08-19 11:35:05 +01:00
913df97a1d
EitherTest: add missing test display name values (#223) 2021-08-19 10:24:10 +01:00
786569a995
Implement a Reader monad (#214)
* Add Reader monad

* WrapperTest: clean up

* Reader: add API status annotations

* Version set to 3.1.0

* pom: remove duplicate dependency
2021-08-18 17:00:51 +01:00
74b3ea92b0
Fix javadoc (#218)
* github/workflow/build: verify javadoc

* github/workflow/deploy: only publish javadoc after successful deploy to sonatype

* result: fix javadoc

* result: fix javadoc (jdk 16 flagged)
2021-08-05 08:07:02 +01:00
571fd2641a
Result enhancements (#215)
* pom: don’t override java version - use LTS - JDK 11

* result: nest tests

* Add Result.{from(Either|Optional),ofVoid,ok(),onSuccess,applyOver}

* Add Result.flatApplyOver

* result: create separate documentation file

* Add Result.toEither()

* Add Result.onError - by type

* Simplify creation of Result in Result.ofVoid

* Make Result.ofVoid tolerate exceptions and no return statement

* Add missing javadoc for result.VoidCallable

* Bump pitest-junit5-plugin from 0.12 to 0.14 (#187)

* Bump tiles-maven-plugin from 2.19 to 2.20 (#188)

* Bump lombok from 1.18.18 to 1.18.20 (#189)

* Bump spotbugs-annotations from 4.2.2 to 4.2.3 (#191)

* Bump mockito-junit-jupiter from 3.8.0 to 3.9.0 (#190)

* Bump pitest-maven from 1.6.4 to 1.6.5 (#192)

* Bump pitest-maven from 1.6.5 to 1.6.6 (#194)

* Bump tiles-maven-plugin from 2.20 to 2.21 (#195)

* Bump mockito-junit-jupiter from 3.9.0 to 3.10.0 (#196)

* Bump junit-bom from 5.7.1 to 5.7.2 (#197)

* Bump tiles-maven-plugin from 2.21 to 2.22 (#198)

* Bump pitest-maven from 1.6.6 to 1.6.7 (#199)

* Bump mockito-junit-jupiter from 3.10.0 to 3.11.0 (#200)

* Bump assertj-core from 3.19.0 to 3.20.0 (#202)

* Bump mockito-junit-jupiter from 3.11.0 to 3.11.1 (#201)

* Bump assertj-core from 3.20.0 to 3.20.1 (#203)

* Bump tiles-maven-plugin from 2.22 to 2.23 (#204)

* Bump assertj-core from 3.20.1 to 3.20.2 (#205)

* Bump mockito-junit-jupiter from 3.11.1 to 3.11.2 (#206)

* Upgrade to GitHub-native Dependabot (#193)

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Paul Campbell <pcampbell@kemitix.net>

* Create dependabot.yml (#207)

* Bump actions/setup-java from 1 to 2.1.0 (#210)

* Bump actions/setup-java from 1 to 2.1.0

Bumps [actions/setup-java](https://github.com/actions/setup-java) from 1 to 2.1.0.
- [Release notes](https://github.com/actions/setup-java/releases)
- [Commits](https://github.com/actions/setup-java/compare/v1...v2.1.0)

---
updated-dependencies:
- dependency-name: actions/setup-java
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update build-maven.yml

* Update deploy-sonatype.yml

* Update build-maven.yml

* Update build-maven.yml

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Paul Campbell <pcampbell@kemitix.net>

* Bump release-drafter/release-drafter from 5.14.0 to 5.15.0 (#209)

Bumps [release-drafter/release-drafter](https://github.com/release-drafter/release-drafter) from 5.14.0 to 5.15.0.
- [Release notes](https://github.com/release-drafter/release-drafter/releases)
- [Commits](https://github.com/release-drafter/release-drafter/compare/v5.14.0...v5.15.0)

---
updated-dependencies:
- dependency-name: release-drafter/release-drafter
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Paul Campbell <pcampbell@kemitix.net>

* Add ResultVoid special Result type

- Result now extends ThrowableFunctor allowing mapping functions to throw exceptions
- Added ResultVoid to replace the usage of Result<Void> and handle void cases better
- Add `flatMapV` and `andThenV` which return ResultVoid

* result: Migrate static constructor docs to javadoc

* result.Result: move static constructors to top of class

* result: add docs and tests for from(Maybe) and from(Either)

* pom: add apigaurdian dependency

* Remove migrated docs

* result: add missing api status

* result.Result: group static methods together in file

* result.Result: reorder static methods

* result.Result: deprecate static maybe methods that don’t include Maybe in name

* result.Result.toMaybe: update docs and tests

* fix up toMaybe example

* result.Result.flatMapMaybe: update docs and tests

* result.Result.applyOver(Stream,Consumer): updated docs and tests

* result.Result.applyOver: update docs and tests

* result.Result: fix bad javadoc encoding

* result.Result.flatMapApply: update docs and tests

* result.Result.error(Class, Throwable): added

* result.Result: suppress warning on long class

* result.Result: apply warning supression to entire interface

* result.Result.toEither: update docs and tests

* result.Result.err: deprecate

* [BREAKING] result.Result.err: removed

* [BREAKING] result.Result.result: remove method

* [BREAKING] result.Result.success: remove method

* result.Result.orElseThrow: update docs and tests

* result.Result.toVoid: add javadoc and test

* result.Result.map: update docs and tests

* result.Result.map: add api status

* result.Result.isError: update docs and test

* result.Result.isError: update docs and test

* result.Result.isOkay: update docs and test

* result.Result.onError: update docs and test

* result.Result.onError: update docs and tests

* result.Result: tidy up and add some API statuses

* result.Result.orElseThrowUnchecked: update docs and tests

* result.Result.orElseThrow: update docs and tests

* result.Result.maybe: removed

* result.Result.thenWith: update docs and test

* result.Result.peek: update docs and tests

* result.Result.recover: update docs and tests

* result.Result.match: update docs and tests

* result.Result.andThen: deprecate in favour of map

* result.Result.flatMap: update docs and tests

* Update link to documentation for Result

* result.Result.flatMapV: add docs and test

* result.Result.match: update docs

* result.Result.onSuccess: update docs

* result.Result.reduce: mark experimental

* pom: remove java.version (conflict resolution mistake)

* Result: add deprecation annotations

* result.Err: remove unused imports

* result.BaseResult: extract interface

* result.ResultVoid.match: add javadoc

* result.ResultVoid: regroup tests and add javadoc for recover and onSuccess

* result.ResultVoid.onError: update docs and tests

* result.Err.andThen: don't create new object needlessly

* result.ResultVoid.andThen: add javadoc and update tests

* result.ResultVoid.inject: on error returns new exception, update docs and tests

* result.Result.error: suppress false positive unused parameter warning

* result.Success.getInstance added

* ErrVoid: fix toString

* SuccessVoid: break circular dependency

* Err: break circular dependency

* Result.result: added

* Success: break cyclic dependency

* Result.result: add javadoc and test

* Result.result: reuse static of(…)

* github/dependabot: clean up

* github/workflow: remove unused graphviz

* github/workflow: drop java  support

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-08-05 06:49:32 +01:00
5737e11395
Bump kemitix-maven-tiles to 3.0.0 and kemitix-checkstye to 5.5.0 (#181)
* Bump kemitix-maven-tiles to 3.0.0

* Bump kemitix-maven-tiles to 3.0.1

* Bump kemitix-checkstyle to 5.5.0

* Docs updates - more to come

* Checkstyle and PMD compliance updates

* result: map on Success should become Error on exception

* README: reformat in markdown
2021-03-14 15:15:50 +00:00
a501c506a4
Add Wrapper (#179)
* Update copyright year

* Alias: added

* bump release-drafter from 5.11.0 to 5.14.0

* Version set to 2.3.0

* Rename Alias as Wrapper and drop map method

Simplify tests.
2021-03-12 20:28:38 +00:00
bdb22f134e
TypeAlias allow toString to be overridden (#129) 2020-06-20 15:08:12 +01:00
30f903dbb2
Add flatMapLeft/Right and getLeft/Right to Either (#128)
* clean up code

* tree: replace deprecated assertj methods

* either: add flatMapLeft and flatMapRight

* either: add getLeft and getRight
2020-06-20 15:03:52 +01:00
830b312d9e
JDK 13 Compatibility (#116)
* Add jdk 13 to build matrix

* Adjust indentation

* Adjust indentation

* Bump kemitix-maven-tiles from 1.2.0 to 2.4.1

* Fix TypeAlias.equals(Object) does not check for null argument

net.kemitix.mon.TypeAlias.equals(Object) does not check for null argument [net.kemitix.mon.TypeAlias] At TypeAlias.java:[lines 82-88] NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT

* Fix TypeAlias.flatMap(Function) declares unbound method template parameter

[ERROR] Method net.kemitix.mon.TypeAlias.flatMap(Function) declares unbound method template parameter(s) [net.kemitix.mon.TypeAlias] At TypeAlias.java:[line 72] UMTP_UNBOUND_METHOD_TEMPLATE_PARAMETER

* Fix Lazy has a circular dependency with other classes

[ERROR] Class net.kemitix.mon.lazy.Lazy has a circular dependency with other classes [net.kemitix.mon.lazy.Lazy] At Lazy.java:[lines 36-46] FCCD_FIND_CLASS_CIRCULAR_DEPENDENCY

* Fix Synchronization performed on AtomicReference

[ERROR] Synchronization performed on java.util.concurrent.atomic.AtomicReference in net.kemitix.mon.lazy.LazySupplier.value() [net.kemitix.mon.lazy.LazySupplier] At LazySupplier.java:[line 61] JLM_JSR166_UTILCONCURRENT_MONITORENTER

* Fix Just.orElseThrow(Supplier) declares throwing an exception that isn't thrown

[ERROR] Non derivable method net.kemitix.mon.maybe.Just.orElseThrow(Supplier) declares throwing an exception that isn't thrown [net.kemitix.mon.maybe.Just] At Just.java:[line 102] BED_BOGUS_EXCEPTION_DECLARATION

* Fix Maybe has a circular dependency with other classes

[ERROR] Class net.kemitix.mon.maybe.Maybe has a circular dependency with other classes [net.kemitix.mon.maybe.Maybe] At Maybe.java:[lines 40-94] FCCD_FIND_CLASS_CIRCULAR_DEPENDENCY

* Fix Maybe.findFirst(Stream) uses immediate execution of a block

[ERROR] Method net.kemitix.mon.maybe.Maybe.findFirst(Stream) uses immediate execution of a block of code that is often not used [net.kemitix.mon.maybe.Maybe] At Maybe.java:[line 94] OI_OPTIONAL_ISSUES_USES_IMMEDIATE_EXECUTION

* Fix Success/Result/Err has a circular dependency

[ERROR] Class net.kemitix.mon.result.Err has a circular dependency with other classes [net.kemitix.mon.result.Err] At Err.java: FCCD_FIND_CLASS_CIRCULAR_DEPENDENCY

* Fix GeneralisedTree has a circular dependency

[ERROR] Class net.kemitix.mon.tree.GeneralisedTree has a circular dependency with other classes [net.kemitix.mon.tree.GeneralisedTree] At GeneralisedTree.java:[lines 39-80] FCCD_FIND_CLASS_CIRCULAR_DEPENDENCY

* Supress warning about boxing a boolean

NAB_NEEDLESS_BOOLEAN_CONSTANT_CONVERSION

Without creating a whole reimplemention of Maybe/Just/Nothing purely for `boolean` primitives, we can’t avoid this boxing.

* Supress store before return warnings in Lombok generate hashCode

USBR_UNNECESSARY_STORE_BEFORE_RETURN

The annotation has to be used at the class level, which unfortunately means we have no store-before-return checks for the rest of the class.

* Suppress warning about unused parameter

The type parameter for `Tree.builder(type)` is used to specify the parameterised type of the return value.

* Checkstyle fixups

* [changelog] updated
2020-03-20 07:17:29 +00:00
b2fe2f4557
Clean up (#64)
* [readme] use valid haskell example

* [tree] Immediately return this expression instead of assigning it to the temporary variable "treeList".

* [tree] Use normal defensive copying for array fields
2019-01-06 12:33:19 +00:00
8357d7f5d8
[tree] Add TreeBuilder (#57)
* [tree] TreeBuilder: whenEmptyBuilderBuildThenTreeIsAnEmptyLeaf()

* [tree] Provide default implementation of count()

* [tree] Extract TreeMapper

* [tree] MutableTree added

* [tree] TreeBuilder: whenAddLeafThenTreeHasLeaf()

* [tree] TreeBuilder: whenAddSubTreeThenTreeHasSubTree()

* [maybe] Add Maybe.findFirst(Stream) and matchValue(Function, Supplier)

* [tree] TreeBuilder: whenAddGrandChildThenTreeHasGrandChild()

* [tree] TreeBuilder: whenAddMultipleChildrenThenTreeHasAllChildren()

* [tree] Tree: avoid leaking MutableTree type as parameters

* [changelog] update

* [changelog][readme] Update to include TreeBuilder
2018-10-14 08:55:09 +01:00
73e59b0050
Bump junit from 4.12 to 5.3.1 (#56)
* Bump junit from 4.12 to 5.3.1

* [changelog] update

* [jenkins] stop publishing to codacy and test build with java 11
2018-10-12 20:42:11 +01:00
00d8808479 [result] orElseThrow() throws error within a CheckedErrorResultException 2018-10-06 19:58:50 +01:00
aed85d5488 [result] toMaybe fix typo 2018-10-04 07:55:34 +01:00
48e19fb653 [result] add orElseThrow(Class) and orElseThrowUnchecked()
Split `MonResultException` into `ErrorResultException` and `UnexpectedErrorResultException`.
2018-10-04 07:24:50 +01:00
c0ee1cdbc7 [result] orElseThrow() wraps the error exception in an unchecked MonResultException 2018-10-03 21:58:33 +01:00
d1adfd46d2 [lazy] add test to verify re-entrant behaviour of value() 2018-10-01 22:09:31 +01:00
9249ba8f59 [lazy] Add a lazy evaluator 2018-09-30 19:37:30 +01:00
f5c10e668d [tree] Add a Generalised Tree 2018-09-30 18:05:41 +01:00
93ad09c2fc [license] Update year to 2018 2018-09-29 19:59:38 +01:00
f26c5f07d5 Bump kemitix-checkstyle-ruleset from 4.1.1 to 5.0.0 2018-09-29 19:44:30 +01:00
Paul Campbell
11912a070e Fix typo in javadoc 2018-09-01 06:34:00 +01:00
Paul Campbell
1ca686a3f6 Add Maybe.or(Supplier<Maybe>)
Like a flatMap for the negative case.
2018-08-31 22:53:06 +01:00
4542d82c1a Rename Result.invert as swap 2018-07-21 22:42:16 +01:00
b80650b6ae Add Result.reduce(Result,BinaryOperator) 2018-07-20 18:40:33 +01:00
a1a7ad65c2 Left/Right: don't use @Getter for final fields
QA tools want these fields to be static, for which lombok creates static getter
methods, which then don't match the specification from the `Either` interface.
2018-07-16 22:39:28 +01:00
e8989718f3 README.org: expand TypeAlias documentation and add TypeAlias.flatMap() 2018-07-16 20:56:56 +01:00
e5958ba432 Add Either (experimental) 2018-07-16 18:49:44 +01:00
9a6c58c835 Rewrite README and convert to org-mode
* MaybeTest use static import Maybe.*
* Maybe.orElseThrow() now returns value when is a Just
2018-07-15 20:59:49 +01:00
51f86884fb Add Maybe.isJust() and Maybe.isNothing() 2018-07-12 20:28:34 +01:00
d66c4c8502 Add Maybe.match(Consumer,Runnable) 2018-07-12 18:45:02 +01:00
c64284872c Rename Result.maybeThen() as Result.flatMapMaybe() 2018-07-10 22:46:22 +01:00
3c60da2735 * Add Result.maybeThen(Result<Maybe<T>>, Function) 2018-07-10 17:37:54 +01:00
9138cbba46 ResultTest: tidy up test names 2018-07-09 15:47:27 +01:00
a9beeacf0b Update ResultTest sample businessOperation 2018-07-09 15:24:28 +01:00
f6eb27450f Add thenWith(Function) 2018-07-09 08:00:53 +01:00
fb6b65e6de Add andThen(Function) 2018-07-08 19:46:45 +01:00
28564a2129 Add Result.recover(Function) and Result.onError(Consumer) 2018-07-07 23:02:02 +01:00
c5247d7c14 Add Maybe.ifNothing(Runnable) 2018-07-07 18:21:35 +01:00
7648967f8a TypeAlias: access own member fields directly 2018-07-05 07:27:17 +01:00
9923bbc880 Add Result.peek(Consumer) 2018-06-30 18:13:29 +01:00
248bda0b4f Add Result.of(Callable) to reduce boiler plate when calling 2018-06-30 16:24:06 +01:00
1e85a14165 Result.Err.equals(): test when error is different 2018-06-26 22:18:32 +01:00
3e80dded1d Move BeanBuilder to experimental package and allow multiple with() calls 2018-06-26 07:31:03 +01:00
2f5b01f460 Remove Identity 2018-06-26 07:22:32 +01:00
18aa6406ef Result extends Functor 2018-06-26 07:19:39 +01:00
1f986139bc Tidy up checkstyle violations 2018-06-26 07:13:48 +01:00