Class LongPrimitives

java.lang.Object
com.illumon.iris.libs.primitives.LongPrimitives

public class LongPrimitives extends Object
A set of commonly used functions that can be applied to Long types.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    array(long[] values)
    Converts a primitive array to a DB array.
    static long[]
    concat(long[]... values)
    Returns the concatenation of multiple arrays into a single array.
    static long[]
    concat(DbLongArray... values)
    Returns the concatenation of multiple arrays into a single array.
    static int
    count(long[] values)
    Counts the number of non-null values.
    static int
    Counts the number of non-null values.
    static int
    count(Long[] values)
    Counts the number of non-null values.
    static long
    countDistinct(long[] values)
    Counts the number of distinct elements in the array.
    static long
    countDistinct(long[] values, boolean countNull)
    Counts the number of distinct elements in the array.
    static long
    Counts the number of distinct elements in the array.
    static long
    countDistinct(DbLongArray values, boolean countNull)
    Counts the number of distinct elements in the array.
    static long[]
    distinct(long[] values)
    Returns an array containing only the distinct values from the input.
    static long[]
    distinct(long[] values, boolean includeNull, boolean sort)
    Returns an array containing only the distinct values from the input.
    Returns an array containing only the distinct values from the input.
    distinct(DbLongArray values, boolean includeNull, boolean sort)
    Returns an array containing only the distinct values from the input.
    static long[]
    enlist(long... values)
    Returns a list containing its arguments.
    static long
    first(long[] values)
    Returns the first value from an array.
    static long
    Returns the first value from an array.
    static long[]
    forwardFill(long[] values)
     
    static boolean
    in(long testedValues, long... possibleValues)
    Checks if a value is within a discrete set of possible values.
    static boolean
    inRange(long testedValue, long lowInclusiveValue, long highInclusiveValue)
    Checks if a value is within a range.
    static boolean
    isNull(long value)
    Determines if a value is null.
    static long
    last(long[] values)
    Returns the last value from an array.
    static long
    last(DbLongArray values)
    Returns the last value from an array.
    static long
    nth(int index, long[] values)
    Returns the nth value from an array.
    static long
    nth(int index, DbLongArray values)
    Returns the nth value from an array.
    static long[]
    nullToValue(long[] values, long defaultValue)
    Replaces null values with a default value.
    static long
    nullToValue(long value, long defaultValue)
    Replaces null values with a default value.
    static long[]
    nullToValue(DbLongArray values, long defaultValue)
    Replaces null values with a default value.
    static long[]
    repeat(long value, int size)
    Returns an array with a value repeated.
    static long[]
    reverse(long... values)
    Returns an array with the values reversed.
    static long[]
    Returns an array with the values reversed.
    static long[]
    unbox(Long... values)
    Unboxes a array of values.
    static long
    uniqueValue(DbLongArray arr, boolean countNull)
    Get the single unique value in the array, or null if there are none, or there are more than 1 distinct values.
    static long[]
    vec(DbLongArray values)
    Converts a DB array to a primitive array.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LongPrimitives

      public LongPrimitives()
  • Method Details

    • unbox

      public static long[] unbox(Long... values)
      Unboxes a array of values.
      Parameters:
      values - values.
      Returns:
      unboxed array of values.
    • isNull

      public static boolean isNull(long value)
      Determines if a value is null.
      Parameters:
      value - value.
      Returns:
      true if the value is null, and false otherwise.
    • nullToValue

      public static long nullToValue(long value, long defaultValue)
      Replaces null values with a default value.
      Parameters:
      value - value.
      defaultValue - default value to return for null values.
      Returns:
      value, if value is not null, and defaultValue if value is null.
    • nullToValue

      public static long[] nullToValue(long[] values, long defaultValue)
      Replaces null values with a default value.
      Parameters:
      values - values.
      defaultValue - default value to return for null values.
      Returns:
      values with nulls replaced by defaultValue.
    • nullToValue

      public static long[] nullToValue(DbLongArray values, long defaultValue)
      Replaces null values with a default value.
      Parameters:
      values - values.
      defaultValue - default value to return for null values.
      Returns:
      values with nulls replaced by defaultValue.
    • count

      public static int count(Long[] values)
      Counts the number of non-null values.
      Parameters:
      values - values.
      Returns:
      number of non-null values.
    • count

      public static int count(long[] values)
      Counts the number of non-null values.
      Parameters:
      values - values.
      Returns:
      number of non-null values.
    • count

      public static int count(DbLongArray values)
      Counts the number of non-null values.
      Parameters:
      values - values.
      Returns:
      number of non-null values.
    • last

      public static long last(DbLongArray values)
      Returns the last value from an array.
      Parameters:
      values - values.
      Returns:
      last value from the array.
    • last

      public static long last(long[] values)
      Returns the last value from an array.
      Parameters:
      values - values.
      Returns:
      last value from the array.
    • first

      public static long first(DbLongArray values)
      Returns the first value from an array.
      Parameters:
      values - values.
      Returns:
      first value from the array.
    • first

      public static long first(long[] values)
      Returns the first value from an array.
      Parameters:
      values - values.
      Returns:
      first value from the array.
    • nth

      public static long nth(int index, DbLongArray values)
      Returns the nth value from an array.
      Parameters:
      index - index of the value to return.
      values - values.
      Returns:
      nth value from the array or null, if the index is outside of the array's index range.
    • nth

      public static long nth(int index, long[] values)
      Returns the nth value from an array.
      Parameters:
      index - index of the value to return.
      values - values.
      Returns:
      nth value from the array or null, if the index is outside of the array's index range.
    • vec

      public static long[] vec(DbLongArray values)
      Converts a DB array to a primitive array.
      Parameters:
      values - DB array
      Returns:
      primitive array.
    • array

      public static DbLongArray array(long[] values)
      Converts a primitive array to a DB array.
      Parameters:
      values - primitive array
      Returns:
      DB array.
    • inRange

      public static boolean inRange(long testedValue, long lowInclusiveValue, long highInclusiveValue)
      Checks if a value is within a range.
      Parameters:
      testedValue - tested value.
      lowInclusiveValue - lower inclusive bound of the range.
      highInclusiveValue - upper inclusive bound of the range.
      Returns:
      true if the tested value is within the range, and false if the tested value is not in the range or is null.
    • in

      public static boolean in(long testedValues, long... possibleValues)
      Checks if a value is within a discrete set of possible values.
      Parameters:
      testedValues - tested value.
      possibleValues - possible values.
      Returns:
      true if the tested value is contained in the possible values, and false otherwise.
    • countDistinct

      public static long countDistinct(long[] values)
      Counts the number of distinct elements in the array.
      Parameters:
      values - values.
      Returns:
      number of distinct non-null values.
    • countDistinct

      public static long countDistinct(DbLongArray values)
      Counts the number of distinct elements in the array.
      Parameters:
      values - values.
      Returns:
      number of distinct non-null values.
    • countDistinct

      public static long countDistinct(long[] values, boolean countNull)
      Counts the number of distinct elements in the array.
      Parameters:
      values - values.
      countNull - true to count null values, and false to exclude null values.
      Returns:
      number of distinct values.
    • countDistinct

      public static long countDistinct(DbLongArray values, boolean countNull)
      Counts the number of distinct elements in the array.
      Parameters:
      values - values.
      countNull - true to count null values, and false to exclude null values.
      Returns:
      number of distinct values.
    • uniqueValue

      public static long uniqueValue(DbLongArray arr, boolean countNull)
      Get the single unique value in the array, or null if there are none, or there are more than 1 distinct values.
      Parameters:
      arr - the array
      countNull - if nulls should count as values
      Returns:
      the single unique value in the array, or null.
    • distinct

      public static long[] distinct(long[] values)
      Returns an array containing only the distinct values from the input.
      Parameters:
      values - values.
      Returns:
      unsorted array containing only distinct non-null items from arr.
    • distinct

      public static DbLongArray distinct(DbLongArray values)
      Returns an array containing only the distinct values from the input.
      Parameters:
      values - values.
      Returns:
      unsorted array containing only distinct non-null items from arr.
    • distinct

      public static long[] distinct(long[] values, boolean includeNull, boolean sort)
      Returns an array containing only the distinct values from the input.
      Parameters:
      values - values.
      includeNull - true to include null values, and false to exclude null values.
      sort - true to sort the resultant array
      Returns:
      array containing only distinct items from arr.
    • distinct

      public static DbLongArray distinct(DbLongArray values, boolean includeNull, boolean sort)
      Returns an array containing only the distinct values from the input.
      Parameters:
      values - values.
      includeNull - true to include null values, and false to exclude null values.
      sort - true to sort the resultant array
      Returns:
      array containing only distinct items from arr.
    • repeat

      public static long[] repeat(long value, int size)
      Returns an array with a value repeated.
      Parameters:
      value - value.
      size - number of times to repeat the value.
      Returns:
      array of repeated values. If size is less than zero, an empty array is returned.
    • enlist

      public static long[] enlist(long... values)
      Returns a list containing its arguments.
      Parameters:
      values - values.
      Returns:
      list containing values.
    • concat

      public static long[] concat(long[]... values)
      Returns the concatenation of multiple arrays into a single array.
      Parameters:
      values - values.
      Returns:
      concatenation of multiple arrays into a single array.
    • concat

      public static long[] concat(DbLongArray... values)
      Returns the concatenation of multiple arrays into a single array.
      Parameters:
      values - values.
      Returns:
      concatenation of multiple arrays into a single array.
    • reverse

      public static long[] reverse(long... values)
      Returns an array with the values reversed.
      Parameters:
      values - values.
      Returns:
      array with the values reversed.
    • reverse

      public static long[] reverse(DbLongArray values)
      Returns an array with the values reversed.
      Parameters:
      values - values.
      Returns:
      array with the values reversed.
    • forwardFill

      public static long[] forwardFill(long[] values)