title: Create a tuple with an optional field (Flink Java)
body: <p>I want to store an optional value associated with a <code>Tuple2&lt;String, String&gt;</code> key.  </p>
  
  <p>To do so, I tried creating a <code>class MyKey extends Tuple3&lt;String, String, String&gt;</code> with the third field optional. It can be null and is not used when checking for equality. </p>
  
  <p>I then overrided the equals() and hashCode() methods: </p>
  
  <pre><code>class MyKey extends Tuple3&lt;String, String, String&gt; {
      @Override
      public boolean equals(Object o) {
          if (this == o) {
              return true;
          }
          if (!(o instanceof myKey)) {
              return false;
          }
  
          MyKey tuple = (MyKey) o;
  
          if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) {
              return false;
          }
          if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) {
              return false;
          }
          return true;
  
      }
  
      @Override
      public int hashCode() {
          int result = f0 != null ? f0.hashCode() : 0;
          result = 31 * result + (f1 != null ? f1.hashCode() : 0);
          return result;
      }
  }
  </code></pre>
  
  <ul>
  <li>Are there any gotchas I should be aware of with this method?</li>
  <li>Are there any other solutions that I can consider?</li>
  </ul>