public class Values extends Object
Either an array or a list can be wrapped into a Values object. Accessing the elements of these data
structures is done via the at(..) methods which return the element wrapped as Value
.
This permits instant coercing and conversion capabilities for the returned element and also handles IndexOutOfBoundExceptions gracefully as simply an empty value is returned instead of throwing an exception.
Also this supports access via "Excel Style" column names ("A", "B", ..., "AH") which is beneficial when importing external data.
Modifier and Type | Method and Description |
---|---|
Value |
at(int index)
Returns the element at the (zero based) index wrapped as
Value
If the index is out of the valid range for the wrapped elements, an empty value will be returned |
Value |
at(String excelStyleIndex)
Returns the element at the given column in "Excel style" notation.
|
static int |
convertExcelColumn(String excelStyleIndex)
Converts an "Excel Style" column name into a zero based index
Therefore "A" will return 0.
|
int |
length()
Returns the number of elements in the underlying data structure
|
static Values |
of(List<?> list)
Creates a wrapper for the given list
|
static Values |
of(Object[] array)
Creates a wrapper for the given array
|
String |
toString() |
@Nonnull public static Values of(@Nonnull List<?> list)
list
- the list to wrap@Nonnull public static Values of(@Nonnull Object[] array)
array
- the array to wrap@Nonnull public Value at(int index)
Value
If the index is out of the valid range for the wrapped elements, an empty value will be returned
index
- the zero based index of the element to return@Nonnull public Value at(@Nonnull String excelStyleIndex)
Therefore "A" will return the first element (which is at index 0). "Z" will return the 26th element (at index 25). "AH" will return the 34th element (at index 33).
excelStyleIndex
- a column index in "Excel Notation" (A, B, ..., AA, AB, ...)public int length()
public static int convertExcelColumn(@Nonnull String excelStyleIndex)
Therefore "A" will return 0. "Z" will return 25 and AH will return 33.
excelStyleIndex
- a column index in "Excel Notation" (A, B, ..., AA, AB, ...)Copyright © 2018. All rights reserved.