TemplateModelListProxy extends AbstractList<T> implements Serializable { @Override public void add(int index, T object) { if (object == null) { throw new IllegalArgumentException( "Null values cannot be added to a list in the model"); } StateNode nodeToAdd = itemType.applicationToModel(object, PropertyFilter.ACCEPT_ALL); getModelList().add(index, nodeToAdd); } TemplateModelListProxy(StateNode stateNode,
            ComplexModelType<T> itemType); @SuppressWarnings("unchecked") @Override T get(int index); @Override T set(int index, T object); @Override void add(int index, T object); @Override void clear(); @Override int indexOf(Object object); @Override boolean remove(Object object); @Override T remove(int index); @Override int size();  }
@Test public void clear_noDefaultConstructor() { TemplateModelListProxy<ClassWithoutDefaultConstructor> list = createModelListProxy( ClassWithoutDefaultConstructor.class); list.add(new ClassWithoutDefaultConstructor("one")); list.add(new ClassWithoutDefaultConstructor("two")); assertListClearedNormally(list); }
@Test public void clear_defaultConstructor() { TemplateModelListProxy<ClassWithDefaultConstructor> list = createModelListProxy( ClassWithDefaultConstructor.class); ClassWithDefaultConstructor one = new ClassWithDefaultConstructor(); one.setField("one"); ClassWithDefaultConstructor two = new ClassWithDefaultConstructor(); two.setField("one"); list.add(one); list.add(two); assertListClearedNormally(list); }