
org.davidmoten.kool.Indexed Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kool Show documentation
Show all versions of kool Show documentation
Streaming library supporting reuse and many operators
package org.davidmoten.kool;
import com.github.davidmoten.guavamini.Preconditions;
public final class Indexed {
private final T t;
private final int index;
private Indexed(T t, int index) {
Preconditions.checkNotNull(t);
this.t = t;
this.index = index;
}
public static Indexed create(T t, int index) {
return new Indexed(t, index);
}
public T value() {
return t;
}
public int index() {
return index;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + index;
result = prime * result + t.hashCode();
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Indexed> other = (Indexed>) obj;
if (index != other.index)
return false;
if (!t.equals(other.t))
return false;
return true;
}
@Override
public String toString() {
return "Indexed[index=" + index + ", value=" + t + "]";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy