Package guru.mikelue.jdut.datagrain
Class DataRow
- java.lang.Object
-
- guru.mikelue.jdut.datagrain.DataRow
-
public class DataRow extends Object
Represents the data of a row.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
DataRow.Builder
Used withDataRow.build(Consumer<DataRow.Builder>)
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DataRow
build(Consumer<DataRow.Builder> builderConsumer)
Builds row byConsumer
ofDataRow.Builder
.static DataRow
build(Consumer<DataRow.Builder> builderConsumer, DataRow existingRow)
Builds row byConsumer
ofDataRow.Builder
and existing row.protected DataRow
clone()
boolean
equals(Object obj)
Compares the table schema and data.<T> T
getAttribute(String name)
Gets attribute of this row.List<String>
getColumns()
Gets name of columns.<T> T
getData(String columnName)
Gets the data by column name.<T> DataField<T>
getDataField(String columnName)
Gets the field by column name.SchemaTable
getTable()
Gets the table schema.boolean
hasAttribute(String name)
Checks whether or not a attribute is existing.int
hashCode()
Hashes the table schema and data.boolean
isValidated()
Whether or not this row is validated with schema of table.void
putAttribute(String name, Object value)
Puts a attribute.void
validate()
Validates the data of row with schema information fromgetTable()
.
-
-
-
Method Detail
-
build
public static DataRow build(Consumer<DataRow.Builder> builderConsumer)
Builds row byConsumer
ofDataRow.Builder
.- Parameters:
builderConsumer
- The consumer to build row- Returns:
- the built data of row
-
build
public static DataRow build(Consumer<DataRow.Builder> builderConsumer, DataRow existingRow)
Builds row byConsumer
ofDataRow.Builder
and existing row.- Parameters:
builderConsumer
- The consumer to build rowexistingRow
- The row to be modified- Returns:
- the built data of row
-
getTable
public SchemaTable getTable()
Gets the table schema.- Returns:
- table schema
-
getDataField
public <T> DataField<T> getDataField(String columnName)
Gets the field by column name.- Type Parameters:
T
- The type of field- Parameters:
columnName
- The name of column- Returns:
- The field with the column name
- Throws:
IllegalArgumentException
- If the is no such field found with the column name- See Also:
getData(java.lang.String)
-
getData
public <T> T getData(String columnName)
Gets the data by column name.- Type Parameters:
T
- The type of data- Parameters:
columnName
- The name of column- Returns:
- The field with the column name
- Throws:
IllegalArgumentException
- If the is no such field found with the column name- See Also:
getDataField(java.lang.String)
-
validate
public void validate() throws DataRowException
Validates the data of row with schema information fromgetTable()
.- Throws:
DataRowException
- The exception if the validation is failed- See Also:
isValidated()
-
isValidated
public boolean isValidated()
Whether or not this row is validated with schema of table.- Returns:
- true if validated
- See Also:
validate()
-
getAttribute
public <T> T getAttribute(String name)
Gets attribute of this row.- Type Parameters:
T
- The expected type of result- Parameters:
name
- The name of attribute- Returns:
- null if attribute is not existing
- See Also:
hasAttribute(java.lang.String)
,putAttribute(java.lang.String, java.lang.Object)
-
hasAttribute
public boolean hasAttribute(String name)
Checks whether or not a attribute is existing.- Parameters:
name
- The name of attribute- Returns:
- true if the attribute is existing
- See Also:
getAttribute(java.lang.String)
,putAttribute(java.lang.String, java.lang.Object)
-
putAttribute
public void putAttribute(String name, Object value)
Puts a attribute.- Parameters:
name
- The name of attributevalue
- the value of attribute- See Also:
getAttribute(java.lang.String)
,hasAttribute(java.lang.String)
-
hashCode
public int hashCode()
Hashes the table schema and data.
-
-