Package org.omegazero.common.config
Class ConfigArray
java.lang.Object
org.omegazero.common.config.ConfigArray
- All Implemented Interfaces:
Serializable,Iterable<Object>
A read-only array of any type of data, providing a layer of abstraction for different data representations. Created by a
Configuration instance.- Since:
- 2.4
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates an emptyConfigArray.ConfigArray(int initialCapacity) Deprecated.ConfigArray(List<Object> data) Creates aConfigArraywith the given elements. -
Method Summary
Modifier and TypeMethodDescriptionclone()Returns a clone of thisConfigArray, which contains the same elements as thisConfigArray.booleanReturns whether the given element o is in thisConfigArray.booleancontainsAll(Collection<?> c) Returns whether all elements in the givenCollectionare contained in thisConfigArray.copyData()Creates a newArrayListwith all values of thisConfigArray.booleanDetermines whether the given object is equal to thisConfigArray.get(int index) Returns the element at the given position in thisConfigArray.inthashCode()Returns a hash code for thisConfigArray.intReturns the index of the given element.booleanisEmpty()Returns whether thisConfigArrayis empty.iterator()intReturns the last index of the given element.merge(ConfigArray other) Creates a newConfigArraythat contains all values of this and the givenConfigArray.intsize()Returns the number of elements in thisConfigArray.Object[]toArray()Converts thisConfigArrayto anObjectarray.<T> T[]Converts thisConfigArrayto an array of the given type.toString()Returns a string representation of thisConfigArray.Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
data
The data.
-
-
Constructor Details
-
ConfigArray
public ConfigArray()Creates an emptyConfigArray. -
ConfigArray
Deprecated.Creates aConfigArray.- Parameters:
initialCapacity- The number of elements
-
ConfigArray
Creates aConfigArraywith the given elements.Changes on the given list have no effects on this
ConfigArray.- Parameters:
data- The data
-
-
Method Details
-
copyData
Creates a newArrayListwith all values of thisConfigArray. Changes to the returned list have no effect on thisConfigArray.- Returns:
- A
Listwith all values of thisConfigArray
-
merge
Creates a newConfigArraythat contains all values of this and the givenConfigArray. Values of thisConfigArrayare added first, followed by values in the providedConfigArray.
Both provided objects stay unchanged.- Parameters:
other- TheConfigArrayto merge this one with- Returns:
- A new
ConfigArraywith all values of this and other
-
size
public int size()Returns the number of elements in thisConfigArray.- Returns:
- The number of elements
- See Also:
-
isEmpty
public boolean isEmpty()Returns whether thisConfigArrayis empty.- Returns:
trueif empty- See Also:
-
contains
Returns whether the given element o is in thisConfigArray.- Parameters:
o- The element to search- Returns:
trueif o exists- See Also:
-
toArray
Converts thisConfigArrayto anObjectarray.- Returns:
- The array containing all elements
- See Also:
-
toArray
Converts thisConfigArrayto an array of the given type.- Parameters:
type- The target type- Returns:
- The array containing all elements
- Throws:
ClassCastException- If any element in thisConfigArrayis not of the given type- Since:
- 2.11.0
- See Also:
-
containsAll
Returns whether all elements in the givenCollectionare contained in thisConfigArray.- Parameters:
c- The collection- Returns:
trueif all elements of the collection exist- See Also:
-
get
Returns the element at the given position in thisConfigArray.- Parameters:
index- The index- Returns:
- The element at the index
- See Also:
-
indexOf
Returns the index of the given element.- Parameters:
o- The element to search- Returns:
- The index of the element, or
-1if the element does not exist - See Also:
-
lastIndexOf
Returns the last index of the given element.- Parameters:
o- The element to search- Returns:
- The last index of the element, or
-1if the element does not exist - See Also:
-
iterator
-
equals
Determines whether the given object is equal to thisConfigArray.Another object is equal if it is also a
ConfigArrayand contains the same elements. -
hashCode
public int hashCode()Returns a hash code for thisConfigArray. -
clone
Returns a clone of thisConfigArray, which contains the same elements as thisConfigArray. -
toString
Returns a string representation of thisConfigArray.
-