public class DataTable
extends java.lang.Object
Constructor and Description |
---|
DataTable(gherkin.pickles.PickleTable pickleTable,
TableConverter tableConverter)
Creates a new DataTable.
|
Modifier and Type | Method and Description |
---|---|
<T> java.util.List<T> |
asList(java.lang.Class<T> itemType)
Converts the table to a List.
|
<T> java.util.List<java.util.List<T>> |
asLists(java.lang.Class<T> itemType)
Converts the table to a List of List of scalar.
|
<K,V> java.util.Map<K,V> |
asMap(java.lang.Class<K> keyType,
java.lang.Class<V> valueType)
Converts the table to a single Map.
|
<K,V> java.util.List<java.util.Map<K,V>> |
asMaps(java.lang.Class<K> keyType,
java.lang.Class<V> valueType)
Converts the table to a List of Map.
|
java.util.List<java.util.List<java.lang.String>> |
cells(int firstRow) |
static DataTable |
create(java.util.List<?> raw) |
static DataTable |
create(java.util.List<?> raw,
java.util.Locale locale,
java.lang.String... columnNames) |
static DataTable |
create(java.util.List<?> raw,
java.lang.String format,
java.lang.String... columnNames) |
protected cucumber.runtime.table.TablePrinter |
createTablePrinter() |
void |
diff(DataTable other)
Diffs this table with
other . |
void |
diff(java.util.List<?> other)
Diffs this table with
other , which can be a List<List<String>> or a
List<YourType> . |
java.util.List<cucumber.runtime.table.DiffableRow> |
diffableRows() |
boolean |
equals(java.lang.Object o) |
java.util.List<gherkin.pickles.PickleRow> |
getPickleRows()
Internal method.
|
TableConverter |
getTableConverter() |
int |
hashCode() |
java.util.List<java.util.List<java.lang.String>> |
raw() |
java.util.List<java.lang.String> |
topCells() |
java.lang.String |
toString() |
DataTable |
toTable(java.util.List<?> raw,
java.lang.String... columnNames)
Creates another table using the same
Locale and Format that was used to create this table. |
DataTable |
transpose() |
void |
unorderedDiff(DataTable other)
Diffs this table with
other . |
void |
unorderedDiff(java.util.List<?> other)
Diffs this table with
other , which can be a List<List<String>> or a
List<YourType> . |
public DataTable(gherkin.pickles.PickleTable pickleTable, TableConverter tableConverter)
pickleTable
- the underlying table.tableConverter
- how to convert the rows.public static DataTable create(java.util.List<?> raw)
public static DataTable create(java.util.List<?> raw, java.lang.String format, java.lang.String... columnNames)
public static DataTable create(java.util.List<?> raw, java.util.Locale locale, java.lang.String... columnNames)
public java.util.List<java.util.List<java.lang.String>> raw()
public <K,V> java.util.List<java.util.Map<K,V>> asMaps(java.lang.Class<K> keyType, java.lang.Class<V> valueType)
K
- key typeV
- value typekeyType
- key typevalueType
- value typepublic <K,V> java.util.Map<K,V> asMap(java.lang.Class<K> keyType, java.lang.Class<V> valueType)
K
- key typeV
- value typekeyType
- key typevalueType
- value typecucumber.runtime.CucumberException
- if the table doesn't have 2 columns.public <T> java.util.List<T> asList(java.lang.Class<T> itemType)
itemType
is a scalar type the table is flattened.
Otherwise, the top row is used to name the fields/properties and the remaining
rows are turned into list items.T
- the type of the list itemsitemType
- the type of the list itemspublic <T> java.util.List<java.util.List<T>> asLists(java.lang.Class<T> itemType)
T
- the type of the list itemsitemType
- the type of the list itemspublic java.util.List<java.lang.String> topCells()
public java.util.List<java.util.List<java.lang.String>> cells(int firstRow)
public DataTable toTable(java.util.List<?> raw, java.lang.String... columnNames)
Locale
and Format
that was used to create this table.raw
- a list of objectscolumnNames
- optional explicit header columnspublic void diff(java.util.List<?> other) throws cucumber.runtime.table.TableDiffException
other
, which can be a List<List<String>>
or a
List<YourType>
.other
- the other table to diff with.cucumber.runtime.table.TableDiffException
- if the tables are different.public void diff(DataTable other) throws cucumber.runtime.table.TableDiffException
other
.other
- the other table to diff with.cucumber.runtime.table.TableDiffException
- if the tables are different.public void unorderedDiff(DataTable other) throws cucumber.runtime.table.TableDiffException
other
.
The order is not important. A set-difference is applied.other
- the other table to diff with.cucumber.runtime.table.TableDiffException
- if the tables are different.public void unorderedDiff(java.util.List<?> other) throws cucumber.runtime.table.TableDiffException
other
, which can be a List<List<String>>
or a
List<YourType>
.other
- the other table to diff with.cucumber.runtime.table.TableDiffException
- if the tables are different.public java.util.List<gherkin.pickles.PickleRow> getPickleRows()
public java.lang.String toString()
toString
in class java.lang.Object
public java.util.List<cucumber.runtime.table.DiffableRow> diffableRows()
public TableConverter getTableConverter()
public DataTable transpose()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
protected cucumber.runtime.table.TablePrinter createTablePrinter()
Copyright © 2017. All Rights Reserved.