trip.spi.helpers.SingleObjectIterable Maven / Gradle / Ivy
package trip.spi.helpers;
import java.util.Iterator;
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public class SingleObjectIterable implements Iterable {
final T object;
@Override
public Iterator iterator() {
return new SingleObjectIterator( object );
}
@RequiredArgsConstructor
public class SingleObjectIterator implements Iterator {
final T object;
boolean firstCall = true;
@Override
public boolean hasNext() {
boolean hasNext = firstCall;
if ( firstCall )
firstCall = false;
return hasNext;
}
@Override
public T next() {
return object;
}
@Override
public void remove() {
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy