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

org.jinq.tuples.Pair Maven / Gradle / Ivy

Go to download

Jinq public API for extending Java 8 streams with database functionality

There is a newer version: 2.0.2
Show newest version
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