ForeignKeyHolder { @Override public String toString() { return this.instance != null ? this.instance.toString() : this.childClass.getSimpleName() + "[" + ObjectUtils.toString(this.id, null) + "]"; } ForeignKeyHolder(Class<C> childClass, Class<P> domainClass, Alias<P> domainAlias, ForeignKeyAliasColumn<C, P> childColumn); P get(); void set(P instance); Long getId(); void setId(Long id); @Override String toString();  }
@Test public void testToString() { ForeignKeyHolder<DummyDomainObject, DummyDomainObject> h = new ForeignKeyHolder<DummyDomainObject, DummyDomainObject>( DummyDomainObject.class, DummyDomainObject.class, null, null); Assert.assertEquals("DummyDomainObject[null]", h.toString()); h.setId(1l); Assert.assertEquals("DummyDomainObject[1]", h.toString()); }