Interface Holder<T>


public interface Holder<T>
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns true if this holder has an id.
    int
    id()
    Returns the id of this holder, or -1 if this holder is direct.
    boolean
    Returns true if this holder is backed by a direct value.
    static <T> Holder<T>
    of(int id)
    Returns an indirect id holder.
    static <T> Holder<T>
    of(T value)
    Returns a direct value holder.
    updateId(it.unimi.dsi.fastutil.ints.Int2IntFunction rewriteFunction)
    Returns a new holder with the id rewritten using the given function, or self if this is a direct holder or the id did not change.
    Returns the value of this holder.
  • Method Details

    • of

      static <T> Holder<T> of(int id)
      Returns an indirect id holder.
      Type Parameters:
      T - the type of the value
      Parameters:
      id - the id
      Returns:
      a new holder with the given id
      Throws:
      IllegalArgumentException - if the id is negative
    • of

      static <T> Holder<T> of(T value)
      Returns a direct value holder.
      Type Parameters:
      T - the type of the value
      Parameters:
      value - the value
      Returns:
      a new direct holder
    • isDirect

      boolean isDirect()
      Returns true if this holder is backed by a direct value.
      Returns:
      true if the holder is direct
      See Also:
    • hasId

      boolean hasId()
      Returns true if this holder has an id.
      Returns:
      true if this holder has an id
      See Also:
    • value

      T value()
      Returns the value of this holder.
      Returns:
      the value of this holder
      Throws:
      IllegalArgumentException - if this holder is not direct
      See Also:
    • id

      int id()
      Returns the id of this holder, or -1 if this holder is direct.
      Returns:
      the id of this holder, or -1 if this holder is direct
      See Also:
    • updateId

      Holder<T> updateId(it.unimi.dsi.fastutil.ints.Int2IntFunction rewriteFunction)
      Returns a new holder with the id rewritten using the given function, or self if this is a direct holder or the id did not change.
      Parameters:
      rewriteFunction - the function to rewrite the id
      Returns:
      a new holder with the id rewritten, or self