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

org.seedstack.business.pagination.Slice Maven / Gradle / Ivy

/*
 * Copyright © 2013-2024, The SeedStack authors 
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
package org.seedstack.business.pagination;

import java.util.Iterator;
import java.util.List;
import java.util.Spliterator;
import java.util.function.Consumer;

/**
 * A slice of contiguous items taken from a bigger list.
 *
 * @param  the item type
 */
public interface Slice extends Iterable {

    /**
     * Return items contained in the slice.
     *
     * @return the items.
     */
    List getItems();

    /**
     * Returns the size of the slice.
     *
     * @return the number of items.
     */
    long getSize();

    @Override
    default Iterator iterator() {
        return getItems().iterator();
    }

    @Override
    default void forEach(Consumer action) {
        getItems().forEach(action);
    }

    @Override
    default Spliterator spliterator() {
        return getItems().spliterator();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy