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 and Description |
---|
AddressView(Function<A,java.util.List<A>> split,
Function<java.util.List<A>,A> merge)
Constructs an address view.
|
Modifier and Type | Method and 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] ). |
public AddressView(Function<A,java.util.List<A>> split, Function<java.util.List<A>,A> merge)
split
- the address split functor (it splits an address into the fields).merge
- the address merge functor (it merges fields to produce the address).java.lang.IllegalArgumentException
- if split
or merge
is null.public java.util.List<A> getFields(A address)
address
- the address.java.lang.IllegalArgumentException
- if address
is null.public A getField(A address, int i)
address
- the address.i
- the field index.java.lang.IllegalArgumentException
- if address
is null.java.lang.IndexOutOfBoundsException
- if i
is out of bounds.public A getAddress(java.util.List<A> fields)
fields
- the fields.java.lang.IllegalArgumentException
- if fields
is null.public A getAddress(A tag, A index, A offset)
tag
- the tag.index
- the index.offset
- the offset.java.lang.IllegalArgumentException
- if index
, tag
or offset
is null.public A getTag(A address)
fields[0]
).address
- the address.java.lang.IllegalArgumentException
- if address
is null.public A getIndex(A address)
fields[1]
).address
- the address.java.lang.IllegalArgumentException
- if address
is null.