Class RowedFormatter.Builder<T>
java.lang.Object
eu.cloudnetservice.utils.base.column.RowedFormatter.Builder<T>
- Type Parameters:
T- the type of elements that will be handled by the new formatter.
- Enclosing class:
RowedFormatter<T>
A builder that can be used to construct a new row based formatter.
- Since:
- 4.0
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds a new row based formatter from this builder.Sets the extractor function for the next column.Sets the extractor functions for all columns.defaultFormatter(@NonNull ColumnFormatter defaultFormatter) Sets the default formatter for the columns.
-
Field Details
-
defaultFormatter
-
columns
-
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
defaultFormatter
@Contract(value="_ -> this", pure=true) @NonNull public @NonNull RowedFormatter.Builder<T> defaultFormatter(@NonNull @NonNull ColumnFormatter defaultFormatter) Sets the default formatter for the columns.- Parameters:
defaultFormatter- the default formatter to use.- Returns:
- the same builder instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given column formatter is null.
-
columns
@Contract(value="_ -> this", pure=true) @NonNull public @NonNull RowedFormatter.Builder<T> columns(@NonNull @NonNull List<Function<T, Object>> columns) Sets the extractor functions for all columns. This method copies the list into this builder, meaning that changes made to the given list are not reflected into this builder.- Parameters:
columns- the extractor functions for all columns, in order.- Returns:
- the same builder instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given column extractor function list is null.
-
column
@Contract(value="_ -> this", pure=true) @NonNull public @NonNull RowedFormatter.Builder<T> column(@NonNull @NonNull Function<T, Object> converter) Sets the extractor function for the next column.- Parameters:
converter- the converter for the next column.- Returns:
- the same builder instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given column extractor function is null.
-
build
Builds a new row based formatter from this builder. Further changes to this builder do not reflect into the returned formatter.- Returns:
- a new rowed formatter based on this builder.
- Throws:
NullPointerException- if the given default formatter is null.IllegalArgumentException- if there are no column extractor function are given.
-