/*
 * @author Ranides Atterwim {@literal <ranides@gmail.com>}
 * @copyright Ranides Atterwim
 * @license WTFPL
 * @url http://ranides.net/projects/assira
 */
package net.ranides.assira.generic;

import lombok.Data;

import java.io.Serializable;

/**
 * Represents immutable pair of numbers.
 * It implements Comparable and can be used as a key inside any Map.
 */
@Data(staticConstructor = "of")
public final class IntPair implements Comparable<IntPair>, Serializable {

    private static final long serialVersionUID = 1L;

    private final int first;
    private final int second;

    @Override
    public int compareTo(IntPair that) {
        int cmp1 = Integer.compare(this.first, that.first);
        return cmp1 != 0 ? cmp1 : Integer.compare(this.second, that.second);
    }

}
