Skip to content

Commit b42259c

Browse files
authored
Add badges + refactor markdown a bit.
1 parent ab84ae4 commit b42259c

1 file changed

Lines changed: 22 additions & 11 deletions

File tree

README.md

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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

55
Simple 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
```
1717
Result.success("success");
18-
-----------------------
18+
```
19+
```
1920
Result.failure("failure");
20-
-----------------------
21+
```
22+
```
2123
Result.of("success");
22-
-----------------------
24+
```
25+
```
2326
Result.of(new Function<String>() {
2427
@Override public String call() throws Exception {
2528
return "success";
2629
}
2730
});
28-
-----------------------
31+
```
32+
```
2933
Result.orDefault(new Function<Integer>() {
3034
@Override public Integer call() throws Exception {
3135
return Integer.parseInt("invalid");
3236
}
3337
}, -1);
34-
-----------------------
38+
```
39+
```
3540
Result.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+
```
5056
Result.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
```
6571
Result.success("success").value();
66-
-----------------------
72+
```
73+
```
6774
Result.failure("failure").error();
68-
-----------------------
75+
```
76+
```
6977
Result.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+
```
8190
String 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
133144
This project was heavily inspired by:

0 commit comments

Comments
 (0)