@Test void addSetListenerAdd() { Thread mock = mock(Thread.class); WorkbenchUtils.addListListener( observableList, c -> mock.run(), c -> fail("was removed instead of added") ); observableList.add("Test"); verify(mock).run(); }
public static <T> void addListListener(ObservableList<T> list, Consumer<T> addAction, Consumer<T> removeAction) { list.addListener((ListChangeListener<? super T>) c -> { while (c.next()) { if (!c.wasPermutated() && !c.wasUpdated()) { for (T remitem : c.getRemoved()) { removeAction.accept(remitem); } for (T additem : c.getAddedSubList()) { addAction.accept(additem); } } } }); }
WorkbenchUtils { public static <T> void addListListener(ObservableList<T> list, Consumer<T> addAction, Consumer<T> removeAction) { list.addListener((ListChangeListener<? super T>) c -> { while (c.next()) { if (!c.wasPermutated() && !c.wasUpdated()) { for (T remitem : c.getRemoved()) { removeAction.accept(remitem); } for (T additem : c.getAddedSubList()) { addAction.accept(additem); } } } }); } }
WorkbenchUtils { public static <T> void addListListener(ObservableList<T> list, Consumer<T> addAction, Consumer<T> removeAction) { list.addListener((ListChangeListener<? super T>) c -> { while (c.next()) { if (!c.wasPermutated() && !c.wasUpdated()) { for (T remitem : c.getRemoved()) { removeAction.accept(remitem); } for (T additem : c.getAddedSubList()) { addAction.accept(additem); } } } }); } private  WorkbenchUtils(); }
WorkbenchUtils { public static <T> void addListListener(ObservableList<T> list, Consumer<T> addAction, Consumer<T> removeAction) { list.addListener((ListChangeListener<? super T>) c -> { while (c.next()) { if (!c.wasPermutated() && !c.wasUpdated()) { for (T remitem : c.getRemoved()) { removeAction.accept(remitem); } for (T additem : c.getAddedSubList()) { addAction.accept(additem); } } } }); } private  WorkbenchUtils(); static void assertNodeNotSame(Node node1, Node node2); static void addListListener(ObservableList<T> list,
      Consumer<T> addAction,
      Consumer<T> removeAction); static String convertToId(String name); static int calculateColumnsPerRow(int modulesPerPage); }
WorkbenchUtils { public static <T> void addListListener(ObservableList<T> list, Consumer<T> addAction, Consumer<T> removeAction) { list.addListener((ListChangeListener<? super T>) c -> { while (c.next()) { if (!c.wasPermutated() && !c.wasUpdated()) { for (T remitem : c.getRemoved()) { removeAction.accept(remitem); } for (T additem : c.getAddedSubList()) { addAction.accept(additem); } } } }); } private  WorkbenchUtils(); static void assertNodeNotSame(Node node1, Node node2); static void addListListener(ObservableList<T> list,
      Consumer<T> addAction,
      Consumer<T> removeAction); static String convertToId(String name); static int calculateColumnsPerRow(int modulesPerPage);  }