@Test public void testSet() { EventList<Integer> source = new BasicEventList<>(); FunctionList<Integer, String> intsToStrings = new FunctionList<>(source, new IntegerToString(), new StringToInteger()); ListConsistencyListener.install(intsToStrings); source.add(ZERO); source.add(ONE); source.add(TWO); intsToStrings.set(0, "8"); assertEquals("8", intsToStrings.get(0)); source = new BasicEventList<>(); intsToStrings = new FunctionList<>(source, new IntegerToString()); source.add(ZERO); try { intsToStrings.set(0, "8"); fail("failed to receive an IllegalStateException for a call to set with no reverse function specified"); } catch (Exception e) {} source.set(0, NINE); assertEquals("9", intsToStrings.get(0)); }
@Override public E set(int index, E value) { final E updated = get(index); source.set(index, reverse(value)); return updated; }
FunctionList extends TransformedList<S, E> implements RandomAccess { @Override public E set(int index, E value) { final E updated = get(index); source.set(index, reverse(value)); return updated; } }
FunctionList extends TransformedList<S, E> implements RandomAccess { @Override public E set(int index, E value) { final E updated = get(index); source.set(index, reverse(value)); return updated; } FunctionList(EventList<S> source, Function<S,E> forward);  FunctionList(EventList<S> source, Function<S,E> forward, Function<E,S> reverse); }
FunctionList extends TransformedList<S, E> implements RandomAccess { @Override public E set(int index, E value) { final E updated = get(index); source.set(index, reverse(value)); return updated; } FunctionList(EventList<S> source, Function<S,E> forward);  FunctionList(EventList<S> source, Function<S,E> forward, Function<E,S> reverse); void setForwardFunction(Function<S,E> forward); Function<S,E> getForwardFunction(); void setReverseFunction(Function<E,S> reverse); Function<E,S> getReverseFunction(); @Override void listChanged(ListEvent<S> listChanges); @Override E get(int index); @Override E remove(int index); @Override E set(int index, E value); @Override void add(int index, E value); @Override boolean removeIf(Predicate<? super E> filter); }
FunctionList extends TransformedList<S, E> implements RandomAccess { @Override public E set(int index, E value) { final E updated = get(index); source.set(index, reverse(value)); return updated; } FunctionList(EventList<S> source, Function<S,E> forward);  FunctionList(EventList<S> source, Function<S,E> forward, Function<E,S> reverse); void setForwardFunction(Function<S,E> forward); Function<S,E> getForwardFunction(); void setReverseFunction(Function<E,S> reverse); Function<E,S> getReverseFunction(); @Override void listChanged(ListEvent<S> listChanges); @Override E get(int index); @Override E remove(int index); @Override E set(int index, E value); @Override void add(int index, E value); @Override boolean removeIf(Predicate<? super E> filter);  }