Class AddressView<A>

  • Type Parameters:
    A - address type.

    public final class AddressView<A>
    extends java.lang.Object
    AddressView implements an address view, i.e. a set of methods for composing/decomposing address into fields.
    • Constructor Summary

      Constructors 
      Constructor Description
      AddressView​(Function<A,​java.util.List<A>> split, Function<java.util.List<A>,​A> merge)
      Constructs an address view.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      A getAddress​(A tag, A index, A offset)
      Returns the address to the given tag, index and offset.
      A getAddress​(java.util.List<A> fields)
      Returns the address for the given fields.
      A getField​(A address, int i)
      Returns the field of the address.
      java.util.List<A> getFields​(A address)
      Returns the fields of the address.
      A getIndex​(A address)
      Returns the index of the given address (fields[1]).
      A getOffset​(A address)
      Returns the offset of the given address (fields[2]).
      A getTag​(A address)
      Returns the tag of the given address (fields[0]).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AddressView

        public AddressView​(Function<A,​java.util.List<A>> split,
                           Function<java.util.List<A>,​A> merge)
        Constructs an address view.
        Parameters:
        split - the address split functor (it splits an address into the fields).
        merge - the address merge functor (it merges fields to produce the address).
        Throws:
        java.lang.IllegalArgumentException - if split or merge is null.
    • Method Detail

      • getFields

        public java.util.List<A> getFields​(A address)
        Returns the fields of the address.
        Parameters:
        address - the address.
        Returns:
        the list of fields.
        Throws:
        java.lang.IllegalArgumentException - if address is null.
      • getField

        public A getField​(A address,
                          int i)
        Returns the field of the address.
        Parameters:
        address - the address.
        i - the field index.
        Returns:
        the list of fields.
        Throws:
        java.lang.IllegalArgumentException - if address is null.
        java.lang.IndexOutOfBoundsException - if i is out of bounds.
      • getAddress

        public A getAddress​(java.util.List<A> fields)
        Returns the address for the given fields.
        Parameters:
        fields - the fields.
        Returns:
        the address.
        Throws:
        java.lang.IllegalArgumentException - if fields is null.
      • getAddress

        public A getAddress​(A tag,
                            A index,
                            A offset)
        Returns the address to the given tag, index and offset.
        Parameters:
        tag - the tag.
        index - the index.
        offset - the offset.
        Returns:
        the address.
        Throws:
        java.lang.IllegalArgumentException - if index, tag or offset is null.
      • getTag

        public A getTag​(A address)
        Returns the tag of the given address (fields[0]).
        Parameters:
        address - the address.
        Returns:
        the tag.
        Throws:
        java.lang.IllegalArgumentException - if address is null.
      • getIndex

        public A getIndex​(A address)
        Returns the index of the given address (fields[1]).
        Parameters:
        address - the address.
        Returns:
        the index.
        Throws:
        java.lang.IllegalArgumentException - if address is null.
      • getOffset

        public A getOffset​(A address)
        Returns the offset of the given address (fields[2]).
        Parameters:
        address - the address.
        Returns:
        the offset.
        Throws:
        java.lang.IllegalArgumentException - if address is null.