| Summary: | [xbase][lib] IteratorExtensions | ||
|---|---|---|---|
| Product: | [Modeling] TMF | Reporter: | Bernd Kolb <b.kolb> |
| Component: | Xtext | Assignee: | Project Inbox <tmf.xtext-inbox> |
| Status: | CLOSED FIXED | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | CC: | christian.dietrich.opensource, jan, sebastian.zarnekow, sven.efftinge |
| Version: | unspecified | Flags: | sebastian.zarnekow:
juno+
|
| Target Milestone: | M4 | ||
| Hardware: | PC | ||
| OS: | Mac OS X - Carbon (unsup.) | ||
| Whiteboard: | |||
|
Description
Bernd Kolb
This is what the /org.eclipse.xtext.xtend2.lib/src/org/eclipse/xtext/xtend2/lib/EObjectExtensions.java /org.eclipse.xtext.xtend2.lib/src/org/eclipse/xtext/xtend2/lib/ResourceExtensions.java /org.eclipse.xtext.xtend2.lib/src/org/eclipse/xtext/xtend2/lib/ResourceSetExtensions.java extensions are for. You have to explicitely import them as static extensions, as we don't want to force Xtend users to have a dependency on EMF. We introduce an IteratorIterable for this
public class IteratorIterable<T> implements Iterable<T> {
private Iterator<T> iterator;
@Override
public Iterator<T> iterator() {
return iterator;
}
public IteratorIterable(Iterator<T> iterator) {
super();
this.iterator = iterator;
}
public static <T> IteratorIterable<T> iterable(Iterator<T> i) {
return new IteratorIterable<T>(i);
}
}
resource.allContents.iterable.filter(typeof(Greeting))
We should consider to have something like IteratorExtensions.
Furthermore it may be interesting to allow iterators in for loops, e.g.
for(something: somethingElse.eAllContents) {
..
}
similar to the things that are available in IterableExtensions or Iterators + Iterator.asIterable instead of for(e: iterator) I've pushed IteratorExtensions and it includes one extension so far: public static <T> Iterable<T> toIterable(final Iterator<T> iterator) Closing all bugs that were set to RESOLVED before Neon.0 Closing all bugs that were set to RESOLVED before Neon.0 |