@Test void getReference() { PageReference page = new PageReference("wiki", "parent", "page"); PageReference pageClone = new PageReference("wiki", "parent", "page"); assertSame(page, this.factory.getReference(page)); assertSame(page, this.factory.getReference(pageClone)); assertSame(page.getParent(), this.factory.getReference(pageClone.getParent())); PageReference page2 = new PageReference("wiki", "parent", "page2"); PageReference page2Cached = this.factory.getReference(page2); assertEquals(page2, page2Cached); assertNotSame(page, page2Cached); assertSame(page.getParent(), page2Cached.getParent()); }
public <E extends EntityReference> E getReference(E reference) { if (reference == null) { return null; } EntityReference entityReference = this.cache.get(reference); if (entityReference == null || !reference.getClass().isAssignableFrom(entityReference.getClass())) { entityReference = unique(reference); this.cache.put(entityReference, entityReference); } return (E) entityReference; }
EntityReferenceFactory { public <E extends EntityReference> E getReference(E reference) { if (reference == null) { return null; } EntityReference entityReference = this.cache.get(reference); if (entityReference == null || !reference.getClass().isAssignableFrom(entityReference.getClass())) { entityReference = unique(reference); this.cache.put(entityReference, entityReference); } return (E) entityReference; } }
EntityReferenceFactory { public <E extends EntityReference> E getReference(E reference) { if (reference == null) { return null; } EntityReference entityReference = this.cache.get(reference); if (entityReference == null || !reference.getClass().isAssignableFrom(entityReference.getClass())) { entityReference = unique(reference); this.cache.put(entityReference, entityReference); } return (E) entityReference; }  }
EntityReferenceFactory { public <E extends EntityReference> E getReference(E reference) { if (reference == null) { return null; } EntityReference entityReference = this.cache.get(reference); if (entityReference == null || !reference.getClass().isAssignableFrom(entityReference.getClass())) { entityReference = unique(reference); this.cache.put(entityReference, entityReference); } return (E) entityReference; }  E getReference(E reference); }
EntityReferenceFactory { public <E extends EntityReference> E getReference(E reference) { if (reference == null) { return null; } EntityReference entityReference = this.cache.get(reference); if (entityReference == null || !reference.getClass().isAssignableFrom(entityReference.getClass())) { entityReference = unique(reference); this.cache.put(entityReference, entityReference); } return (E) entityReference; }  E getReference(E reference);  }