org.jinq.tuples.Pair Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of api Show documentation
Show all versions of api Show documentation
Jinq public API for extending Java 8 streams with database functionality
package org.jinq.tuples;
import java.util.Collection;
import java.util.Vector;
public class Pair
{
final T one;
final U two;
public T getOne()
{
return one;
}
public U getTwo()
{
return two;
}
public Pair(T one, U two)
{
this.one = one;
this.two = two;
}
public boolean equals(Object obj)
{
if ( this == obj) return true;
if (! (obj instanceof Pair)) return false;
Pair,?> pair = (Pair,?>)obj;
return this.one.equals(pair.one)
&& this.two.equals(pair.two);
}
public int hashCode()
{
if (one != null && two != null)
return one.hashCode() + two.hashCode();
else if (one != null)
return one.hashCode();
else if (two != null)
return one.hashCode();
else
return 0;
}
public static Collection> PairCollection(V one, Collection twoList)
{
Vector> combined = new Vector>(twoList.size());
for (W two: twoList)
combined.add(new Pair(one, two));
return combined;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy