Class ArrayModule<T>

java.lang.Object
com.github.collinalpert.java2db.modules.ArrayModule<T>
Type Parameters:
T - The type of the array.

public class ArrayModule<T>
extends java.lang.Object
A helper module to work with arrays and especially adding elements to them.
Author:
Collin Alpert
  • Constructor Summary

    Constructors 
    Constructor Description
    ArrayModule​(java.lang.Class<T> clazz, int chunkSize)  
  • Method Summary

    Modifier and Type Method Description
    void addElement​(T element)
    Adds an element to the array.
    T[] getArray()
    Gets an array with all the elements that were added to it.

    Methods inherited from class java.lang.Object

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

    • ArrayModule

      public ArrayModule​(java.lang.Class<T> clazz, int chunkSize)
  • Method Details

    • getArray

      public T[] getArray()
      Gets an array with all the elements that were added to it. Should there be excess slots from when the array was extended to fit more elements, they will be trimmed away.
      Returns:
      An array containing the added elements.
    • addElement

      public void addElement​(T element)
      Adds an element to the array. When the max size of the array is reached, it is extended by the specified chunkSize in the constructor.
      Parameters:
      element - The element to add to the array.