Top Description Inners Fields Constructors Methods
io.github.kusoroadeolu.clique.configuration

public final Class TableConfiguration

extends Object
Class Inheritance
Annotations
@Stable
since:3.2.0
Imports
io.github.kusoroadeolu.clique.internal.documentation.Stable, io.github.kusoroadeolu.clique.internal.utils.ParserUtils, io.github.kusoroadeolu.clique.parser.MarkupParser, io.github.kusoroadeolu.clique.spi.AnsiCode, java.util.Arrays, .HashMap, .Map, .Objects

An immutable configuration object that defines the visual and functional behavior of a Table.

This class uses a builder pattern for construction. Default values are:

Resolution Order: When determining cell alignment, configurations defined via TableConfigurationBuilder#columnAlignment(int, CellAlign) take precedence over the global TableConfigurationBuilder#alignment(CellAlign) setting.

Thread Safety: This class is immutable and thread-safe.

Since
1.0.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private final CellAlign
private final AnsiCode[]
private final Map<Integer, CellAlign>
public static final TableConfiguration
DEFAULT

The default table configuration.

private final String
private final int
private final MarkupParser

Constructor Summary

AccessConstructor and Description
private
private

Method Summary

Modifier and TypeMethod and Description
public static TableConfiguration.TableConfigurationBuilder

Returns:

a new builder instance
builder
()

Creates a new builder for constructing a TableConfiguration.

public boolean
equals(Object object)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public CellAlign

Returns:

the default cell alignment
getAlignment
()

Returns the global alignment setting for table cells.

public AnsiCode[]

Returns:

a copy of the border color ANSI codes
getBorderColor
()

Returns the ANSI codes used to style the table borders.

public Map<Integer, CellAlign>

Returns:

a copy of the column alignment map
getColumnAlignment
()

Returns the map of column-specific alignments.

public String

Returns:

the null replacement string
getNullReplacement
()

Returns the string used to replace null cell values.

public int

Returns:

the number of spaces used for padding
getPadding
()

Returns the horizontal padding applied to cell content.

public MarkupParser

Returns:

the markup parser
getParser
()

Returns the parser used for resolving markup within cell content.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

alignmentback to summary
private final CellAlign alignment
borderColorback to summary
private final AnsiCode[] borderColor
columnAlignmentback to summary
private final Map<Integer, CellAlign> columnAlignment
DEFAULTback to summary
public static final TableConfiguration DEFAULT

The default table configuration.

nullReplacementback to summary
private final String nullReplacement
paddingback to summary
private final int padding
parserback to summary
private final MarkupParser parser

Constructor Detail

TableConfigurationback to summary
private TableConfiguration()
TableConfigurationback to summary
private TableConfiguration(TableConfiguration.TableConfigurationBuilder builder)

Method Detail

builderback to summary
public static TableConfiguration.TableConfigurationBuilder builder()

Creates a new builder for constructing a TableConfiguration.

Returns:TableConfiguration.TableConfigurationBuilder

a new builder instance

equalsback to summary
public boolean equals(Object object)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Annotations
@Override
getAlignmentback to summary
public CellAlign getAlignment()

Returns the global alignment setting for table cells.

Returns:CellAlign

the default cell alignment

getBorderColorback to summary
public AnsiCode[] getBorderColor()

Returns the ANSI codes used to style the table borders.

Returns:AnsiCode[]

a copy of the border color ANSI codes

getColumnAlignmentback to summary
public Map<Integer, CellAlign> getColumnAlignment()

Returns the map of column-specific alignments.

Returns:Map<Integer, CellAlign>

a copy of the column alignment map

getNullReplacementback to summary
public String getNullReplacement()

Returns the string used to replace null cell values.

Returns:String

the null replacement string

getPaddingback to summary
public int getPadding()

Returns the horizontal padding applied to cell content.

Returns:int

the number of spaces used for padding

getParserback to summary
public MarkupParser getParser()

Returns the parser used for resolving markup within cell content.

Returns:MarkupParser

the markup parser

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
io.github.kusoroadeolu.clique.configuration back to summary

public Class TableConfiguration.TableConfigurationBuilder

extends Object
Class Inheritance
  • java.lang.Object
  • io.github.kusoroadeolu.clique.configuration.TableConfiguration.TableConfigurationBuilder

Builder for TableConfiguration instances.

This builder is not thread-safe.

Field Summary

Modifier and TypeField and Description
private CellAlign
private AnsiCode[]
private Map<Integer, CellAlign>
private String
private int
private MarkupParser

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public TableConfiguration.TableConfigurationBuilder

Returns:

this builder
alignment
(CellAlign
the cell alignment; must not be null
alignment
)

Sets the default alignment for all table cells.

public TableConfiguration.TableConfigurationBuilder

Returns:

this builder
borderColor
(String
a string containing color tags e.g "red, bold". Note that the markup brackets should not be included
borderColor
)

Sets the border color using a markup-styled string.

public TableConfiguration.TableConfigurationBuilder

Returns:

this builder
borderColor
(AnsiCode...
the ANSI codes to apply
borderColor
)

Sets the border color using ANSI codes.

public TableConfiguration

Returns:

a new configuration instance
build
()

Builds a new TableConfiguration based on current settings.

public TableConfiguration.TableConfigurationBuilder

Returns:

this builder
columnAlignment
(Map<Integer, CellAlign>
the mapping of column indices; must not be null
columnAlignment
)

Sets column-specific alignments using a map of column indices to alignments.

public TableConfiguration.TableConfigurationBuilder

Returns:

this builder
columnAlignment
(int
the 0-based index of the column
column
,
CellAlign
the alignment to apply; must not be null
alignment
)

Sets the alignment for a specific column.

public TableConfiguration.TableConfigurationBuilder

Returns:

this builder
nullReplacement
(String
the replacement string; must not be null
nullReplacement
)

Sets the replacement string for cells containing null.

public TableConfiguration.TableConfigurationBuilder

Returns:

this builder
padding
(int
the number of spaces to apply; must not be negative
padding
)

Sets the padding for table cells.

public TableConfiguration.TableConfigurationBuilder

Returns:

this builder
parser
(MarkupParser
the parser to use; must not be null
parser
)

Sets the parser for markup resolution.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

alignmentback to summary
private CellAlign alignment
borderColorback to summary
private AnsiCode[] borderColor
columnAlignmentback to summary
private Map<Integer, CellAlign> columnAlignment
nullReplacementback to summary
private String nullReplacement
paddingback to summary
private int padding
parserback to summary
private MarkupParser parser

Constructor Detail

TableConfigurationBuilderback to summary
public TableConfigurationBuilder()

Method Detail

alignmentback to summary
public TableConfiguration.TableConfigurationBuilder alignment(CellAlign alignment)

Sets the default alignment for all table cells.

Parameters
alignment:CellAlign

the cell alignment; must not be null

Returns:TableConfiguration.TableConfigurationBuilder

this builder

Exceptions
NullPointerException:
if alignment is null
borderColorback to summary
public TableConfiguration.TableConfigurationBuilder borderColor(String borderColor)

Sets the border color using a markup-styled string.

Parameters
borderColor:String

a string containing color tags e.g "red, bold". Note that the markup brackets should not be included

Returns:TableConfiguration.TableConfigurationBuilder

this builder

Exceptions
NullPointerException:
if borderColor is null
borderColorback to summary
public TableConfiguration.TableConfigurationBuilder borderColor(AnsiCode... borderColor)

Sets the border color using ANSI codes.

Parameters
borderColor:AnsiCode[]

the ANSI codes to apply

Returns:TableConfiguration.TableConfigurationBuilder

this builder

Exceptions
NullPointerException:
if borderColor is null
buildback to summary
public TableConfiguration build()

Builds a new TableConfiguration based on current settings.

Returns:TableConfiguration

a new configuration instance

columnAlignmentback to summary
public TableConfiguration.TableConfigurationBuilder columnAlignment(Map<Integer, CellAlign> columnAlignment)

Sets column-specific alignments using a map of column indices to alignments.

Parameters
columnAlignment:Map<Integer, CellAlign>

the mapping of column indices; must not be null

Returns:TableConfiguration.TableConfigurationBuilder

this builder

Exceptions
NullPointerException:
if columnAlignment is null
columnAlignmentback to summary
public TableConfiguration.TableConfigurationBuilder columnAlignment(int column, CellAlign alignment)

Sets the alignment for a specific column.

Scoping: This setting overrides the global table alignment for the specified column index.

Parameters
column:int

the 0-based index of the column

alignment:CellAlign

the alignment to apply; must not be null

Returns:TableConfiguration.TableConfigurationBuilder

this builder

Exceptions
IllegalArgumentException:
if column < 0
NullPointerException:
if alignment is null
nullReplacementback to summary
public TableConfiguration.TableConfigurationBuilder nullReplacement(String nullReplacement)

Sets the replacement string for cells containing null.

Parameters
nullReplacement:String

the replacement string; must not be null

Returns:TableConfiguration.TableConfigurationBuilder

this builder

Exceptions
NullPointerException:
if nullReplacement is null
paddingback to summary
public TableConfiguration.TableConfigurationBuilder padding(int padding)

Sets the padding for table cells.

Parameters
padding:int

the number of spaces to apply; must not be negative

Returns:TableConfiguration.TableConfigurationBuilder

this builder

Exceptions
IllegalArgumentException:
if padding < 0
parserback to summary
public TableConfiguration.TableConfigurationBuilder parser(MarkupParser parser)

Sets the parser for markup resolution. content will be treated as literal text and will not be parsed into ANSI sequences.

Parameters
parser:MarkupParser

the parser to use; must not be null

Returns:TableConfiguration.TableConfigurationBuilder

this builder

Exceptions
NullPointerException:
if parser is null