@Test public void testFromArray() throws Exception { String[] array = new String[] {"first"}; Triplet<String, String, String> triplet = Triplet.fromArray(array); assertTrue(triplet.first().equals("first")); assertTrue(null == triplet.second()); assertTrue(null == triplet.third()); array = new String[] {"first", "second"}; triplet = Triplet.fromArray(array); assertTrue("first".equals(triplet.first())); assertTrue("second".equals(triplet.second())); assertTrue(null == triplet.third()); array = new String[] {"first", "second", "third"}; triplet = Triplet.fromArray(array); assertTrue("first".equals(triplet.first())); assertTrue("second".equals(triplet.second())); assertTrue("third".equals(triplet.third())); array[1] = null; triplet = Triplet.fromArray(array); assertTrue("first".equals(triplet.first())); assertTrue(null == triplet.second()); assertTrue("third".equals(triplet.third())); }
public static <A> Triplet<A, A, A> fromArray(A[] array) { return new Triplet<>(0 < array.length ? array[0] : null, 1 < array.length ? array[1] : null, 2 < array.length ? array[2] : null); }
Triplet implements Serializable { public static <A> Triplet<A, A, A> fromArray(A[] array) { return new Triplet<>(0 < array.length ? array[0] : null, 1 < array.length ? array[1] : null, 2 < array.length ? array[2] : null); } }
Triplet implements Serializable { public static <A> Triplet<A, A, A> fromArray(A[] array) { return new Triplet<>(0 < array.length ? array[0] : null, 1 < array.length ? array[1] : null, 2 < array.length ? array[2] : null); } Triplet(A first, B second, C third); }
Triplet implements Serializable { public static <A> Triplet<A, A, A> fromArray(A[] array) { return new Triplet<>(0 < array.length ? array[0] : null, 1 < array.length ? array[1] : null, 2 < array.length ? array[2] : null); } Triplet(A first, B second, C third); static Triplet<A, B, C> of(A first, B second, C third); static Triplet<A, A, A> fromArray(A[] array); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); A first(); B second(); C third(); }
Triplet implements Serializable { public static <A> Triplet<A, A, A> fromArray(A[] array) { return new Triplet<>(0 < array.length ? array[0] : null, 1 < array.length ? array[1] : null, 2 < array.length ? array[2] : null); } Triplet(A first, B second, C third); static Triplet<A, B, C> of(A first, B second, C third); static Triplet<A, A, A> fromArray(A[] array); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); A first(); B second(); C third();  }