ObjectLibrary { public static <U, T> Function<U, T> methodIdentity(final T object) { return new Function<U, T>() { @Override public T outputFor(U value) { return object; } }; }  static Function<T, String> methodToString(); static Function<U, T> methodIdentity(final T object); static Function<T, T> methodYourself();  }
@Test public void methodIdentityReturnsSameObject() { Integer three = 3; Function<Object, Integer> identity = methodIdentity(three); assertEquals(three, identity.outputFor("1")); assertEquals(three, identity.outputFor(2)); three = null; assertEquals(Integer.valueOf(3), identity.outputFor(null)); assertTrue(null == methodIdentity(three).outputFor("1")); assertTrue(null == methodIdentity(null).outputFor("1")); }