org.joe_e.array
Class ConstArray.Builder<E>

java.lang.Object
  extended by org.joe_e.array.ConstArray.Builder<E>
All Implemented Interfaces:
ArrayBuilder<E>
Direct Known Subclasses:
ImmutableArray.Builder
Enclosing class:
ConstArray<E>

public static class ConstArray.Builder<E>
extends Object
implements ArrayBuilder<E>

A ConstArray factory.


Method Summary
 void append(E newE)
          Appends an element to the Array
 void append(E[] newEs)
          Appends all elements from a Java array to the Array
 void append(E[] newEs, int off, int len)
          Appends a range of elements from a Java array to the Array
 int length()
          Gets the current number of elements in the Array
 ConstArray<E> snapshot()
          Create a snapshot of the current content.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

append

public void append(E newE)
Appends an element to the Array

Specified by:
append in interface ArrayBuilder<E>
Parameters:
newE - the element to append
Throws:
NegativeArraySizeException - if the resulting internal array would exceed the maximum length of a Java array. The builder is unmodified.

append

public void append(E[] newEs)
Appends all elements from a Java array to the Array

Specified by:
append in interface ArrayBuilder<E>
Parameters:
newEs - the element to append
Throws:
IndexOutOfBoundsException - if the resulting internal array would exceed the maximum length of a Java array. The builder is unmodified.

append

public void append(E[] newEs,
                   int off,
                   int len)
Appends a range of elements from a Java array to the Array

Specified by:
append in interface ArrayBuilder<E>
Parameters:
newEs - the source array
off - the index of the first element to append
len - the number of elements to append
Throws:
IndexOutOfBoundsException - if an out-of-bounds index would be referenced or the resulting internal array would exceed the maximum length of a Java array. The builder is unmodified.

length

public int length()
Gets the current number of elements in the Array

Specified by:
length in interface ArrayBuilder<E>
Returns:
the number of elements that have been appended

snapshot

public ConstArray<E> snapshot()
Create a snapshot of the current content.

Specified by:
snapshot in interface ArrayBuilder<E>
Returns:
a ConstArray containing the elements so far