package com.github.bot.curiosone.core.util;

import java.util.Objects;

/**
 * Container to ease passing around a tuple of two objects.
 */
public class Pair<F, S> {
  /** The first element of the pair. */
  private final F first;

  /** The second element of the pair. */
  private final S second;

  /**
   * Constructor for a Pair.
   *
   * @param first the first object in the pair
   * @param second the second object in the pair
   */
  public Pair(F first, S second) {
    this.first = first;
    this.second = second;
  }

  /**
   * Gets the first element of the pair.
   *
   * @return the first element of the pair.
   */
  public F getFirst() {
    return first;
  }

  /**
   * Gets the second element of the pair.
   *
   * @return the second element of the pair.
   */
  public S getSecond() {
    return second;
  }

  /**
   * Checks the two objects for equality by delegating to their respective
   * {@link Object#equals(Object)} methods.
   *
   * @param other the {@link Pair} to which this one is to be checked for equality
   * @return true if the underlying objects of the Pair are both considered
   *         equal
   */
  @Override
  public boolean equals(Object other) {
    if (other == this) {
      return true;
    }
    if (other == null || other.getClass() != this.getClass()) {
      return false;
    }
    Pair<?, ?> that = (Pair<?, ?>) other;
    return Objects.equals(that.first, this.first) && Objects.equals(that.second, this.second);
  }

  /**
   * Compute a hash code using the hash codes of the underlying objects.
   *
   * @return a hashcode of the pair
   */
  @Override
  public int hashCode() {
    return Objects.hash(first, second);
  }

  /**
   * Returns a string representation of this pair.
   *
   * @return a string representation of this interval in the form (first, second)
   */
  @Override
  public String toString() {
    return "(" + first + ", " + second + ")";
  }

  /**
   * Convenience method for creating an appropriately typed pair.
   *
   * @param a the first object in the pair
   * @param b the second object in the pair
   * @return a pair that is templatized with the types of a and b
   */
  public static <A, B> Pair<A, B> create(A a, B b) {
    return new Pair<A, B>(a, b);
  }
}

@@ -76,42 +76,73 @@
 %0A * 
-Container to ease passing around a
+Provides utility methods to easily create and manage an immutable
  tup
@@ -147,21 +147,17 @@
 uple of 
-two o
+O
 bjects.%0A
@@ -186,23 +186,36 @@
 F, S%3E %7B%0A
+%0A
   /**
- T
+%0A   * Stores t
 he first
@@ -227,32 +227,35 @@
 ent of the pair.
+%0A  
  */%0A  private fi
@@ -277,10 +277,22 @@
  /**
- T
+%0A   * Stores t
 he s
@@ -317,16 +317,19 @@
 he pair.
+%0A  
  */%0A  pr
@@ -375,28 +375,21 @@
 ruct
-or for a
+s this
  Pair.%0A
-   *%0A
    *
@@ -627,57 +627,8 @@
 ir.%0A
-   *%0A   * @return the first element of the pair.%0A
    *
@@ -728,58 +728,8 @@
 ir.%0A
-   *%0A   * @return the second element of the pair.%0A
    *
@@ -904,21 +904,16 @@
 ethods.%0A
-   *%0A
    * @pa
@@ -946,52 +946,27 @@
  to 
-which this one is to be checked for equality
+be compared against
 %0A   
@@ -975,20 +975,28 @@
 @return 
+%7B@code 
 true
+%7D
  if the 
@@ -1039,23 +1039,19 @@
 oth 
-considered
+equal;
 %0A   
-*
+ 
     
@@ -1055,21 +1055,40 @@
         
-equal
+%7B@code false%7D otherwise.
 %0A   */%0A 
@@ -1435,116 +1435,103 @@
   * 
-Compute a hash code using
+Returns
  the 
-hash codes of the underlying objects.%0A   *%0A   * @return a hashc
+HashCode for this Pair.%0A   * The HashCode is based on the HashC
 ode of 
-the pair
+each element.
 %0A   
@@ -1637,17 +1637,17 @@
 turns a 
-s
+S
 tring re
@@ -1675,68 +1675,8 @@
 pair
-.%0A   *%0A   * @return a string representation of this interval
  in 
@@ -1699,16 +1699,17 @@
  second)
+.
 %0A   */%0A 
@@ -1814,27 +1814,23 @@
   * 
-Convenience
+Utility
  method 
 for 
@@ -1829,55 +1829,40 @@
 hod 
-for
+to
  creat
-ing an appropriately typed p
+e a new immutable P
 air.%0A
-   *%0A
    *
@@ -1877,39 +1877,53 @@
 a the first 
-o
+O
 bject 
-in the p
+of the new immutable P
 air%0A   * @pa
@@ -1935,39 +1935,53 @@
  the second 
-o
+O
 bject 
-in
+of
  the 
-p
+new immutable P
 air%0A   * @re
@@ -1989,60 +1989,30 @@
 urn 
-a pair that is templatized with the types of a and b
+the new immutable Pair
 %0A   

improve Pair javadoc