Tuple2 extends Tuple { public Tuple2<T1, T0> swap() { return new Tuple2<T1, T0>(f1, f0); } Tuple2();  Tuple2(T0 value0, T1 value1); @Override int getArity(); @Override @SuppressWarnings("unchecked") T getField(int pos); @Override @SuppressWarnings("unchecked") void setField(T value, int pos); void setFields(T0 value0, T1 value1); Tuple2<T1, T0> swap(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); @Override @SuppressWarnings("unchecked") Tuple2<T0,T1> copy(); static Tuple2<T0,T1> of(T0 value0, T1 value1); public T0 f0; public T1 f1; }
@Test public void testSwapValues() { Tuple2<String, Integer> toSwap = new Tuple2<>("Test case", 25); Tuple2<Integer, String> swapped = toSwap.swap(); Assert.assertEquals(swapped.f0, toSwap.f1); Assert.assertEquals(swapped.f1, toSwap.f0); }