Interface JoinConfiguration
- All Superinterfaces:
Buildable<JoinConfiguration,
,JoinConfiguration.Builder> net.kyori.examination.Examinable
A join configuration consists of the following parts:
-
a prefix (optional)
a component to be prepended to the resulting component
-
a separator (optional)
a component to be placed between each component
-
a last separator (optional)
a component to be placed between the last two components
-
a suffix (optional)
a component to be appended to the resulting component
-
a convertor (required, defaults to
ComponentLike.asComponent()
)a function to change each
ComponentLike
that is being joined into aComponent
-
a predicate (required, defaults to
true
)a predicate that specifies if a given component should be included in the join process
-
a root
style
(required, defaults toStyle.empty()
)the style of the parent component that contains the joined components.
Note that the last separator only acts as an override for the normal separator.
This means that if you do not specify a last separator, the normal separator will be placed between the last two components.
To omit the final separator, but still include normal separators, use Component.empty()
as the last separator.
If specified, the join method can use a different last separator in the case where the amount of components being joined together is more than two. This can be used to insert a serial (or Oxford) comma if needed.
Null elements are not allowed in the input of the join methods or as output from the convertor. If you would like to exclude elements from being joined, use the predicate.
- Since:
- 4.9.0
- See Also:
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
A builder for join configurations. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull JoinConfiguration
Provides a join configuration that joins components together in the same mannerArrays.toString(Object[])
stringifies an array.static @NotNull JoinConfiguration.Builder
builder()
Creates a new builder.static @NotNull JoinConfiguration
commas
(boolean spaces) Provides a join configuration with no prefix or suffix that simply joins the components together using a single comma, matching a CSV like layout.@NotNull Function<ComponentLike,
Component> Gets the convertor of this join configuration.@Nullable Component
Gets the last separator of this join configuration.@Nullable Component
Gets the last separator that will be used instead of the normal last separator in the case where there are more than two components being joined.static @NotNull JoinConfiguration
newlines()
Provides a join configuration with no prefix or suffix that simply joins the components together using theComponent.newline()
component.static @NotNull JoinConfiguration
Gets a join configuration with no separators, prefix or suffix.@NotNull Style
Gets the style of the parent component that contains the joined components.@NotNull Predicate<ComponentLike>
Gets the predicate of this join configuration.@Nullable Component
prefix()
Gets the prefix of this join configuration.@Nullable Component
Gets the separator of this join configuration.static @NotNull JoinConfiguration
separator
(@Nullable ComponentLike separator) Creates a join configuration with a separator and no prefix or suffix.static @NotNull JoinConfiguration
separators
(@Nullable ComponentLike separator, @Nullable ComponentLike lastSeparator) Creates a join configuration with a separator and last separator but no prefix or suffix.static @NotNull JoinConfiguration
spaces()
Provides a join configuration with no prefix or suffix that simply joins the components together using theComponent.space()
component.@Nullable Component
suffix()
Gets the suffix of this join configuration.Methods inherited from interface net.kyori.examination.Examinable
examinableName, examinableProperties, examine
-
Method Details
-
builder
Creates a new builder.- Returns:
- a new builder
- Since:
- 4.9.0
-
noSeparators
Gets a join configuration with no separators, prefix or suffix.- Returns:
- the join configuration
- Since:
- 4.9.0
-
newlines
Provides a join configuration with no prefix or suffix that simply joins the components together using theComponent.newline()
component.A purely text based example of this syntax, without introducing the concepts of components, would join the two strings 'hello' and 'there' together, creating the following output: 'hello\nthere'.
- Returns:
- the join configuration
- Since:
- 4.10.0
-
spaces
Provides a join configuration with no prefix or suffix that simply joins the components together using theComponent.space()
component.A purely text based example of this syntax, without introducing the concepts of components, would join the two strings 'hello' and 'there' together, creating the following output: 'hello there'.
- Returns:
- the join configuration
- Since:
- 4.15.0
-
commas
Provides a join configuration with no prefix or suffix that simply joins the components together using a single comma, matching a CSV like layout.A purely text based example of this syntax, without introducing the concepts of components, would join the two strings 'hello' and 'there' together, creating either the output 'hello,there' or 'hello, there' depending on whether the passed boolean flag was
false
ortrue
respectively.- Parameters:
spaces
- a plain boolean flag indicating whether the returned comma-based join configuration should append a single space after each comma or not- Returns:
- the join configuration
- Since:
- 4.10.0
-
arrayLike
Provides a join configuration that joins components together in the same mannerArrays.toString(Object[])
stringifies an array. Specifically, the join configuration prefixes and suffixes the components with an open or closed square bracket respectively. Components themselves are joined together using a comma and a space.A purely text based example of this syntax, without introducing the concepts of components, would join the two strings 'hello' and 'there' together, creating the following output: '[hello, there]'.
- Returns:
- the join configuration
- Since:
- 4.10.0
-
separator
Creates a join configuration with a separator and no prefix or suffix.- Parameters:
separator
- the separator- Returns:
- the join configuration
- Since:
- 4.9.0
-
separators
@NotNull static @NotNull JoinConfiguration separators(@Nullable @Nullable ComponentLike separator, @Nullable @Nullable ComponentLike lastSeparator) Creates a join configuration with a separator and last separator but no prefix or suffix.- Parameters:
separator
- the separatorlastSeparator
- the last separator- Returns:
- the join configuration
- Since:
- 4.9.0
-
prefix
Gets the prefix of this join configuration.- Returns:
- the prefix
- Since:
- 4.9.0
-
suffix
Gets the suffix of this join configuration.- Returns:
- the suffix
- Since:
- 4.9.0
-
separator
Gets the separator of this join configuration.- Returns:
- the separator
- Since:
- 4.9.0
-
lastSeparator
Gets the last separator of this join configuration.- Returns:
- the last separator
- Since:
- 4.9.0
-
lastSeparatorIfSerial
Gets the last separator that will be used instead of the normal last separator in the case where there are more than two components being joined. This can be used to mimic a serial (or Oxford) comma.- Returns:
- the separator
- Since:
- 4.9.0
-
convertor
Gets the convertor of this join configuration.This is used to change the components that are going to be joined. It does not touch the prefix, suffix or any of the separators.
- Returns:
- the operator
- Since:
- 4.9.0
-
predicate
Gets the predicate of this join configuration.This is used to determine if a component is to be included in the join process. It does not touch the prefix, suffix or any of the separators.
- Returns:
- the predicate
- Since:
- 4.9.0
-
parentStyle
Gets the style of the parent component that contains the joined components.- Returns:
- the style
- Since:
- 4.11.0
-