001package Torello.Java;
002
003import java.util.function.Consumer;
004import java.util.function.Supplier;
005
006/**
007 * Provides any method the ability to provide its users the ability to choose what kind of data
008 * structure should be used for returning the method's results.  Currently, this class is used as 
009 * a helper class for class {@link FileNode}
010 * 
011 * @param <INSERT_TYPE> Currently, the only class using {@code VarType} is class {@link FileNode}.
012 * Within class {@link FileNode}, this Type-Parameter, {@code 'INSERT_TYPE'}, is always assigned
013 * the value of class {@code 'FileNode'}
014 * 
015 * @param <RET_DATA_STRUCTURE> This Generic Type-Parameter provides a user the ability to specify
016 * any Method Return-Type needed / desired.  In class {@link FileNode}, for instance, this
017 * Type-Parameter is often assigned to things such as: {@code Stream<FileNode>},
018 * {@code Iterator<FileNode>} or even {@code String[]} - where each of the {@code String's} are
019 * actual File-Names as a {@code String}.
020 * 
021 * <BR /><BR />If this class {@code VarType} where used elsewhere, outside of {@code FileNode},
022 * then the Generic Type-Parameter {@code 'RET_DATA_STRUCTURE'} would allow a user to provide a
023 * means for his / her users to specify, exactly, any method's Return Type/Class.
024 * 
025 * @see FileNode
026 */
027public class VarType<RET_DATA_STRUCTURE, INSERT_TYPE>
028{
029    /** Accepts and inserts data into the data-structure. */
030    public final Consumer<INSERT_TYPE> inserter;
031
032    /** Performs any finalizations on the data-structure, and then returns it */
033    public final Supplier<RET_DATA_STRUCTURE> finisher;
034
035    /**
036     * Constructs an instance of this class
037     * @param inserter This is assigned to the field {@link #inserter}.
038     * @param finisher Assigned to field {@link #finisher}.
039     */
040    public VarType(Consumer<INSERT_TYPE> inserter, Supplier<RET_DATA_STRUCTURE> finisher)
041    { this.inserter=inserter; this.finisher=finisher; }
042}