Record Class RowedFormatter<T>

java.lang.Object
java.lang.Record
eu.cloudnetservice.utils.base.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
  • Field Details

  • Constructor Details

  • Method Details

    • builder

      @NonNull public static <T> @NonNull RowedFormatter.Builder<T> 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

      @NonNull public @NonNull ColumnEntry[] convertToColumns(@NonNull @NonNull Collection<T> input)
      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

      @NonNull public @NonNull ColumnEntry[] convertToColumns(@NonNull T... input)
      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

      @NonNull public @NonNull Collection<String> format(@NonNull T... input)
      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

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • defaultFormatter

      @NonNull public @NonNull ColumnFormatter defaultFormatter()
      Returns the value of the defaultFormatter record component.
      Returns:
      the value of the defaultFormatter record component
    • columns

      @NonNull public @NonNull List<Function<T,Object>> columns()
      Returns the value of the columns record component.
      Returns:
      the value of the columns record component