T
- The type managed by the Header
.org.refcodes.mixin.Clearable
, Collection<T>
, ColumnRow<T,C>
, HeaderRow<T,Column<? extends T>>
, Iterable<T>
, org.refcodes.struct.Keys<T,C>
, org.refcodes.struct.Keys.MutableKeys<T,C>
, List<T>
HeaderImpl
public interface Header<T> extends HeaderRow<T,Column<? extends T>>
Column
instances, for example describing the elements of a
CSV file (visually speaking the of the CSV file's header line), is
represented by the Header
. The
Header
preserves an order for a list of
Column
instances. A
Header
provides the semantics for related
Row
instances.
The Keys.keySet()
method must provide a predictable order as ensured by
the LinkedHashSet
class as of the ordered nature of the
Header
.
Modifier and Type | Method | Description |
---|---|---|
default T |
get(Row<T> aRow,
String aKey) |
|
default boolean |
isEqualWith(Record<?> aRecord) |
|
default boolean |
isEqualWith(Row<?> aRow) |
|
default boolean |
isSubsetOf(Record<?> aRecord) |
|
default boolean |
isSubsetOf(Row<?> aRow) |
|
default boolean |
isSupersetOf(Record<?> aRecord) |
|
default boolean |
isSupersetOf(Row<?> aRow) |
|
default <REC> Record<REC> |
toIntersection(Record<REC> aRecord) |
|
default String[] |
toKeys() |
Returns the keys of the
Header in the intended order. |
default <REC> Record<REC> |
toSubset(Record<REC> aRecord) |
|
default Class<T> |
toType() |
|
default T[] |
toValues(Record<T> aRecord) |
Returns an array of the values stored by the
Record in the order
as defined by the header. |
parallelStream, removeIf, stream
containsValue, withColumns
fromStorageString, fromStorageString, fromStorageStringRecord, fromStorageStringRow, fromStorageStrings, fromStorageStrings, fromStorageStringsRecord, fromStorageStringsRow, indexOf, toPrintable, toPrintable, toPrintableRecord, toPrintableRow, toRecord, toRecordIgnoreType, toRow, toRowIgnoreType, toStorageString, toStorageString, toStorageStringRecord, toStorageStringRow, toStorageStrings, toStorageStrings, toStorageStringsRecord, toStorageStringsRow
containsKey, get, getOr, keySet, use, values
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, of, of, of, of, of, of, of, of, of, of, of, of, remove, remove, removeAll, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray
default T get(Row<T> aRow, String aKey) throws HeaderMismatchException, ColumnMismatchException
Row
by taking the index of
the according column of this Header
of the given key (the one
with the given key) and returns that value. This is possible as the
values in the row and in the header have an order. This method is a
convenience delegate to Row.get(Header, String)
.aRow
- The Row
containing the value of the given key.aKey
- The key for which to retrieve the value.HeaderMismatchException
- Thrown in case there is a mismatch
between the given HeaderMismatchException
and the
Row
, i.e. the index for the given key in the header may
be out of index of the given row or the given key does not exist
in the Header
.ColumnMismatchException
- in case the type defined in the column
for that key does not match the type in the row identified by the
given key.default String[] toKeys()
Header
in the intended order.Header
in correct order.default T[] toValues(Record<T> aRecord)
Record
in the order
as defined by the header.aRecord
- The Record
to be converted to an array of values.default boolean isSubsetOf(Record<?> aRecord)
Header
elements is
matching the Record
's elements in terms of matching the same
relevant attributes of the Column
instances with the elements in
the Record
. I.e. all Column
instances in the subset must
match the elements, even if this has more elements. The test also fails
(returns false) in case the types of the instances in the Record
do not match the according key's type in the Header
Column
instance or vice versa.aRecord
- The Record
to be used for testing.default boolean isEqualWith(Record<?> aRecord)
Header
is matching
the Record
's elements in terms of matching the same relevant
attributes of the columns with the elements in the Record
. I.e.
all Header
in the subset must match the elements, and the number
of Header
must be the same as the number of elements in the
Record
. The test also fails (returns false) in case the types of
the instances in the Record
do not match the according key's type
in the Header
Column
instance or vice versa.aRecord
- The Record
to be used for testing.default boolean isSupersetOf(Record<?> aRecord)
Record
's elements is matching the given
potential superset of Header
elements in terms of matching the
same relevant attributes of the columns with the elements in the
Record
. I.e. all elements in the Record
must match the
Header
in the superset, even if the superset has more elements.
The test also fails (returns false) in case the types of the instances in
the Record
do not match the according key's type in the
Header
Column
instance or vice versa.aRecord
- The Record
to be used for testing.default boolean isSubsetOf(Row<?> aRow)
Header
is a subset of the Row
's
elements in terms of matching the same relevant attributes of the
Header
with the elements in the Row
. I.e. all
Column
instances in the subset must match the elements, even if
this has more elements. The test also fails (returns false) in case the
types of the instances in the Row
do not match the according
key's type in the Header
Column
instance or vice versa.aRow
- The Row
to be used for testing.default boolean isEqualWith(Row<?> aRow)
Header
equal set is matching
the Row
's elements in terms of matching the same relevant
attributes of the Header
with the elements in the Row
.
I.e. all Column
instances in the subset must match the elements,
and the number of columns must be the same as the number of elements in
the Row
. The test also fails (returns false) in case the types of
the instances in the Row
do not match the according key's type in
the Header
Column
instance or vice versa.aRow
- The Row
to be used for testing.default boolean isSupersetOf(Row<?> aRow)
Row
's elements is matching the given potential
Header
superset in terms of matching the same relevant attributes
of the Header
with the elements in the Row
. I.e. all
elements in the Row
must match the Column
instances in
the superset, even if the superset has more elements. The test also fails
(returns false) in case the types of the instances in the Row
do
not match the according key's type in the Header
Column
instance or vice versa.aRow
- The Row
to be used for testing.default <REC> Record<REC> toIntersection(Record<REC> aRecord) throws ColumnMismatchException
default <REC> Record<REC> toSubset(Record<REC> aRecord) throws ColumnMismatchException
Copyright © 2021. All rights reserved.