Class Index<Target,TargetList extends HList.HCons<?,?>>
- java.lang.Object
-
- com.jnape.palatable.lambda.adt.hlist.Index<Target,TargetList>
-
- Type Parameters:
Target- the target element typeTargetList- type of compatible HList
public abstract class Index<Target,TargetList extends HList.HCons<?,?>> extends java.lang.ObjectHList indexes representing a value at arbitrary depth in some compatible HList. HList compatibility requires identical element types up to and including the target element, but thereafter is unconstrained in length and element type.
-
-
Constructor Summary
Constructors Modifier Constructor Description privateIndex()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <NewHead> Index<Target,HList.HCons<NewHead,? extends TargetList>>after()Nest this index deeper by one element.abstract Targetget(TargetList hList)Retrieve the value at this index in hList.static <Target> Index<Target,HList.HCons<Target,?>>index()Create a root index for a head value of typeTarget.abstract <L extends TargetList>
Lset(Target newElement, L hList)Set a new value of the same type at this index in anHList.
-
-
-
Method Detail
-
after
public final <NewHead> Index<Target,HList.HCons<NewHead,? extends TargetList>> after()
Nest this index deeper by one element.- Type Parameters:
NewHead- the type of the preceding element- Returns:
- an index at the same Target, nested one level deep
-
get
public abstract Target get(TargetList hList)
Retrieve the value at this index in hList.- Parameters:
hList- the hList- Returns:
- the value at this index
-
set
public abstract <L extends TargetList> L set(Target newElement, L hList)
Set a new value of the same type at this index in anHList.- Type Parameters:
L- the inferred tail type of the HList- Parameters:
newElement- the new valuehList- the HList- Returns:
- the updated HList
-
index
public static <Target> Index<Target,HList.HCons<Target,?>> index()
Create a root index for a head value of typeTarget.- Type Parameters:
Target- the type of the value to get- Returns:
- the root index
-
-