io.polaris.core.tuple.Pair Maven / Gradle / Ivy
package io.polaris.core.tuple;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
import java.util.Map;
/**
* @author Qt
* @since 1.8
*/
@Getter
@Setter
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class Pair extends Tuple2 implements Map.Entry, Serializable, Tuple {
public Pair(final A first, final B second) {
super(first, second);
}
public Pair() {
}
public static Pair of(T1 first, T2 second) {
return new Pair<>(first, second);
}
@Override
public A getKey() {
return getFirst();
}
@Override
public B getValue() {
return getSecond();
}
@Override
public B setValue(B value) {
B old = this.getSecond();
this.setSecond(value);
return old;
}
}