ref_send API 2.17
defensive programming in Java

org.joe_e.array
Class ShortArray

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<java.lang.Short>
              extended by org.joe_e.array.ShortArray
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<java.lang.Short>, Immutable, Powerless, Selfless

public final class ShortArray
extends PowerlessArray<java.lang.Short>

An immutable array of short.

See Also:
Serialized Form

Nested Class Summary
static class ShortArray.Builder
          A ShortArray factory.
 
Method Summary
static ShortArray array()
          Construct an empty ShortArray
static ShortArray array(short... shorts)
          Constructs an array of shorts.
static ShortArray array(short value)
          Construct a ShortArray with one element.
static ShortArray array(short value1, short value2)
          Construct a ShortArray with two elements.
static ShortArray array(short value1, short value2, short value3)
          Construct a ShortArray with three elements.
static ShortArray array(short value1, short value2, short value3, short value4)
          Construct a ShortArray with four elements.
static ShortArray.Builder builder()
          Get a ShortArray.Builder.
static ShortArray.Builder builder(int estimate)
          Get a ShortArray.Builder.
 boolean equals(java.lang.Object other)
          Test for equality with another object
 java.lang.Short get(int i)
          Creates a Short for a specified short.
 short getShort(int i)
          Gets the short at a specified position.
 int hashCode()
          Computes a digest of the array for hashing.
 int length()
          Gets the length of the array.
<T> T[]
toArray(T[] prototype)
          Return a mutable copy of the array
 short[] toShortArray()
          Creates a mutable copy of the short array
 java.lang.String toString()
          Return a string representation of the array
 ShortArray with(short newShort)
          Creates a ShortArray with an appended short.
 ShortArray with(java.lang.Short newShort)
          Creates a ShortArray with an appended Short.
 ShortArray without(int i)
          Return a new ShortArray that contains the same elements as this one excluding the element at a specified index
 
Methods inherited from class org.joe_e.array.PowerlessArray
array
 
Methods inherited from class org.joe_e.array.ConstArray
iterator
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

array

public static ShortArray array(short... shorts)
Constructs an array of shorts.

Parameters:
shorts - each element

array

public static ShortArray array()
Construct an empty ShortArray


array

public static ShortArray array(short value)
Construct a ShortArray with one element.

Parameters:
value - the value

array

public static ShortArray array(short value1,
                               short value2)
Construct a ShortArray with two elements.

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

array

public static ShortArray array(short value1,
                               short value2,
                               short value3)
Construct a ShortArray with three elements.

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

array

public static ShortArray array(short value1,
                               short value2,
                               short value3,
                               short value4)
Construct a ShortArray with four elements.

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

equals

public boolean equals(java.lang.Object other)
Test for equality with another object

Overrides:
equals in class ImmutableArray<java.lang.Short>
Returns:
true if the other object is a ConstArray with the same contents as this array

hashCode

public int hashCode()
Computes a digest of the array for hashing. The hash code is the same as Arrays.hashCode(Object[]) called on a Java array containing the same elements.

Specified by:
hashCode in interface Selfless
Overrides:
hashCode in class ConstArray<java.lang.Short>
Returns:
a hash code based on the contents of this array

toString

public java.lang.String toString()
Return a string representation of the array

Overrides:
toString in class ConstArray<java.lang.Short>
Returns:
a string representation of this array

length

public int length()
Gets the length of the array.

Overrides:
length in class ConstArray<java.lang.Short>

get

public java.lang.Short get(int i)
Creates a Short for a specified short.

Overrides:
get in class ConstArray<java.lang.Short>
Parameters:
i - position of the element to return
Throws:
java.lang.ArrayIndexOutOfBoundsException - i is out of bounds

toArray

public <T> T[] toArray(T[] prototype)
Return a mutable copy of the array

Overrides:
toArray in class ConstArray<java.lang.Short>
Parameters:
prototype - prototype of the array to copy into
Returns:
an array containing the contents of this ConstArray of the same type as prototype
Throws:
java.lang.ArrayStoreException - if an element cannot be stored in the array

with

public ShortArray with(java.lang.Short newShort)
Creates a ShortArray with an appended Short.

Overrides:
with in class PowerlessArray<java.lang.Short>
Parameters:
newShort - the element to append
Returns:
the new array
Throws:
java.lang.NullPointerException - newShort is null

getShort

public short getShort(int i)
Gets the short at a specified position.

Parameters:
i - position of the element to return
Throws:
java.lang.ArrayIndexOutOfBoundsException - i is out of bounds

toShortArray

public short[] toShortArray()
Creates a mutable copy of the short array


with

public ShortArray with(short newShort)
Creates a ShortArray with an appended short.

Parameters:
newShort - the element to append

without

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

Overrides:
without in class PowerlessArray<java.lang.Short>
Parameters:
i - the index of the element to exclude
Returns:
the new array

builder

public static ShortArray.Builder builder()
Get a ShortArray.Builder. This is equivalent to the constructor.

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

builder

public static ShortArray.Builder builder(int estimate)
Get a ShortArray.Builder. This is equivalent to the constructor.

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

ref_send API 2.17
defensive programming in Java

Submit a bug or feature, or get help

Copyright 1998-2009 Waterken Inc. under the terms of the MIT X license.