Class RowPadding


  • public final class RowPadding
    extends Object
    Contains data about how to pad a given row.
    Since:
    2020-12-15
    Author:
    miki
    • Field Detail

      • NONE

        public static final RowPadding NONE
        Constant for no padding.
    • Constructor Detail

      • RowPadding

        public RowPadding​(int beginning,
                          int end)
        Creates information about padding a row.
        Parameters:
        beginning - Number of empty cells at the beginning of the row. Must not be a negative number,
        end - Number of empty cells at the end of the row. Must not be a negative number.
        Throws:
        IllegalArgumentException - When either beginning or end are negative.
    • Method Detail

      • centred

        public static RowPadding centred​(int cells,
                                         int columns,
                                         boolean whenOddPutMoreToBeginning)
        Creates RowPadding where given number of cells are centred in given number of columns (optionally putting one odd cell to the beginning).
        Parameters:
        cells - Number of cells to split. If not less than columns, NONE will be returned.
        columns - Number of columns to fill. Must be a positive number.
        whenOddPutMoreToBeginning - When there is odd number of empty cells to distribute and this parameter is true, extra empty cell will be added to the beginning. Otherwise, it will be added to the end if needed.
        Returns:
        Row padding data.
      • getBeginning

        public int getBeginning()
        Returns the number of empty cells at the beginning of the row.
        Returns:
        Non-negative number of empty cells at the beginning of the row.
      • getEnd

        public int getEnd()
        Returns the number of empty cells at the end of the row.
        Returns:
        Non-negative number of empty cells at the beginning of the row.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object