All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cz.jalasoft.util.text.FragmentList Maven / Gradle / Ivy

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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy