org.joe_e.array
Class PowerlessArray<E>

java.lang.Object
  extended by org.joe_e.array.ConstArray<E>
      extended by org.joe_e.array.ImmutableArray<E>
          extended by org.joe_e.array.PowerlessArray<E>
Type Parameters:
E - the element type of objects contained in the array
All Implemented Interfaces:
Serializable, Iterable<E>, Immutable, Powerless, Selfless
Direct Known Subclasses:
BooleanArray, ByteArray, CharArray, DoubleArray, FloatArray, IntArray, LongArray, ShortArray

public class PowerlessArray<E>
extends ImmutableArray<E>
implements Powerless

An immutable array containing powerless objects.

See Also:
Serialized Form

Nested Class Summary
static class PowerlessArray.Builder<E>
          A PowerlessArray factory.
 
Method Summary
static
<T> PowerlessArray<T>
array()
          Construct an empty ConstArray.
static
<T> PowerlessArray<T>
array(T... values)
          Construct a PowerlessArray.
static
<T> PowerlessArray<T>
array(T value)
          Construct a ConstArray with one element.
static
<T> PowerlessArray<T>
array(T value1, T value2)
          Construct a ConstArray with two elements.
static
<T> PowerlessArray<T>
array(T value1, T value2, T value3)
          Construct an PowerlessArray with three elements.
static
<T> PowerlessArray<T>
array(T value1, T value2, T value3, T value4)
          Construct an PowerlessArray with four elements.
static
<E> PowerlessArray.Builder<E>
builder()
          Get a PowerlessArray.Builder.
static
<E> PowerlessArray.Builder<E>
builder(int estimate)
          Get a PowerlessArray.Builder.
 PowerlessArray<E> with(E newE)
          Return a new PowerlessArray that contains the same elements as this one but with a new element added to the end.
 PowerlessArray<E> without(int i)
          Return a new PowerlessArray that contains the same elements as this one excluding the element at a specified index
 
Methods inherited from class org.joe_e.array.ConstArray
equals, get, hashCode, iterator, length, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

array

public static <T> PowerlessArray<T> array(T... values)
Construct a PowerlessArray. The type will be

Parameters:
values - each value, or an array of values
Throws:
ClassCastException - if the runtime component type of values is not powerless in the overlay type system

array

public static <T> PowerlessArray<T> array()
Construct an empty ConstArray.


array

public static <T> PowerlessArray<T> array(T value)
Construct a ConstArray with one element.

Parameters:
value - the value

array

public static <T> PowerlessArray<T> array(T value1,
                                          T value2)
Construct a ConstArray with two elements.

Parameters:
value1 - the first value
value2 - the second value

array

public static <T> PowerlessArray<T> array(T value1,
                                          T value2,
                                          T value3)
Construct an PowerlessArray with three elements.

Parameters:
value1 - the first value
value2 - the second value
value3 - the third value

array

public static <T> PowerlessArray<T> array(T value1,
                                          T value2,
                                          T value3,
                                          T value4)
Construct an PowerlessArray with four elements.

Parameters:
value1 - the first value
value2 - the second value
value3 - the third value
value4 - the fourth value

with

public PowerlessArray<E> with(E newE)
Return a new PowerlessArray that contains the same elements as this one but with a new element added to the end.

Overrides:
with in class ImmutableArray<E>
Parameters:
newE - an element to add
Returns:
the new array
Throws:
ClassCastException - if newE is not powerless

without

public PowerlessArray<E> without(int i)
Return a new PowerlessArray that contains the same elements as this one excluding the element at a specified index

Overrides:
without in class ImmutableArray<E>
Parameters:
i - the index of the element to exclude
Returns:
the new array

builder

public static <E> PowerlessArray.Builder<E> builder()
Get a PowerlessArray.Builder. This is equivalent to the constructor.

Returns:
a new builder instance, with the default internal array length

builder

public static <E> PowerlessArray.Builder<E> builder(int estimate)
Get a PowerlessArray.Builder. This is equivalent to the constructor.

Parameters:
estimate - estimated array length
Returns:
a new builder instance