All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.polaris.core.tuple.Pair Maven / Gradle / Ivy

There is a newer version: 3.2.1
Show newest version
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;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy