com.andrebreves:java-tuple

Yet another Tuple library for Java 8

License

License

Categories

Categories

Java Languages
GroupId

GroupId

com.andrebreves
ArtifactId

ArtifactId

java-tuple
Last Version

Last Version

1.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

com.andrebreves:java-tuple
Yet another Tuple library for Java 8
Project URL

Project URL

https://github.com/andrebreves/java-tuple
Source Code Management

Source Code Management

https://github.com/andrebreves/java-tuple.git

Download java-tuple

How to add to project

<!-- https://jarcasting.com/artifacts/com.andrebreves/java-tuple/ -->
<dependency>
    <groupId>com.andrebreves</groupId>
    <artifactId>java-tuple</artifactId>
    <version>1.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.andrebreves/java-tuple/
implementation 'com.andrebreves:java-tuple:1.2.0'
// https://jarcasting.com/artifacts/com.andrebreves/java-tuple/
implementation ("com.andrebreves:java-tuple:1.2.0")
'com.andrebreves:java-tuple:jar:1.2.0'
<dependency org="com.andrebreves" name="java-tuple" rev="1.2.0">
  <artifact name="java-tuple" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.andrebreves', module='java-tuple', version='1.2.0')
)
libraryDependencies += "com.andrebreves" % "java-tuple" % "1.2.0"
[com.andrebreves/java-tuple "1.2.0"]

Dependencies

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

java-tuple

Maven Central

Yet another Tuple library for Java 8 and up.

Maven

Add to pom.xml:

<dependencies>
    <dependency>
        <groupId>com.andrebreves</groupId>
        <artifactId>java-tuple</artifactId>
        <version>1.2.0</version>
    </dependency>
</dependencies>

Usage

Java 8:

Tuple2<String, String> tuple = Tuple.of("v01", "v02");
System.out.println(tuple.v1()); // "v01"
System.out.println(tuple.v2()); // "v02"

Tuple3<String, String, String> newTuple = tuple.concat("v03");
System.out.println(newTuple.v1()); // "v01"
System.out.println(newTuple.v2()); // "v02"
System.out.println(newTuple.v3()); // "v03"

List<Tuple3<String, Integer, String>> 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:

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"

Versions

Version
1.2.0
1.1.0