Class Index<Target,​TargetList extends HList.HCons<?,​?>>

  • Type Parameters:
    Target - the target element type
    TargetList - type of compatible HList
    Direct Known Subclasses:
    Index.N, Index.Z

    public abstract class Index<Target,​TargetList extends HList.HCons<?,​?>>
    extends java.lang.Object
    HList 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 Detail

      • Index

        private Index()
    • 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 an HList.
        Type Parameters:
        L - the inferred tail type of the HList
        Parameters:
        newElement - the new value
        hList - 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 type Target.
        Type Parameters:
        Target - the type of the value to get
        Returns:
        the root index