Package eu.cloudnetservice.common.column
Record Class RowedFormatter<T>
java.lang.Object
java.lang.Record
eu.cloudnetservice.common.column.RowedFormatter<T>
- Type Parameters:
T- the type of element converted to a table by this formatter- Record Components:
defaultFormatter- the default formatter to use to turn the formatted rows into a table.columns- the column level data extractors.
public record RowedFormatter<T>(@NonNull ColumnFormatter defaultFormatter, @NonNull List<Function<T,Object>> columns)
extends Record
A formatter for rows based on columns. The columns are generated from functions given to this formatter.
- Since:
- 4.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA builder that can be used to construct a new row based formatter. -
Field Summary
FieldsModifier and TypeFieldDescriptionThe field for thecolumnsrecord component.private final @NonNull ColumnFormatterThe field for thedefaultFormatterrecord component. -
Constructor Summary
ConstructorsConstructorDescriptionRowedFormatter(@NonNull ColumnFormatter defaultFormatter, @NonNull List<Function<T, Object>> columns) Creates an instance of aRowedFormatterrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> @NonNull RowedFormatter.Builder<T>builder()Constructs a new builder for a rowed formatter.columns()Returns the value of thecolumnsrecord component.convertToColumns(@NonNull Collection<T> input) Converts the given input data into columns to prepare them to be converted into a table.convertToColumns(@NonNull T... input) Converts the given input data into columns to prepare them to be converted into a table.Returns the value of thedefaultFormatterrecord component.final booleanIndicates whether some other object is "equal to" this one.format(@NonNull Collection<T> input) Converts the given input data into a formatted table using the default formatter given to this formatter.Converts the given input data into a formatted table using the default formatter given to this formatter.final inthashCode()Returns a hash code value for this object.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
defaultFormatter
The field for thedefaultFormatterrecord component. -
columns
The field for thecolumnsrecord component.
-
-
Constructor Details
-
RowedFormatter
public RowedFormatter(@NonNull @NonNull ColumnFormatter defaultFormatter, @NonNull @NonNull List<Function<T, Object>> columns) Creates an instance of aRowedFormatterrecord class.- Parameters:
defaultFormatter- the value for thedefaultFormatterrecord componentcolumns- the value for thecolumnsrecord component
-
-
Method Details
-
builder
Constructs a new builder for a rowed formatter.- Type Parameters:
T- the type of elements that will be handled by the rowed formatter.- Returns:
- a new builder for a rowed formatter.
-
convertToColumns
Converts the given input data into columns to prepare them to be converted into a table.- Parameters:
input- the input data to parse and convert into columns.- Returns:
- the prepared columns based on the given input data.
- Throws:
NullPointerException- if the given input data is null.
-
convertToColumns
Converts the given input data into columns to prepare them to be converted into a table.- Parameters:
input- the input data to parse and convert into columns.- Returns:
- the prepared columns based on the given input data.
- Throws:
NullPointerException- if the given input data is null.
-
format
Converts the given input data into a formatted table using the default formatter given to this formatter.- Parameters:
input- the input data to parse and convert into a table.- Returns:
- the formatted table based on the given input data.
- Throws:
NullPointerException- if the given input data is null.
-
format
Converts the given input data into a formatted table using the default formatter given to this formatter.- Parameters:
input- the input data to parse and convert into a table.- Returns:
- the formatted table based on the given input data.
- Throws:
NullPointerException- if the given input data is null.
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
defaultFormatter
Returns the value of thedefaultFormatterrecord component.- Returns:
- the value of the
defaultFormatterrecord component
-
columns
Returns the value of thecolumnsrecord component.- Returns:
- the value of the
columnsrecord component
-