https://github.com/andrebreves/java-tuple
Yet another Tuple library for Java 8 and up
https://github.com/andrebreves/java-tuple
java java-tuple tuple-library
Last synced: 5 months ago
JSON representation
Yet another Tuple library for Java 8 and up
- Host: GitHub
- URL: https://github.com/andrebreves/java-tuple
- Owner: andrebreves
- License: apache-2.0
- Created: 2018-12-05T10:59:18.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-11-11T21:53:15.000Z (over 4 years ago)
- Last Synced: 2025-07-26T08:28:58.946Z (10 months ago)
- Topics: java, java-tuple, tuple-library
- Language: Java
- Homepage:
- Size: 183 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# java-tuple
[](https://maven-badges.herokuapp.com/maven-central/com.andrebreves/java-tuple)
Yet another Tuple library for Java 8 and up.
Maven
=====
Add to ```pom.xml```:
```xml
com.andrebreves
java-tuple
1.2.0
```
Usage
=====
Java 8:
```java
Tuple2 tuple = Tuple.of("v01", "v02");
System.out.println(tuple.v1()); // "v01"
System.out.println(tuple.v2()); // "v02"
Tuple3 newTuple = tuple.concat("v03");
System.out.println(newTuple.v1()); // "v01"
System.out.println(newTuple.v2()); // "v02"
System.out.println(newTuple.v3()); // "v03"
List> tuples = Arrays.asList(
Tuple.of("v10", 11, "v12"),
Tuple.of("v20", 21, "v22"),
Tuple.of("v30", 31, "v32")
);
tuples.stream()
.map(Tuple::v3)
.forEachOrdered(System.out::print); // "v12v22v32"
```
Java 10 and up:
```java
var tuple = Tuple.of("v01", "v02");
System.out.println(tuple.v1()); // "v01"
System.out.println(tuple.v2()); // "v02"
var newTuple = tuple.concat("v03");
System.out.println(newTuple.v1()); // "v01"
System.out.println(newTuple.v2()); // "v02"
System.out.println(newTuple.v3()); // "v03"
var tuples = List.of(
Tuple.of("v10", 11, "v12"),
Tuple.of("v20", 21, "v22"),
Tuple.of("v30", 31, "v32")
);
tuples.stream()
.map(Tuple::v3)
.forEachOrdered(System.out::print); // "v12v22v32"
```