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

public final Class FrameConfiguration

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.Frame.

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

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

Example:

FrameConfiguration config = FrameConfiguration.builder()
    .padding(3)
    .frameAlign(FrameAlign.LEFT)
    .borderColor("red")
    .build();
Since
3.1.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

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

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

private final int
private final MarkupParser

Constructor Summary

AccessConstructor and Description
private
private

Method Summary

Modifier and TypeMethod and Description
public static FrameConfiguration.FrameConfigurationBuilder
builder()

Returns a new builder for constructing a FrameConfiguration.

public boolean
equals(Object object)

Overrides java.lang.Object.equals.

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

public AnsiCode[]

Returns:

the border color codes; never null, may be empty
getBorderColor
()

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

public FrameAlign

Returns:

the frame alignment; never null
getFrameAlign
()

Returns the default horizontal alignment applied to nested content.

public int

Returns:

the padding value; always >= 0
getPadding
()

Returns the number of blank characters inserted between the frame 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 nested strings and border color specifications.

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

alignback to summary
private final FrameAlign align
borderColorback to summary
private final AnsiCode[] borderColor
DEFAULTback to summary
public static final FrameConfiguration DEFAULT

A default FrameConfiguration 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

Constructor Detail

FrameConfigurationback to summary
private FrameConfiguration()
FrameConfigurationback to summary
private FrameConfiguration(FrameConfiguration.FrameConfigurationBuilder builder)

Method Detail

builderback to summary
public static FrameConfiguration.FrameConfigurationBuilder builder()

Returns a new builder for constructing a FrameConfiguration.

Returns:FrameConfiguration.FrameConfigurationBuilder

a new FrameConfigurationBuilder

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 frame border, or an empty array if no border color has been set.

Returns:AnsiCode[]

the border color codes; never null, may be empty

getFrameAlignback to summary
public FrameAlign getFrameAlign()

Returns the default horizontal alignment applied to nested content.

Individual nodes may override this value at nest time via io.github.kusoroadeolu.clique.components.Frame#nest(String, io.github.kusoroadeolu.clique.configuration.FrameAlign).

Returns:FrameAlign

the frame alignment; never null

getPaddingback to summary
public int getPadding()

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

Returns:int

the padding value; always >= 0

getParserback to summary
public MarkupParser getParser()

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

Returns:MarkupParser

the parser; 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 FrameConfiguration.FrameConfigurationBuilder

extends Object
Class Inheritance
  • java.lang.Object
  • io.github.kusoroadeolu.clique.configuration.FrameConfiguration.FrameConfigurationBuilder

Builder for FrameConfiguration.

Default values match those of FrameConfiguration#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 FrameAlign
private int
private MarkupParser

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public FrameConfiguration.FrameConfigurationBuilder

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 FrameConfiguration.FrameConfigurationBuilder

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 FrameConfiguration

Returns:

a new, immutable FrameConfiguration
build
()

Constructs a new FrameConfiguration from the current builder state.

public FrameConfiguration.FrameConfigurationBuilder

Returns:

this builder
frameAlign
(FrameAlign
the alignment to apply; must not be null
align
)

Sets the default horizontal alignment for content nested in the frame.

public FrameConfiguration.FrameConfigurationBuilder

Returns:

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

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

public FrameConfiguration.FrameConfigurationBuilder

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 nested content and border color markup strings.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

borderColorback to summary
private AnsiCode[] borderColor
frameAlignback to summary
private FrameAlign frameAlign
paddingback to summary
private int padding
parserback to summary
private MarkupParser parser

Constructor Detail

FrameConfigurationBuilderback to summary
public FrameConfigurationBuilder()

Method Detail

borderColorback to summary
public FrameConfiguration.FrameConfigurationBuilder 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.

Parameters
borderColor:String

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

Returns:FrameConfiguration.FrameConfigurationBuilder

this builder

borderColorback to summary
public FrameConfiguration.FrameConfigurationBuilder 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:FrameConfiguration.FrameConfigurationBuilder

this builder

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

Constructs a new FrameConfiguration from the current builder state.

Returns:FrameConfiguration

a new, immutable FrameConfiguration

frameAlignback to summary
public FrameConfiguration.FrameConfigurationBuilder frameAlign(FrameAlign align)

Sets the default horizontal alignment for content nested in the frame.

This value is used when content is added without an explicit alignment. Individual nodes may override it at nest time.

Parameters
align:FrameAlign

the alignment to apply; must not be null

Returns:FrameConfiguration.FrameConfigurationBuilder

this builder

Exceptions
NullPointerException:
if align is null
paddingback to summary
public FrameConfiguration.FrameConfigurationBuilder padding(int padding)

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

Parameters
padding:int

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

Returns:FrameConfiguration.FrameConfigurationBuilder

this builder

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

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

Parameters
parser:MarkupParser

the parser to use; must not be null

Returns:FrameConfiguration.FrameConfigurationBuilder

this builder

Exceptions
NullPointerException:
if parser is null