org.nd4j.linalg.primitives.Pair Maven / Gradle / Ivy
package org.nd4j.linalg.primitives;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Arrays;
/**
* Simple pair implementation
*
* @author [email protected]
*/
@AllArgsConstructor
@Data
@NoArgsConstructor
@Builder
public class Pair implements Serializable {
private static final long serialVersionUID = 119L;
protected K key;
protected V value;
@Override
public String toString() {
return "Pair{" +
"key=" + (key instanceof int[] ? Arrays.toString((int[]) key) : key) +
", value=" + (value instanceof int[] ? Arrays.toString((int[]) value) : value) +
'}';
}
public K getLeft() {
return key;
}
public V getRight() {
return value;
}
public K getFirst() {
return key;
}
public V getSecond() {
return value;
}
public void setFirst(K first) {
key = first;
}
public void setSecond(V second) {
value = second;
}
public static Pair of(T key, E value) {
return new Pair(key, value);
}
public static Pair makePair(T key, E value) {
return new Pair(key, value);
}
public static Pair create(T key, E value) {
return new Pair(key, value);
}
public static Pair pairOf(T key, E value) {
return new Pair(key, value);
}
}