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 aConfigArray
with the given elements. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Returns a clone of thisConfigArray
, which contains the same elements as thisConfigArray
.boolean
Returns whether the given element o is in thisConfigArray
.boolean
containsAll
(Collection<?> c) Returns whether all elements in the givenCollection
are contained in thisConfigArray
.copyData()
Creates a newArrayList
with all values of thisConfigArray
.boolean
Determines whether the given object is equal to thisConfigArray
.get
(int index) Returns the element at the given position in thisConfigArray
.int
hashCode()
Returns a hash code for thisConfigArray
.int
Returns the index of the given element.boolean
isEmpty()
Returns whether thisConfigArray
is empty.iterator()
int
Returns the last index of the given element.merge
(ConfigArray other) Creates a newConfigArray
that contains all values of this and the givenConfigArray
.int
size()
Returns the number of elements in thisConfigArray
.Object[]
toArray()
Converts thisConfigArray
to anObject
array.<T> T[]
Converts thisConfigArray
to 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, wait
Methods 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 aConfigArray
with the given elements.Changes on the given list have no effects on this
ConfigArray
.- Parameters:
data
- The data
-
-
Method Details
-
copyData
Creates a newArrayList
with all values of thisConfigArray
. Changes to the returned list have no effect on thisConfigArray
.- Returns:
- A
List
with all values of thisConfigArray
-
merge
Creates a newConfigArray
that contains all values of this and the givenConfigArray
. Values of thisConfigArray
are added first, followed by values in the providedConfigArray
.
Both provided objects stay unchanged.- Parameters:
other
- TheConfigArray
to merge this one with- Returns:
- A new
ConfigArray
with 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 thisConfigArray
is empty.- Returns:
true
if empty- See Also:
-
contains
Returns whether the given element o is in thisConfigArray
.- Parameters:
o
- The element to search- Returns:
true
if o exists- See Also:
-
toArray
Converts thisConfigArray
to anObject
array.- Returns:
- The array containing all elements
- See Also:
-
toArray
Converts thisConfigArray
to an array of the given type.- Parameters:
type
- The target type- Returns:
- The array containing all elements
- Throws:
ClassCastException
- If any element in thisConfigArray
is not of the given type- Since:
- 2.11.0
- See Also:
-
containsAll
Returns whether all elements in the givenCollection
are contained in thisConfigArray
.- Parameters:
c
- The collection- Returns:
true
if 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
-1
if 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
-1
if 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
ConfigArray
and 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
.
-