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

org.jmmo.tuple.Tuple0 Maven / Gradle / Ivy

There is a newer version: 1.4
Show newest version
package org.jmmo.tuple;

public class Tuple0 implements Tuple, Comparable {
    private static final long serialVersionUID = 8036223661372630498L;

    private static final Tuple0 INSTANCE = new Tuple0();

    protected Tuple0() {
    }

    public static Tuple0 instance() {
        return INSTANCE;
    }

    @Override public int getSize() {
        return 0;
    }

    @Override public  E get(int i) {
        throw new IndexOutOfBoundsException("Tuple0 has no elements but " + i + " element requested");
    }

    @Override public int compareTo(Tuple0 o) {
        return 0;
    }

    @Override public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Tuple0)) return false;
        Tuple0 other = (Tuple0) o;
        return other.getSize() == 0;
    }

    @Override public int hashCode() {
        return 1;
    }

    @Override public String toString() {
        return "Tuple0{}";
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy