com.clumd.projects.java_common_utils.models.Pair Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-common-utils Show documentation
Show all versions of java-common-utils Show documentation
A collection of common utilities I find myself writing for most Java projects
package com.clumd.projects.java_common_utils.models;
import lombok.Data;
import java.io.Serializable;
/**
* A simple 'Pair' concept, which groups together two objects, via whatever logical grouping the user believes.
*/
@Data
public class Pair implements Serializable {
private L left;
private R right;
public Pair(L left, R right) {
this.left = left;
this.right = right;
}
public static Pair of(final L left, final R right) {
return new Pair<>(left, right);
}
public L getFirst() {
return left;
}
public void setFirst(final L updatedFirst) {
left = updatedFirst;
}
public R getSecond() {
return right;
}
public void setSecond(final R updatedSecond) {
right = updatedSecond;
}
@Override
public String toString() {
return "< " + left.toString() + " : " + right.toString() + " >";
}
}