### Question:
IdRef extends GenericIdRef<Long, E> { public static <E extends GenericEntity<Long>> IdRef<E> of(E entity) { if (entity == null) { return null; } return of(entity.getId()); } IdRef(Long id); static IdRef<E> of(E entity); static IdRef<E> of(Long id); static IdRef<E> of(long id);  }### Answer:
@Test public void testOfEntity() { long id = 4711L; FooEto foo = new FooEto(); foo.setId(id); IdRef<Foo> fooId = IdRef.<Foo> of(foo); assertThat(fooId).isNotNull(); assertThat(fooId.getId()).isEqualTo(foo.getId()).isEqualTo(id); assertThat(fooId.toString()).isEqualTo(Long.toString(id)); assertThat(IdRef.of((Foo) null)).isNull(); Bar bar = new Bar(); bar.setFooId(fooId); IdRef<Bar> barId = IdRef.of(1234L); bar.setBarId(barId); }
@Test public void testOfLong() { long id = 4711L; IdRef<Foo> fooId = IdRef.of(id); assertThat(fooId).isNotNull(); assertThat(fooId.getId()).isEqualTo(id); assertThat(fooId.toString()).isEqualTo(Long.toString(id)); assertThat(IdRef.of(Long.valueOf(id))).isEqualTo(fooId).isNotSameAs(fooId); assertThat(IdRef.of((Long) null)).isNull(); }