public class DataTable extends Object
Constructor and Description |
---|
DataTable(gherkin.pickles.PickleTable pickleTable,
TableConverter tableConverter)
Creates a new DataTable.
|
Modifier and Type | Method and Description |
---|---|
<T> List<T> |
asList(Class<T> itemType)
Converts the table to a List.
|
<T> List<List<T>> |
asLists(Class<T> itemType)
Converts the table to a List of List of scalar.
|
<K,V> Map<K,V> |
asMap(Class<K> keyType,
Class<V> valueType)
Converts the table to a single Map.
|
<K,V> List<Map<K,V>> |
asMaps(Class<K> keyType,
Class<V> valueType)
Converts the table to a List of Map.
|
List<List<String>> |
cells(int firstRow) |
static DataTable |
create(List<?> raw) |
static DataTable |
create(List<?> raw,
Locale locale,
String... columnNames) |
static DataTable |
create(List<?> raw,
String format,
String... columnNames) |
protected cucumber.runtime.table.TablePrinter |
createTablePrinter() |
void |
diff(DataTable other)
Diffs this table with
other . |
void |
diff(List<?> other)
Diffs this table with
other , which can be a List<List<String>> or a
List<YourType> . |
List<cucumber.runtime.table.DiffableRow> |
diffableRows() |
boolean |
equals(Object o) |
List<gherkin.pickles.PickleRow> |
getPickleRows()
Internal method.
|
TableConverter |
getTableConverter() |
int |
hashCode() |
List<List<String>> |
raw() |
List<String> |
topCells() |
String |
toString() |
DataTable |
toTable(List<?> raw,
String... columnNames)
|
DataTable |
transpose() |
void |
unorderedDiff(DataTable other)
Diffs this table with
other . |
void |
unorderedDiff(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 <K,V> List<Map<K,V>> asMaps(Class<K> keyType, Class<V> valueType)
K
- key typeV
- value typekeyType
- key typevalueType
- value typepublic <K,V> Map<K,V> asMap(Class<K> keyType, Class<V> valueType)
K
- key typeV
- value typekeyType
- key typevalueType
- value typecucumber.runtime.CucumberException
- if the table doesn't have 2 columns.public <T> List<T> asList(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> List<List<T>> asLists(Class<T> itemType)
T
- the type of the list itemsitemType
- the type of the list itemspublic DataTable toTable(List<?> raw, String... columnNames)
raw
- a list of objectscolumnNames
- optional explicit header columnspublic void diff(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(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 List<gherkin.pickles.PickleRow> getPickleRows()
public List<cucumber.runtime.table.DiffableRow> diffableRows()
public TableConverter getTableConverter()
public DataTable transpose()
protected cucumber.runtime.table.TablePrinter createTablePrinter()
Copyright © 2017. All Rights Reserved.