Package Torello.Java.Additional
Class VarListBuilderWithSortAndApply<ORIGINAL,TRANSFORMED>
- java.lang.Object
-
- Torello.Java.Additional.VarListBuilderWithSortAndApply<ORIGINAL,TRANSFORMED>
-
- Type Parameters:
ORIGINAL
- This is the original data-type that is to be inserted into the list, after a simple transformation has been applied. For class this class, the sort is applied before the transformation.
Speaking from the perspective ofFileNode
andFileNode.RetTypeChoice
the'ORIGINAL'
type is always computed to be'FileNode'
.TRANSFORMED
- This is the data-type, after the transform has been applied. The list that's returned to the user will be a container / list whose contents have type'TRANSFORMED'
.
In the case ofFileNode
, andFileNode.RetTypeChoice
, the'TRANSFORMED'
type is usuallyjava.lang.String
- and theString
contents are the Full-Path File-Name, or the File-Name, itself.
public class VarListBuilderWithSortAndApply<ORIGINAL,TRANSFORMED> extends java.lang.Object
Implementation of theFileNode
class'RetTypeChoice'
.
Java HTML Library Helper for Torello.Java.FileNode
Currently, the only application for theVarList
User-Specified Variable Return Type Interface is for theFileNode
helper-class'RetTypeChoice'
.
This class could theoretically be used wherever there are many container-variants for the same set of identical-data being returned to a user.
This class will build an suite of implementations of theVarList
interface. This version provides the ability to sort and then transform the list-contents class / type.
Hi-Lited Source-Code:- View Here: Torello/Java/Additional/VarListBuilderWithSortAndApply.java
- Open New Browser-Tab: Torello/Java/Additional/VarListBuilderWithSortAndApply.java
-
-
Field Summary
Fields Modifier and Type Field VarList<TRANSFORMED[],ORIGINAL>
ARRAY
VarList<ArrayList<TRANSFORMED>,
ORIGINAL>ARRAYLIST
VarList<Iterator<TRANSFORMED>,
ORIGINAL>ITERATOR
VarList<LinkedList<TRANSFORMED>,
ORIGINAL>LINKEDLIST
VarList<Stack<TRANSFORMED>,
ORIGINAL>STACK
VarList<Stream<TRANSFORMED>,
ORIGINAL>STREAM
VarList<Stream.Builder<TRANSFORMED>,
ORIGINAL>STREAM_BUILDER
VarList<Vector<TRANSFORMED>,
ORIGINAL>VECTOR
-
Constructor Summary
Constructors Constructor VarListBuilderWithSortAndApply(Comparator<ORIGINAL> comparator, Function<ORIGINAL,TRANSFORMED> transformer, Class<TRANSFORMED> outputClass)
-
-
-
Field Detail
-
VECTOR
public final VarList<java.util.Vector<TRANSFORMED>,ORIGINAL> VECTOR
ThisVarList
instance has a'retrieve()'
method that will return aVector
whoseVector
-contents are of parametrized-type'TRANSFORMED'
. TheVector
returned will have already been sorted upon return.- Code:
- Exact Field Declaration Expression:
public final VarList<Vector<TRANSFORMED>, ORIGINAL> VECTOR;
-
ARRAYLIST
public final VarList<java.util.ArrayList<TRANSFORMED>,ORIGINAL> ARRAYLIST
ThisVarList
instance has a'retrieve()'
method that will return anArrayList
whoseArrayList
-contents are of parametrized-type'TRANSFORMED'
. TheArrayList
returned will have already been sorted upon return.- Code:
- Exact Field Declaration Expression:
public final VarList<ArrayList<TRANSFORMED>, ORIGINAL> ARRAYLIST;
-
ITERATOR
public final VarList<java.util.Iterator<TRANSFORMED>,ORIGINAL> ITERATOR
ThisVarList
instance has a'retrieve()'
method that will return anIterator
whoseIterator
-contents are of parametrized-type'TRANSFORMED'
. TheIterator
returned will have already been sorted upon return.- Code:
- Exact Field Declaration Expression:
public final VarList<Iterator<TRANSFORMED>, ORIGINAL> ITERATOR;
-
ARRAY
public final VarList<TRANSFORMED[],ORIGINAL> ARRAY
ThisVarList
instance has a'retrieve()'
method that will return anarray
whosearray
-contents are of parametrized-type'TRANSFORMED'
. Thearray
returned will have already been sorted upon return.- Code:
- Exact Field Declaration Expression:
public final VarList<TRANSFORMED[], ORIGINAL> ARRAY;
-
STREAM
public final VarList<java.util.stream.Stream<TRANSFORMED>,ORIGINAL> STREAM
ThisVarList
instance has a'retrieve()'
method that will return aStream
whoseStream
-contents are of parametrized-type'TRANSFORMED'
. TheStream
returned will have already been sorted upon return.- Code:
- Exact Field Declaration Expression:
public final VarList<Stream<TRANSFORMED>, ORIGINAL> STREAM;
-
STREAM_BUILDER
public final VarList<java.util.stream.Stream.Builder<TRANSFORMED>,ORIGINAL> STREAM_BUILDER
Instances ofStream.Builder
cannot be sorted. Only a builtStream
may be sorted. Therefore this parameter shall always be null.- Code:
- Exact Field Declaration Expression:
public final VarList<Stream.Builder<TRANSFORMED>, ORIGINAL> STREAM_BUILDER = null;
-
LINKEDLIST
public final VarList<java.util.LinkedList<TRANSFORMED>,ORIGINAL> LINKEDLIST
ThisVarList
instance has a'retrieve()'
method that will return aLinkedList
whoseLinkedList
-contents are of parametrized-type'TRANSFORMED'
. TheLinkedList
returned will have already been sorted upon return.- Code:
- Exact Field Declaration Expression:
public final VarList<LinkedList<TRANSFORMED>, ORIGINAL> LINKEDLIST;
-
STACK
public final VarList<java.util.Stack<TRANSFORMED>,ORIGINAL> STACK
ThisVarList
instance has a'retrieve()'
method that will return aStack
whoseStack
-contents are of parametrized-type'TRANSFORMED'
. TheStack
returned will have already been sorted upon return.- Code:
- Exact Field Declaration Expression:
public final VarList<Stack<TRANSFORMED>, ORIGINAL> STACK;
-
-
Constructor Detail
-
VarListBuilderWithSortAndApply
public VarListBuilderWithSortAndApply (java.util.Comparator<ORIGINAL> comparator, java.util.function.Function<ORIGINAL,TRANSFORMED> transformer, java.lang.Class<TRANSFORMED> outputClass)
Builds all 8 of theVarList's
provided by this builder class.- Parameters:
comparator
- This is used to sort the returned list.
NOTICE: The'comparator'
is of parametrized-type'ORIGINAL'
. This is because the sort shall occur BEFORE the transform.transformer
- Thistransform
is used to convert the contents of the returned list-type. As noticed by its type,'Function<ORIGINAL, TRANSFORMED>'
, the final type of the returnedVarList
will of type'TRANSFORMED'
, although while building this'VarList'
, the elements that shall be inserted will be of type'ORIGINAL'
.
It is the job of the transformer parameter to convert the elements from type'ORIGINAL'
to type'TRANSFORMED'
outputClass
- The final list that is built will be of typeclass U
. Because java generics use "Type Erasure," this class must be obtained here. It is used for array generation or array-construction.
-
-