public final class TabularUtility extends Object
Modifier and Type | Method and Description |
---|---|
static boolean |
isEqualWith(Record<?> aRecord,
Header<?> aEquivalsWith)
|
static boolean |
isEqualWith(Row<?> aRow,
Header<?> aEquivalsWith)
|
static boolean |
isSubsetOf(Record<?> aRecord,
Header<?> aSupersetOf)
|
static boolean |
isSubsetOf(Row<?> aRow,
Header<?> aSupersetOf)
|
static boolean |
isSupersetOf(Record<?> aRecord,
Header<?> aSubsetOf)
|
static boolean |
isSupersetOf(Row<?> aRow,
Header<?> aSubsetOf)
|
static <T> Header<T> |
toHeader(Collection<String> aColumnKeys,
ColumnFactory<T> aColumnFactory)
Creates a header for a given list of strings containing the column names
to be used for the header.
|
static <T> Header<T> |
toHeader(String[] aColumnKeys,
ColumnFactory<T> aColumnFactory)
Creates a header for a given string array with the column names to be
used for the header.
|
static <T> Record<T> |
toIntersection(Record<T> aRecord,
Header<?> aHeader)
|
static Record<?> |
toPurged(Record<?> aRecord)
|
static String |
toSeparatedValues(Record<?> aRecord)
Returns a separated values representation of the implementing collection
by separating each item with the default separator
Delimiter.CSV_DELIMITER . |
static String |
toSeparatedValues(Record<?> aRecord,
char aDelimiter)
Returns a separated values representation of the implementing collection
by separating each item with the given separator.
|
static String |
toString(Record<?> aRecord)
Creates the string representation from from the given record.
|
static String |
toString(Record<?> aRecord,
char aSeparator,
DateTimeFormatter[] aDateFormats)
Creates the string representation from from the given record.
|
static <T> Record<T> |
toSubset(Record<T> aRecord,
Header<?> aHeader)
|
public static <T> Header<T> toHeader(String[] aColumnKeys, ColumnFactory<T> aColumnFactory)
Object
.aColumnKeys
- The column names to be use for the header.aColumnFactory
- creates column instances depending on the key
passed. This is useful when special header keys are to have a
dedicated type such as Date
. If null is passed
then just OneToOneColumnImpl
instances for type
Object.class are created.public static <T> Header<T> toHeader(Collection<String> aColumnKeys, ColumnFactory<T> aColumnFactory)
Object
.aColumnKeys
- The column names to be use for the header.aColumnFactory
- creates column instances depending on the key
passed. This is useful when special header keys are to have a
dedicated type such as Date
. If null is passed
then just OneToOneColumnImpl
instances for type
Object.class are created.public static boolean isSubsetOf(Record<?> aRecord, Header<?> aSupersetOf)
Header
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.
-------------------------------------------------------------------------
TODO: Think about moving this method to the Header
.
-------------------------------------------------------------------------public static boolean isEqualWith(Record<?> aRecord, Header<?> aEquivalsWith)
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.
-------------------------------------------------------------------------
TODO: Think about moving this method to the Header
.
-------------------------------------------------------------------------aRecord
- The Record
to be used for testing.aEquivalsWith
- The columns which all must be matched with elements
of this instance.public static boolean isSupersetOf(Record<?> aRecord, Header<?> aSubsetOf)
Record
's elements is matching the given
potential superset of Header
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.
-------------------------------------------------------------------------
TODO: Think about moving this method to the Header
.
-------------------------------------------------------------------------aRecord
- The Record
to be used for testing.aSupersetOf
- The columns with which all elements in this instance
must match.public static boolean isSubsetOf(Row<?> aRow, Header<?> aSupersetOf)
Header
subset 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, even if
this has more elements.
-------------------------------------------------------------------------
TODO: Think about moving this method to the Header
.
-------------------------------------------------------------------------
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.aSubsetOf
- The columns which all must be matched with elements of
this instance.public static boolean isEqualWith(Row<?> aRow, Header<?> aEquivalsWith)
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.
-------------------------------------------------------------------------
TODO: Think about moving this method to the Header
.
-------------------------------------------------------------------------aRow
- The Row
to be used for testing.aEquivalsWith
- The columns which all must be matched with elements
of this instance.public static boolean isSupersetOf(Row<?> aRow, Header<?> aSubsetOf)
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.
-------------------------------------------------------------------------
TODO: Think about moving this method to the Header
.
-------------------------------------------------------------------------aRow
- The Row
to be used for testing.aSupersetOf
- The columns with which all elements in this instance
must match.public static <T> Record<T> toIntersection(Record<T> aRecord, Header<?> aHeader) throws ColumnMismatchException
Record
just containing the keys as defined in the
Header
and found in the provided Record
.
-------------------------------------------------------------------------
TODO: Think about moving this method to the Header
.
-------------------------------------------------------------------------aRecord
- The Record
to use.aHeader
- The Header
being the reference for the expected
result.Record
being a subset of the given Header
.ColumnMismatchException
- in case the type of a key defined in a
Column
does not match the type of the according value in
the Record
.public static <T> Record<T> toSubset(Record<T> aRecord, Header<?> aHeader) throws ColumnMismatchException
Record
just containing the keys as defined in the
Header
; keys not found in the provided Record
are
ignored.
-------------------------------------------------------------------------
TODO: Think about moving this method to the Header
.
-------------------------------------------------------------------------aRecord
- The Record
to use.aHeader
- The Header
being the reference for the expected
result.Record
being a subset of the given Header
.ColumnMismatchException
- in case the type of a key defined in a
Column
does not match the type of the according value in
the Record
.public static String toString(Record<?> aRecord)
aRecord
- The record for which to create a string.public static String toString(Record<?> aRecord, char aSeparator, DateTimeFormatter[] aDateFormats)
aRecord
- The record for which to create a string.aSeparator
- The separator to separate the items (key / value pairs)
of the record from each other.aDateFormats
- The date formats to use when formatting date objects.public static String toSeparatedValues(Record<?> aRecord)
Delimiter.CSV_DELIMITER
. The common CSV conventions are to be
obeyed (although there is none CSV standard). In case a value's string
representation contains the delimiter char, then this char must be
escaped (i.e. by using the backslash '\').aRecord
- The record from which to generate separated values.public static String toSeparatedValues(Record<?> aRecord, char aDelimiter)
aRecord
- The record from which to generate separated values.aDelimiter
- The delimiter to use when separating the values.Copyright © 2016. All rights reserved.