Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add join method that accepts JoinConfiguration.Builder #924

Merged
merged 4 commits into from
Jun 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions api/src/main/java/net/kyori/adventure/text/Component.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,38 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex
return Component.text().append(component).build();
}

/**
* Joins {@code components} using the configuration in {@code configBuilder}.
*
* @param configBuilder the join configuration
* @param components the components
* @return the resulting component
* @see JoinConfiguration#noSeparators()
* @see JoinConfiguration#separator(ComponentLike)
* @see JoinConfiguration#separators(ComponentLike, ComponentLike)
* @since 4.14.0
*/
@Contract(pure = true)
static @NotNull Component join(final JoinConfiguration.@NotNull Builder configBuilder, final @NotNull ComponentLike@NotNull... components) {
return join(configBuilder, Arrays.asList(components));
}

/**
* Joins {@code components} using the configuration in {@code configBuilder}.
*
* @param configBuilder the join configuration
* @param components the components
* @return the resulting component
* @see JoinConfiguration#noSeparators()
* @see JoinConfiguration#separator(ComponentLike)
* @see JoinConfiguration#separators(ComponentLike, ComponentLike)
* @since 4.14.0
*/
@Contract(pure = true)
static @NotNull Component join(final JoinConfiguration.@NotNull Builder configBuilder, final @NotNull Iterable<? extends ComponentLike> components) {
return JoinConfigurationImpl.join(configBuilder.build(), components);
}

/**
* Joins {@code components} using the configuration in {@code config}.
*
Expand Down