Skip to content

Commit e7cb4e6

Browse files
committed
2 parents 21f0310 + 5d05926 commit e7cb4e6

File tree

1 file changed

+53
-1
lines changed

1 file changed

+53
-1
lines changed

README.md

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,54 @@
11
# java-tuple
2-
Yet another Tuple library for Java 8
2+
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.andrebreves.java/java-tuple/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.andrebreves.java/java-tuple)
3+
4+
Yet another Tuple library for Java 8 and up.
5+
6+
Maven
7+
=====
8+
Add to ```pom.xml```:
9+
```xml
10+
<dependencies>
11+
<dependency>
12+
<groupId>com.andrebreves.java</groupId>
13+
<artifactId>java-tuple</artifactId>
14+
<version>1.0.0</version>
15+
</dependency>
16+
</dependencies>
17+
```
18+
19+
Usage
20+
=====
21+
22+
Java 8:
23+
```java
24+
Tuple3<String, String, String> tuple = Tuple.of("v01", "v02", "v03");
25+
System.out.println(tuple.v1()); // "v01"
26+
System.out.println(tuple.v3()); // "v03"
27+
28+
List<Tuple3<String, Integer, String>> list = Arrays.asList(
29+
Tuple.of("v10", 11, "v12"),
30+
Tuple.of("v20", 21, "v22"),
31+
Tuple.of("v30", 31, "v32")
32+
);
33+
34+
list.stream()
35+
.map(Tuple::v3)
36+
.forEachOrdered(System.out::print); // "v12v22v32"
37+
```
38+
39+
Java 10:
40+
```java
41+
var tuple = Tuple.of("v01", "v02", "v03");
42+
System.out.println(tuple.v1()); // "v01"
43+
System.out.println(tuple.v3()); // "v03"
44+
45+
var list = List.of(
46+
Tuple.of("v10", 11, "v12"),
47+
Tuple.of("v20", 21, "v22"),
48+
Tuple.of("v30", 31, "v32")
49+
);
50+
51+
list.stream()
52+
.map(Tuple::v3)
53+
.forEachOrdered(System.out::print); // "v12v22v32"
54+
```

0 commit comments

Comments
 (0)