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

jdbi_modules.Collector Maven / Gradle / Ivy

The newest version!
package jdbi_modules;

import org.jdbi.v3.core.mapper.RowMapper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.sql.SQLException;
import java.util.Collection;
import java.util.function.BiFunction;
import java.util.function.Consumer;

/**
 * @param  the collection type
 * @param            the type of the elements of the collection
 * @since 14.04.2018
 */
public interface Collector, Type> {
    /**
     * @return the collection currently stored in the collector
     */
    CollectionType get();

    /**
     * @param comparator the comparator to use
     * @return this
     */
    Collector setComparator(@NotNull BiFunction comparator);

    /**
     * Appends an object to the collection if it's not already contained in the collection,
     * and applies the function on the added or found object.
     *
     * @param type    the object to append
     * @param applier a consumer to apply on the accessed object
     * @return this
     */
    Collector appendUnique(@Nullable Type type, @NotNull Consumer applier);

    /**
     * Appends an object to the collection if it's not already contained in the collection.
     *
     * @param type the object to append
     * @return this
     */
    Collector appendUnique(@Nullable Type type);

    /**
     * Appends an object to the collection and applies the function on the added object.
     *
     * @param type    the object to append
     * @param applyer a consumer to apply on the object
     * @return this
     */
    Collector append(@Nullable Type type, @NotNull Consumer applyer);

    /**
     * Appends an object to the collection.
     *
     * @param type the object to append
     * @return this
     */
    Collector append(@Nullable Type type);

    /**
     * Appends an object fetched from the row-view to the collection if it's not already contained in the collection,
     * and applies the function on the added or found object.
     *
     * @param clazz   type of the row-mapper to use
     * @param applier a consumer to apply on the accessed object
     * @return this
     */
    Collector appendUniqueWithRowView(@NotNull Class clazz, @NotNull Consumer applier);

    /**
     * Appends an object fetched from the row-view to the collection if it's not already contained in the collection.
     *
     * @param clazz type of the row-mapper to use
     * @return this
     */
    Collector appendUniqueWithRowView(@NotNull Class clazz);

    /**
     * Appends an object fetched from the row-view to the collection and applies the function on the added object.
     *
     * @param clazz   type of the row-mapper to use
     * @param applier a consumer to apply on the added object
     * @return this
     */
    Collector appendWithRowView(@NotNull Class clazz, @NotNull Consumer applier);

    /**
     * Appends an object fetched from the row-view to the collection.
     *
     * @param clazz type of the row-mapper to use
     * @return this
     */
    Collector appendWithRowView(@NotNull Class clazz);

    /**
     * Appends an object fetched from the row-mapper to the collection if it's not already contained in the collection,
     * and applies the function on the added or found object.
     *
     * @param rowMapper type of the row-mapper to use
     * @param applier   a consumer to apply on the accessed object
     * @return this
     * @throws SQLException a possible exception during the mapping
     */
    Collector appendUniqueWithRowMapper(@NotNull RowMapper rowMapper, @NotNull Consumer applier) throws SQLException;

    /**
     * Appends an object fetched from the row-mapper to the collection if it's not already contained in the collection.
     *
     * @param rowMapper the row-mapper to use
     * @return this
     * @throws SQLException a possible exception during the mapping
     */
    Collector appendUniqueWithRowMapper(@NotNull RowMapper rowMapper) throws SQLException;

    /**
     * Appends an object fetched from the row-mapper to the collection and applies the function on the added object.
     *
     * @param rowMapper the row-mapper to use
     * @param applier   a consumer to apply on the accessed object
     * @return this
     * @throws SQLException a possible exception during the mapping
     */
    Collector appendWithRowMapper(@NotNull RowMapper rowMapper, @NotNull Consumer applier) throws SQLException;

    /**
     * Appends an object fetched from the row-mapper to the collection.
     *
     * @param rowMapper row-mapper to use
     * @return this
     * @throws SQLException a possible exception during the mapping
     */
    Collector appendWithRowMapper(@NotNull RowMapper rowMapper) throws SQLException;
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy