cz.jalasoft.util.text.FragmentList Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of JalasoftUtils Show documentation
Show all versions of JalasoftUtils Show documentation
A collection of utility classes that might be useful.
The newest version!
package cz.jalasoft.util.text;
import java.util.Iterator;
import java.util.List;
/**
* Created by honzales on 18.4.15.
*/
public final class FragmentList implements Iterable {
private final List collection;
FragmentList(List collection) {
this.collection = collection;
}
public boolean isEmpty() {
return collection.isEmpty();
}
@Override
public Iterator iterator() {
return collection.iterator();
}
public T first() {
if (collection.isEmpty()) {
throw new IllegalStateException("Fragment list is empty.");
}
return collection.get(0);
}
public boolean hasJustOneFragment() {
return size() == 1;
}
public int size() {
return collection.size();
}
public T get(int index) {
return collection.get(index);
}
}