Class NumericArray

java.lang.Object
org.eso.ias.types.NumericArray

public class NumericArray extends Object
The array of numbers is backed by a ArrayList of Numbers. Objects of this class checks the type of the values set in the ArrayList NumericArray is immutable
  • Field Details

    • numericArrayType

      public final NumericArray.NumericArrayType numericArrayType
      The type of the items of the arrays
    • array

      public final List<? extends Number> array
      The not null immutable array of items
  • Constructor Details

    • NumericArray

      public NumericArray(NumericArray.NumericArrayType numericArrayType)
      Constructor with no elements in the array
      Parameters:
      numericArrayType - The type of the items of the arrays
    • NumericArray

      public NumericArray(NumericArray.NumericArrayType numericArrayType, List<? extends Number> elements)
      Constructor with a list of elements in the array
      Parameters:
      numericArrayType - The type of the items of the arrays
      elements - the elements in the array (can be null)
    • NumericArray

      public NumericArray(scala.collection.immutable.List<? extends scala.AnyVal> elements, NumericArray.NumericArrayType numericArrayType)
      Constructor with a scala list of elements in the array
      Parameters:
      elements - the elements in the array (can be null)
      numericArrayType - The type of the items of the arrays
  • Method Details

    • clear

      public NumericArray clear()
      Build and return a NumericArray with the same type and no elements
      Returns:
      a new empty NumericArray
    • add

      public NumericArray add(Number value)
      Return a new NumericArray with the passed value appended at the end of array of elements
      Parameters:
      value - the not null value to append to the arrays
      Returns:
      A NumericElement with the passed value appended
    • set

      public NumericArray set(int index, Number value)
      Return a new NumericArray with the passed value saved in the index position
      Parameters:
      index - The index in the arrays
      value - The value to set in the index position
      Throws:
      IndexOutOfBoundsException - - if the index is out of range (index < 0 || index > size())
    • get

      public Number get(int i)
      Return the element at the given position of the arrays
      Parameters:
      i - the index of the element to get
      Returns:
      The Number at the given position of the arrays
      See Also:
    • toArray

      public Number[] toArray()
      Returns:
      An array with all the elements in the ArrayList
    • toArrayOfLong

      public Long[] toArrayOfLong()
      Return the arrays as an array of Long Note that depending on the type of the array (DOUBLE for instance) the numbers of the returned array differ from the original (rounded)
      Returns:
      the array of Long
    • toArrayOfDouble

      public Double[] toArrayOfDouble()
      Return the arrays as an array of Double
      Returns:
      the array sof Double
    • size

      public int size()
      Returns:
      the number of element sin the arrays
      See Also:
    • isEmpty

      public boolean isEmpty()
      Returns:
      true if the array is empty, false otherwise
      See Also:
    • valueOf

      public static NumericArray valueOf(NumericArray.NumericArrayType type, String strValue)
      Builds ansd return a NumericArray of the given type by decoding the passed string. The items in the String must be separated by a coma.
      Parameters:
      type - The type of the arrays
      strValue - The string with the elements of the array
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • codeToString

      public String codeToString()
      Return the elements as a comma separated string of values
      Returns:
      A string with the values separated by a comma
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object