11# Result for Java
22
3- [ ![ CircleCI] ( https://circleci.com/gh/amatkivskiy/ResultForJava/tree/master.svg?style=svg )] ( https://circleci.com/gh/amatkivskiy/ResultForJava/tree/master ) [ ![ Coverage Status] ( https://coveralls.io/repos/github/amatkivskiy/ResultForJava/badge.svg?branch=master )] ( https://coveralls.io/github/amatkivskiy/ResultForJava?branch=master ) ![ Android Supported] ( https://img.shields.io/badge/android%20support-YES-green.svg )
3+ [ ![ CircleCI] ( https://circleci.com/gh/amatkivskiy/ResultForJava/tree/master.svg?style=svg )] ( https://circleci.com/gh/amatkivskiy/ResultForJava/tree/master ) [ ![ Coverage Status] ( https://coveralls.io/repos/github/amatkivskiy/ResultForJava/badge.svg?branch=master )] ( https://coveralls.io/github/amatkivskiy/ResultForJava?branch=master ) ![ Android Supported] ( https://img.shields.io/badge/android%20support-YES-green.svg ) [ ![ Download ] ( https://api.bintray.com/packages/amatkivskiy/maven/result/images/download.svg ) ] ( https://bintray.com/amatkivskiy/maven/result/_latestVersion )
44
55Simple and lightwight implementation of success/failure pattern with ** _ KISS_ ** in mind. Indeed it is just a ` Result<V, E> ` type.
66
@@ -15,23 +15,28 @@ This means that any operation that you need can finish with either `Success` wit
1515- Simplest way to create Result:
1616```
1717Result.success("success");
18- -----------------------
18+ ```
19+ ```
1920Result.failure("failure");
20- -----------------------
21+ ```
22+ ```
2123Result.of("success");
22- -----------------------
24+ ```
25+ ```
2326Result.of(new Function<String>() {
2427 @Override public String call() throws Exception {
2528 return "success";
2629 }
2730});
28- -----------------------
31+ ```
32+ ```
2933Result.orDefault(new Function<Integer>() {
3034 @Override public Integer call() throws Exception {
3135 return Integer.parseInt("invalid");
3236 }
3337}, -1);
34- -----------------------
38+ ```
39+ ```
3540Result.orFailWith(new Function<Integer>() {
3641 @Override public Integer call() throws Exception {
3742 return Integer.parseInt("invalid");
@@ -46,7 +51,8 @@ Result.of("success").map(new Transformer<String, Integer>() {
4651 return value.length();
4752 }
4853});
49- -----------------------
54+ ```
55+ ```
5056Result.of("success")
5157 .flatMap(new Transformer<Result<String, Object>, Result<Integer, IllegalArgumentException>>() {
5258 @Override public Result<Integer, IllegalArgumentException> apply(Result<String, Object> value) {
@@ -63,9 +69,11 @@ Result.of("success")
6369- Consuming ` Result ` :
6470```
6571Result.success("success").value();
66- -----------------------
72+ ```
73+ ```
6774Result.failure("failure").error();
68- -----------------------
75+ ```
76+ ```
6977Result.of("success")
7078 .onSuccess(new Consumer<String>() {
7179 @Override public void accept(String value) {
@@ -77,7 +85,8 @@ Result.of("success")
7785 System.err.println(value);
7886 }
7987 });
80- -----------------------
88+ ```
89+ ```
8190String success = Result.<String, String>failure("failure").or("success");
8291```
8392
@@ -127,7 +136,9 @@ validateInputs(login, password).map(value -> new Credentials(login, password))
127136```
128137
129138## Download
130- TODO
139+ ```
140+ compile 'com.github.amatkivskiy:result:1.0.1'
141+ ```
131142
132143## Inspired by
133144This project was heavily inspired by:
0 commit comments