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

public final Class BoxConfiguration

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, .Objects

Immutable configuration for a io.github.kusoroadeolu.clique.components.Box.

Instances are obtained via builder(). The DEFAULT constant provides a pre-built configuration with the following values:

This class is immutable and thread-safe. BoxConfigurationBuilder is not thread-safe; external synchronization is required if a builder instance is shared across threads.

Example:

BoxConfiguration config = BoxConfiguration.builder()
    .padding(3)
    .textAlign(TextAlign.CENTER)
    .borderColor("blue")
    .build();
Since
1.1.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private final AnsiCode[]
public static final BoxConfiguration
DEFAULT

A default BoxConfiguration with padding 2, center alignment, the default markup parser, and no border color.

private final int
private final MarkupParser
private final TextAlign

Constructor Summary

AccessConstructor and Description
private
private

Method Summary

Modifier and TypeMethod and Description
public static BoxConfiguration.BoxConfigurationBuilder
builder()

Returns a new builder for constructing a BoxConfiguration.

public boolean
equals(Object object)

Overrides java.lang.Object.equals.

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

public AnsiCode[]

Returns:

a defensive copy of the border color codes; never null, may be empty
getBorderColor
()

Returns the ANSI codes applied to the box border, or an empty array if no border color has been set.

public int

Returns:

the padding value; always >= 0
getPadding
()

Returns the number of blank characters inserted between the box border and its content on each side.

public MarkupParser

Returns:

the parser; never null
getParser
()

Returns the markup parser used to interpret inline style tags in box content and border color specifications.

public TextAlign

Returns:

the text alignment; never null
getTextAlign
()

Returns the horizontal alignment applied to content within the box.

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

borderColorback to summary
private final AnsiCode[] borderColor
DEFAULTback to summary
public static final BoxConfiguration DEFAULT

A default BoxConfiguration with padding 2, center alignment, the default markup parser, and no border color.

paddingback to summary
private final int padding
parserback to summary
private final MarkupParser parser
textAlignback to summary
private final TextAlign textAlign

Constructor Detail

BoxConfigurationback to summary
private BoxConfiguration()
BoxConfigurationback to summary
private BoxConfiguration(BoxConfiguration.BoxConfigurationBuilder builder)

Method Detail

builderback to summary
public static BoxConfiguration.BoxConfigurationBuilder builder()

Returns a new builder for constructing a BoxConfiguration.

Returns:BoxConfiguration.BoxConfigurationBuilder

a new BoxConfigurationBuilder

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
getBorderColorback to summary
public AnsiCode[] getBorderColor()

Returns the ANSI codes applied to the box border, or an empty array if no border color has been set.

Returns:AnsiCode[]

a defensive copy of the border color codes; never null, may be empty

getPaddingback to summary
public int getPadding()

Returns the number of blank characters inserted between the box border and its content on each side.

Padding is deducted from the box's configured width, not added on top of it.

Returns:int

the padding value; always >= 0

getParserback to summary
public MarkupParser getParser()

Returns the markup parser used to interpret inline style tags in box content and border color specifications.

Returns:MarkupParser

the parser; never null

getTextAlignback to summary
public TextAlign getTextAlign()

Returns the horizontal alignment applied to content within the box.

Returns:TextAlign

the text alignment; never null

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 BoxConfiguration.BoxConfigurationBuilder

extends Object
Class Inheritance
  • java.lang.Object
  • io.github.kusoroadeolu.clique.configuration.BoxConfiguration.BoxConfigurationBuilder

Builder for BoxConfiguration.

Default values match those of BoxConfiguration#DEFAULT. Methods may be called in any order; each returns this for chaining.

This builder is not thread-safe.

Field Summary

Modifier and TypeField and Description
private AnsiCode[]
private int
private MarkupParser
private TextAlign

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public BoxConfiguration.BoxConfigurationBuilder

Returns:

this builder
borderColor
(String
a markup string representing the desired border color; must not be null
borderColor
)

Sets the border color by parsing a markup string using the currently configured parser.

public BoxConfiguration.BoxConfigurationBuilder

Returns:

this builder
borderColor
(AnsiCode...
the ANSI codes to apply to the border; must not be null
borderColor
)

Sets the border color directly from one or more AnsiCode instances.

public BoxConfiguration

Returns:

a new, immutable BoxConfiguration
build
()

Constructs a new BoxConfiguration from the current builder state.

public BoxConfiguration.BoxConfigurationBuilder

Returns:

this builder
padding
(int
the number of blank characters on each side; must be >= 0
padding
)

Sets the padding applied between the box border and its content.

public BoxConfiguration.BoxConfigurationBuilder

Returns:

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

Sets the markup parser used to interpret inline style tags in box content and border color markup strings.

public BoxConfiguration.BoxConfigurationBuilder

Returns:

this builder
textAlign
(TextAlign
the alignment to apply; must not be null
textAlign
)

Sets the horizontal alignment for content within the box.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

borderColorback to summary
private AnsiCode[] borderColor
paddingback to summary
private int padding
parserback to summary
private MarkupParser parser
textAlignback to summary
private TextAlign textAlign

Constructor Detail

BoxConfigurationBuilderback to summary
public BoxConfigurationBuilder()

Method Detail

borderColorback to summary
public BoxConfiguration.BoxConfigurationBuilder borderColor(String borderColor)

Sets the border color by parsing a markup string using the currently configured parser.

The markup string is resolved against the parser set via parser(MarkupParser) at the time this method is called. no color codes will be applied.

Parameters
borderColor:String

a markup string representing the desired border color; must not be null

Returns:BoxConfiguration.BoxConfigurationBuilder

this builder

borderColorback to summary
public BoxConfiguration.BoxConfigurationBuilder borderColor(AnsiCode... borderColor)

Sets the border color directly from one or more AnsiCode instances.

Parameters
borderColor:AnsiCode[]

the ANSI codes to apply to the border; must not be null

Returns:BoxConfiguration.BoxConfigurationBuilder

this builder

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

Constructs a new BoxConfiguration from the current builder state.

Returns:BoxConfiguration

a new, immutable BoxConfiguration

paddingback to summary
public BoxConfiguration.BoxConfigurationBuilder padding(int padding)

Sets the padding applied between the box border and its content.

Padding is deducted from the box's configured width, not added on top of it.

Parameters
padding:int

the number of blank characters on each side; must be >= 0

Returns:BoxConfiguration.BoxConfigurationBuilder

this builder

Exceptions
IllegalArgumentException:
if padding is negative
parserback to summary
public BoxConfiguration.BoxConfigurationBuilder parser(MarkupParser parser)

Sets the markup parser used to interpret inline style tags in box content and border color markup strings.

Parameters
parser:MarkupParser

the parser to use; must not be null

Returns:BoxConfiguration.BoxConfigurationBuilder

this builder

Exceptions
NullPointerException:
if parser is null
textAlignback to summary
public BoxConfiguration.BoxConfigurationBuilder textAlign(TextAlign textAlign)

Sets the horizontal alignment for content within the box.

Parameters
textAlign:TextAlign

the alignment to apply; must not be null

Returns:BoxConfiguration.BoxConfigurationBuilder

this builder

Exceptions
NullPointerException:
if textAlign is null