@Test public void testGet_shouldReturnNewList_ifUnderlyingListHasCangedOrder() { modelObjects.add(0); modelObjects.add(1); assertThat(itemSupplier.get(), hasSize(2)); assertThat(itemSupplier, hasPmosForModelobjects(0, 1)); SimplePmo pmo2 = itemSupplier.get().get(1); modelObjects.set(0, 99); assertThat(itemSupplier.get(), hasSize(2)); assertThat(itemSupplier, hasPmosForModelobjects(99, 1)); assertThat(pmo2, is(itemSupplier.get().get(1))); }
@Override public List<PMO> get() { List<? extends MO> actualModelObjects = modelObjectSupplier.get(); requireNonNull(actualModelObjects, "modelObjectSupplier must supply a List of model objects (which may be empty)"); if (hasUnderlyingModelObjectListChanged(actualModelObjects)) { HashSet<? extends MO> actualModelObjectsSet = new HashSet<>(actualModelObjects); itemMap.keySet().removeIf(o -> !actualModelObjectsSet.contains(o)); items = new LinkedList<>(); actualModelObjects.forEach(mo -> items.add(applymo2pmoMapping(mo))); modelObjectsCopy = new ArrayList<>(actualModelObjects); } return items; }
SimpleItemSupplier implements Supplier<List<PMO>> { @Override public List<PMO> get() { List<? extends MO> actualModelObjects = modelObjectSupplier.get(); requireNonNull(actualModelObjects, "modelObjectSupplier must supply a List of model objects (which may be empty)"); if (hasUnderlyingModelObjectListChanged(actualModelObjects)) { HashSet<? extends MO> actualModelObjectsSet = new HashSet<>(actualModelObjects); itemMap.keySet().removeIf(o -> !actualModelObjectsSet.contains(o)); items = new LinkedList<>(); actualModelObjects.forEach(mo -> items.add(applymo2pmoMapping(mo))); modelObjectsCopy = new ArrayList<>(actualModelObjects); } return items; } }
SimpleItemSupplier implements Supplier<List<PMO>> { @Override public List<PMO> get() { List<? extends MO> actualModelObjects = modelObjectSupplier.get(); requireNonNull(actualModelObjects, "modelObjectSupplier must supply a List of model objects (which may be empty)"); if (hasUnderlyingModelObjectListChanged(actualModelObjects)) { HashSet<? extends MO> actualModelObjectsSet = new HashSet<>(actualModelObjects); itemMap.keySet().removeIf(o -> !actualModelObjectsSet.contains(o)); items = new LinkedList<>(); actualModelObjects.forEach(mo -> items.add(applymo2pmoMapping(mo))); modelObjectsCopy = new ArrayList<>(actualModelObjects); } return items; } SimpleItemSupplier(Supplier<? extends List<? extends MO>> modelObjectSupplier,
            Function<MO, PMO> mo2pmoMapping); }
SimpleItemSupplier implements Supplier<List<PMO>> { @Override public List<PMO> get() { List<? extends MO> actualModelObjects = modelObjectSupplier.get(); requireNonNull(actualModelObjects, "modelObjectSupplier must supply a List of model objects (which may be empty)"); if (hasUnderlyingModelObjectListChanged(actualModelObjects)) { HashSet<? extends MO> actualModelObjectsSet = new HashSet<>(actualModelObjects); itemMap.keySet().removeIf(o -> !actualModelObjectsSet.contains(o)); items = new LinkedList<>(); actualModelObjects.forEach(mo -> items.add(applymo2pmoMapping(mo))); modelObjectsCopy = new ArrayList<>(actualModelObjects); } return items; } SimpleItemSupplier(Supplier<? extends List<? extends MO>> modelObjectSupplier,
            Function<MO, PMO> mo2pmoMapping); @Override List<PMO> get(); }
SimpleItemSupplier implements Supplier<List<PMO>> { @Override public List<PMO> get() { List<? extends MO> actualModelObjects = modelObjectSupplier.get(); requireNonNull(actualModelObjects, "modelObjectSupplier must supply a List of model objects (which may be empty)"); if (hasUnderlyingModelObjectListChanged(actualModelObjects)) { HashSet<? extends MO> actualModelObjectsSet = new HashSet<>(actualModelObjects); itemMap.keySet().removeIf(o -> !actualModelObjectsSet.contains(o)); items = new LinkedList<>(); actualModelObjects.forEach(mo -> items.add(applymo2pmoMapping(mo))); modelObjectsCopy = new ArrayList<>(actualModelObjects); } return items; } SimpleItemSupplier(Supplier<? extends List<? extends MO>> modelObjectSupplier,
            Function<MO, PMO> mo2pmoMapping); @Override List<PMO> get();  }