-
1. Re: [Erai 4] ListComponent questions
mbarkley Apr 22, 2016 10:59 AM (in response to hr.stoyanov)Hi Hristo,
There aren't getSize or iterator methods on ListComponent because it is expected that most manipulation of the ListComponent is done through the List it is bound to. When your ListComponent is bound to a model List, it is an invariant that each model in your model list will have a corresponding component at the same index in the ListComponent. That means you can iterate through all components using a for-loop where you check the index against the model list length, and call getComponent(int index).
-
2. Re: [Erai 4] ListComponent questions
hr.stoyanov Apr 22, 2016 2:12 PM (in response to mbarkley)Hi Max,
Can we just add 2 convenience methods in the org.jboss.errai.databinding.client.components.ComponentList interface, for example:
default Stream<C> stream(){
return IntStream
.range(0, getValue().size())
.mapToObj(i ->getComponent(i));
}
default Iterator<C> iterator(){
return stream().iterator();
}
With a stream/iterator of components, one can easily process tuples of Component/Model.
The only check to be done is if GWT 2.8 SNAPSHOT already provides java.util.stream.IntStream, which should be there by now.
I filed an Errai issues as well for your consideration. Here is my temp workaround:
public interface ErraiUtils {
static <M, C extends TakesValue<M>> Stream<C> stream(ListComponent<M,C> listComponent) {
return IntStream
.range(0, listComponent.getValue().size())
.mapToObj(i -> listComponent.getComponent(i));
}
static <M, C extends TakesValue<M>> Iterator<C> iterator(ListComponent<M,C> listComponent) {
return stream(listComponent).iterator();
}
}
Thanks.
-
3. Re: [Erai 4] ListComponent questions
hr.stoyanov Apr 22, 2016 4:57 PM (in response to hr.stoyanov)....Oops IntStream still not available in GWT