org.incendo.cloud.minecraft.extras.ImmutableMinecraftHelp Maven / Gradle / Ivy
//
// MIT License
//
// Copyright (c) 2024 Incendo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
package org.incendo.cloud.minecraft.extras;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Objects;
import org.apiguardian.api.API;
import org.checkerframework.checker.index.qual.NonNegative;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.immutables.value.Generated;
/**
* Immutable implementation of {@link MinecraftHelp}.
*
* Use the builder to create immutable instances:
* {@code ImmutableMinecraftHelp.builder()}.
* Use the static factory method to create immutable instances:
* {@code ImmutableMinecraftHelp.of()}.
*/
@Generated(from = "MinecraftHelp", generator = "Immutables")
@SuppressWarnings({"unused", "all"})
@javax.annotation.Generated("org.immutables.processor.ProxyProcessor")
@API(status = API.Status.STABLE, consumers = "org.incendo.cloud.*")
public final class ImmutableMinecraftHelp extends MinecraftHelp {
private final org.incendo.cloud.@NonNull CommandManager commandManager;
private final org.incendo.cloud.minecraft.extras.@NonNull AudienceProvider audienceProvider;
private final java.lang.@NonNull String commandPrefix;
private transient final org.incendo.cloud.help.@NonNull HelpHandler helpHandler;
private final org.incendo.cloud.help.@NonNull CommandPredicate commandFilter;
private final MinecraftHelp.@NonNull DescriptionDecorator descriptionDecorator;
private final java.util.@NonNull Map messages;
private final MinecraftHelp.@NonNull MessageProvider messageProvider;
private final MinecraftHelp.@NonNull HelpColors colors;
private final @NonNegative int headerFooterLength;
private final @NonNegative int maxResultsPerPage;
private ImmutableMinecraftHelp(
org.incendo.cloud.@NonNull CommandManager commandManager,
org.incendo.cloud.minecraft.extras.@NonNull AudienceProvider audienceProvider,
java.lang.@NonNull String commandPrefix,
org.incendo.cloud.help.@NonNull CommandPredicate commandFilter,
MinecraftHelp.@NonNull DescriptionDecorator descriptionDecorator,
java.util.Map messages,
MinecraftHelp.@NonNull MessageProvider messageProvider,
MinecraftHelp.@NonNull HelpColors colors,
@NonNegative int headerFooterLength,
@NonNegative int maxResultsPerPage) {
this.commandManager = Objects.requireNonNull(commandManager, "commandManager");
this.audienceProvider = Objects.requireNonNull(audienceProvider, "audienceProvider");
this.commandPrefix = Objects.requireNonNull(commandPrefix, "commandPrefix");
initShim.commandFilter(Objects.requireNonNull(commandFilter, "commandFilter"));
initShim.descriptionDecorator(Objects.requireNonNull(descriptionDecorator, "descriptionDecorator"));
this.messages = createUnmodifiableMap(true, false, messages);
initShim.messageProvider(Objects.requireNonNull(messageProvider, "messageProvider"));
initShim.colors(Objects.requireNonNull(colors, "colors"));
initShim.headerFooterLength(headerFooterLength);
initShim.maxResultsPerPage(maxResultsPerPage);
this.helpHandler = initShim.helpHandler();
this.commandFilter = initShim.commandFilter();
this.descriptionDecorator = initShim.descriptionDecorator();
this.messageProvider = initShim.messageProvider();
this.colors = initShim.colors();
this.headerFooterLength = initShim.headerFooterLength();
this.maxResultsPerPage = initShim.maxResultsPerPage();
this.initShim = null;
}
private ImmutableMinecraftHelp(ImmutableMinecraftHelp.Builder builder) {
this.commandManager = builder.commandManager;
this.audienceProvider = builder.audienceProvider;
this.commandPrefix = builder.commandPrefix;
this.messages = createUnmodifiableMap(false, false, builder.messages);
if (builder.commandFilterIsSet()) {
initShim.commandFilter(builder.commandFilter);
}
if (builder.descriptionDecoratorIsSet()) {
initShim.descriptionDecorator(builder.descriptionDecorator);
}
if (builder.messageProviderIsSet()) {
initShim.messageProvider(builder.messageProvider);
}
if (builder.colorsIsSet()) {
initShim.colors(builder.colors);
}
if (builder.headerFooterLengthIsSet()) {
initShim.headerFooterLength(builder.headerFooterLength);
}
if (builder.maxResultsPerPageIsSet()) {
initShim.maxResultsPerPage(builder.maxResultsPerPage);
}
this.helpHandler = initShim.helpHandler();
this.commandFilter = initShim.commandFilter();
this.descriptionDecorator = initShim.descriptionDecorator();
this.messageProvider = initShim.messageProvider();
this.colors = initShim.colors();
this.headerFooterLength = initShim.headerFooterLength();
this.maxResultsPerPage = initShim.maxResultsPerPage();
this.initShim = null;
}
private ImmutableMinecraftHelp(
ImmutableMinecraftHelp original,
org.incendo.cloud.@NonNull CommandManager commandManager,
org.incendo.cloud.minecraft.extras.@NonNull AudienceProvider audienceProvider,
java.lang.@NonNull String commandPrefix,
org.incendo.cloud.help.@NonNull CommandPredicate commandFilter,
MinecraftHelp.@NonNull DescriptionDecorator descriptionDecorator,
java.util.@NonNull Map messages,
MinecraftHelp.@NonNull MessageProvider messageProvider,
MinecraftHelp.@NonNull HelpColors colors,
@NonNegative int headerFooterLength,
@NonNegative int maxResultsPerPage) {
this.commandManager = commandManager;
this.audienceProvider = audienceProvider;
this.commandPrefix = commandPrefix;
initShim.commandFilter(commandFilter);
initShim.descriptionDecorator(descriptionDecorator);
this.messages = messages;
initShim.messageProvider(messageProvider);
initShim.colors(colors);
initShim.headerFooterLength(headerFooterLength);
initShim.maxResultsPerPage(maxResultsPerPage);
this.helpHandler = initShim.helpHandler();
this.commandFilter = initShim.commandFilter();
this.descriptionDecorator = initShim.descriptionDecorator();
this.messageProvider = initShim.messageProvider();
this.colors = initShim.colors();
this.headerFooterLength = initShim.headerFooterLength();
this.maxResultsPerPage = initShim.maxResultsPerPage();
this.initShim = null;
}
private static final byte STAGE_INITIALIZING = -1;
private static final byte STAGE_UNINITIALIZED = 0;
private static final byte STAGE_INITIALIZED = 1;
private transient volatile InitShim initShim = new InitShim();
@Generated(from = "MinecraftHelp", generator = "Immutables")
private final class InitShim {
private byte helpHandlerBuildStage = STAGE_UNINITIALIZED;
private org.incendo.cloud.help.@NonNull HelpHandler helpHandler;
org.incendo.cloud.help.@NonNull HelpHandler helpHandler() {
if (helpHandlerBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (helpHandlerBuildStage == STAGE_UNINITIALIZED) {
helpHandlerBuildStage = STAGE_INITIALIZING;
this.helpHandler = Objects.requireNonNull(ImmutableMinecraftHelp.super.helpHandler(), "helpHandler");
helpHandlerBuildStage = STAGE_INITIALIZED;
}
return this.helpHandler;
}
private byte commandFilterBuildStage = STAGE_UNINITIALIZED;
private org.incendo.cloud.help.@NonNull CommandPredicate commandFilter;
org.incendo.cloud.help.@NonNull CommandPredicate commandFilter() {
if (commandFilterBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (commandFilterBuildStage == STAGE_UNINITIALIZED) {
commandFilterBuildStage = STAGE_INITIALIZING;
this.commandFilter = Objects.requireNonNull(ImmutableMinecraftHelp.super.commandFilter(), "commandFilter");
commandFilterBuildStage = STAGE_INITIALIZED;
}
return this.commandFilter;
}
void commandFilter(org.incendo.cloud.help.@NonNull CommandPredicate commandFilter) {
this.commandFilter = commandFilter;
commandFilterBuildStage = STAGE_INITIALIZED;
}
private byte descriptionDecoratorBuildStage = STAGE_UNINITIALIZED;
private MinecraftHelp.@NonNull DescriptionDecorator descriptionDecorator;
MinecraftHelp.@NonNull DescriptionDecorator descriptionDecorator() {
if (descriptionDecoratorBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (descriptionDecoratorBuildStage == STAGE_UNINITIALIZED) {
descriptionDecoratorBuildStage = STAGE_INITIALIZING;
this.descriptionDecorator = Objects.requireNonNull(ImmutableMinecraftHelp.super.descriptionDecorator(), "descriptionDecorator");
descriptionDecoratorBuildStage = STAGE_INITIALIZED;
}
return this.descriptionDecorator;
}
void descriptionDecorator(MinecraftHelp.@NonNull DescriptionDecorator descriptionDecorator) {
this.descriptionDecorator = descriptionDecorator;
descriptionDecoratorBuildStage = STAGE_INITIALIZED;
}
private byte messageProviderBuildStage = STAGE_UNINITIALIZED;
private MinecraftHelp.@NonNull MessageProvider messageProvider;
MinecraftHelp.@NonNull MessageProvider messageProvider() {
if (messageProviderBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (messageProviderBuildStage == STAGE_UNINITIALIZED) {
messageProviderBuildStage = STAGE_INITIALIZING;
this.messageProvider = Objects.requireNonNull(ImmutableMinecraftHelp.super.messageProvider(), "messageProvider");
messageProviderBuildStage = STAGE_INITIALIZED;
}
return this.messageProvider;
}
void messageProvider(MinecraftHelp.@NonNull MessageProvider messageProvider) {
this.messageProvider = messageProvider;
messageProviderBuildStage = STAGE_INITIALIZED;
}
private byte colorsBuildStage = STAGE_UNINITIALIZED;
private MinecraftHelp.@NonNull HelpColors colors;
MinecraftHelp.@NonNull HelpColors colors() {
if (colorsBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (colorsBuildStage == STAGE_UNINITIALIZED) {
colorsBuildStage = STAGE_INITIALIZING;
this.colors = Objects.requireNonNull(ImmutableMinecraftHelp.super.colors(), "colors");
colorsBuildStage = STAGE_INITIALIZED;
}
return this.colors;
}
void colors(MinecraftHelp.@NonNull HelpColors colors) {
this.colors = colors;
colorsBuildStage = STAGE_INITIALIZED;
}
private byte headerFooterLengthBuildStage = STAGE_UNINITIALIZED;
private @NonNegative int headerFooterLength;
@NonNegative int headerFooterLength() {
if (headerFooterLengthBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (headerFooterLengthBuildStage == STAGE_UNINITIALIZED) {
headerFooterLengthBuildStage = STAGE_INITIALIZING;
this.headerFooterLength = ImmutableMinecraftHelp.super.headerFooterLength();
headerFooterLengthBuildStage = STAGE_INITIALIZED;
}
return this.headerFooterLength;
}
void headerFooterLength(@NonNegative int headerFooterLength) {
this.headerFooterLength = headerFooterLength;
headerFooterLengthBuildStage = STAGE_INITIALIZED;
}
private byte maxResultsPerPageBuildStage = STAGE_UNINITIALIZED;
private @NonNegative int maxResultsPerPage;
@NonNegative int maxResultsPerPage() {
if (maxResultsPerPageBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (maxResultsPerPageBuildStage == STAGE_UNINITIALIZED) {
maxResultsPerPageBuildStage = STAGE_INITIALIZING;
this.maxResultsPerPage = ImmutableMinecraftHelp.super.maxResultsPerPage();
maxResultsPerPageBuildStage = STAGE_INITIALIZED;
}
return this.maxResultsPerPage;
}
void maxResultsPerPage(@NonNegative int maxResultsPerPage) {
this.maxResultsPerPage = maxResultsPerPage;
maxResultsPerPageBuildStage = STAGE_INITIALIZED;
}
private String formatInitCycleMessage() {
List attributes = new ArrayList<>();
if (helpHandlerBuildStage == STAGE_INITIALIZING) attributes.add("helpHandler");
if (commandFilterBuildStage == STAGE_INITIALIZING) attributes.add("commandFilter");
if (descriptionDecoratorBuildStage == STAGE_INITIALIZING) attributes.add("descriptionDecorator");
if (messageProviderBuildStage == STAGE_INITIALIZING) attributes.add("messageProvider");
if (colorsBuildStage == STAGE_INITIALIZING) attributes.add("colors");
if (headerFooterLengthBuildStage == STAGE_INITIALIZING) attributes.add("headerFooterLength");
if (maxResultsPerPageBuildStage == STAGE_INITIALIZING) attributes.add("maxResultsPerPage");
return "Cannot build MinecraftHelp, attribute initializers form cycle " + attributes;
}
}
/**
* Returns the command manager instance.
* @return command manager
*/
@Override
public org.incendo.cloud.@NonNull CommandManager commandManager() {
return commandManager;
}
/**
* Returns the audience provider that was used to create this instance.
* @return audience provider
*/
@Override
public org.incendo.cloud.minecraft.extras.@NonNull AudienceProvider audienceProvider() {
return audienceProvider;
}
/**
* Returns the command prefix.
* @return command prefix
* @since 2.0.0
*/
@Override
public java.lang.@NonNull String commandPrefix() {
return commandPrefix;
}
/**
* Returns the help handler.
* @return the help handler
* @since 2.0.0
*/
@Override
public org.incendo.cloud.help.@NonNull HelpHandler helpHandler() {
InitShim shim = this.initShim;
return shim != null
? shim.helpHandler()
: this.helpHandler;
}
/**
* Returns the filter that determines what commands are visible inside the help menu.
*
* The default filter is {@link org.incendo.cloud.help.CommandPredicate#acceptAll()}.
* @return the filter
* @since 2.0.0
*/
@Override
public org.incendo.cloud.help.@NonNull CommandPredicate commandFilter() {
InitShim shim = this.initShim;
return shim != null
? shim.commandFilter()
: this.commandFilter;
}
/**
* Returns the description decorator which turns descriptions into components.
*
* The default decorator is {@link DescriptionDecorator#text()}.
* @return the decorator
* @since 2.0.0
*/
@Override
public MinecraftHelp.@NonNull DescriptionDecorator descriptionDecorator() {
InitShim shim = this.initShim;
return shim != null
? shim.descriptionDecorator()
: this.descriptionDecorator;
}
/**
* Returns the messages which are used by the default {@link MessageProvider}.
*
* Placeholders in the format {@literal } will be replaced.
* @return the messages
* @since 2.0.0
*/
@Override
public java.util.@NonNull Map messages() {
return messages;
}
/**
* Returns the message provider which is used to retrieve messages from message keys.
*
* The keys are constants in {@link MinecraftHelp}.
* @return the message provider
* @since 2.0.0
*/
@Override
public MinecraftHelp.@NonNull MessageProvider messageProvider() {
InitShim shim = this.initShim;
return shim != null
? shim.messageProvider()
: this.messageProvider;
}
/**
* Returns the colors used for help messages.
*
* Defaults to {@link #DEFAULT_HELP_COLORS}.
* @return the active {@link HelpColors}
* @since 2.0.0
*/
@Override
public MinecraftHelp.@NonNull HelpColors colors() {
InitShim shim = this.initShim;
return shim != null
? shim.colors()
: this.colors;
}
/**
* Returns the length of the header/footer of help menus.
*
* Defaults to {@link #DEFAULT_HEADER_FOOTER_LENGTH}.
* @return the length
* @since 2.0.0
*/
@Override
public @NonNegative int headerFooterLength() {
InitShim shim = this.initShim;
return shim != null
? shim.headerFooterLength()
: this.headerFooterLength;
}
/**
* Returns the maximum number of help results to display on a page.
*
* Defaults to {@link MinecraftHelp#DEFAULT_MAX_RESULTS_PER_PAGE}.
* @return the maximum number of results
* @since 2.0.0
*/
@Override
public @NonNegative int maxResultsPerPage() {
InitShim shim = this.initShim;
return shim != null
? shim.maxResultsPerPage()
: this.maxResultsPerPage;
}
/**
* Copy the current immutable object by setting a value for the {@link MinecraftHelp#commandManager() commandManager} attribute.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for commandManager
* @return A modified copy of the {@code this} object
*/
public final ImmutableMinecraftHelp withCommandManager(org.incendo.cloud.@NonNull CommandManager value) {
if (this.commandManager == value) return this;
org.incendo.cloud.@NonNull CommandManager newValue = Objects.requireNonNull(value, "commandManager");
return new ImmutableMinecraftHelp<>(
this,
newValue,
this.audienceProvider,
this.commandPrefix,
this.commandFilter,
this.descriptionDecorator,
this.messages,
this.messageProvider,
this.colors,
this.headerFooterLength,
this.maxResultsPerPage);
}
/**
* Copy the current immutable object by setting a value for the {@link MinecraftHelp#audienceProvider() audienceProvider} attribute.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for audienceProvider
* @return A modified copy of the {@code this} object
*/
public final ImmutableMinecraftHelp withAudienceProvider(org.incendo.cloud.minecraft.extras.@NonNull AudienceProvider value) {
if (this.audienceProvider == value) return this;
org.incendo.cloud.minecraft.extras.@NonNull AudienceProvider newValue = Objects.requireNonNull(value, "audienceProvider");
return new ImmutableMinecraftHelp<>(
this,
this.commandManager,
newValue,
this.commandPrefix,
this.commandFilter,
this.descriptionDecorator,
this.messages,
this.messageProvider,
this.colors,
this.headerFooterLength,
this.maxResultsPerPage);
}
/**
* Copy the current immutable object by setting a value for the {@link MinecraftHelp#commandPrefix() commandPrefix} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for commandPrefix
* @return A modified copy of the {@code this} object
*/
public final ImmutableMinecraftHelp withCommandPrefix(java.lang.@NonNull String value) {
java.lang.@NonNull String newValue = Objects.requireNonNull(value, "commandPrefix");
if (this.commandPrefix.equals(newValue)) return this;
return new ImmutableMinecraftHelp<>(
this,
this.commandManager,
this.audienceProvider,
newValue,
this.commandFilter,
this.descriptionDecorator,
this.messages,
this.messageProvider,
this.colors,
this.headerFooterLength,
this.maxResultsPerPage);
}
/**
* Copy the current immutable object by setting a value for the {@link MinecraftHelp#commandFilter() commandFilter} attribute.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for commandFilter
* @return A modified copy of the {@code this} object
*/
public final ImmutableMinecraftHelp withCommandFilter(org.incendo.cloud.help.@NonNull CommandPredicate value) {
if (this.commandFilter == value) return this;
org.incendo.cloud.help.@NonNull CommandPredicate newValue = Objects.requireNonNull(value, "commandFilter");
return new ImmutableMinecraftHelp<>(
this,
this.commandManager,
this.audienceProvider,
this.commandPrefix,
newValue,
this.descriptionDecorator,
this.messages,
this.messageProvider,
this.colors,
this.headerFooterLength,
this.maxResultsPerPage);
}
/**
* Copy the current immutable object by setting a value for the {@link MinecraftHelp#descriptionDecorator() descriptionDecorator} attribute.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for descriptionDecorator
* @return A modified copy of the {@code this} object
*/
public final ImmutableMinecraftHelp withDescriptionDecorator(MinecraftHelp.@NonNull DescriptionDecorator value) {
if (this.descriptionDecorator == value) return this;
MinecraftHelp.@NonNull DescriptionDecorator newValue = Objects.requireNonNull(value, "descriptionDecorator");
return new ImmutableMinecraftHelp<>(
this,
this.commandManager,
this.audienceProvider,
this.commandPrefix,
this.commandFilter,
newValue,
this.messages,
this.messageProvider,
this.colors,
this.headerFooterLength,
this.maxResultsPerPage);
}
/**
* Copy the current immutable object by replacing the {@link MinecraftHelp#messages() messages} map with the specified map.
* Nulls are not permitted as keys or values.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param entries The entries to be added to the messages map
* @return A modified copy of {@code this} object
*/
public final ImmutableMinecraftHelp withMessages(java.util.Map entries) {
if (this.messages == entries) return this;
java.util.@NonNull Map newValue = createUnmodifiableMap(true, false, entries);
return new ImmutableMinecraftHelp<>(
this,
this.commandManager,
this.audienceProvider,
this.commandPrefix,
this.commandFilter,
this.descriptionDecorator,
newValue,
this.messageProvider,
this.colors,
this.headerFooterLength,
this.maxResultsPerPage);
}
/**
* Copy the current immutable object by setting a value for the {@link MinecraftHelp#messageProvider() messageProvider} attribute.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for messageProvider
* @return A modified copy of the {@code this} object
*/
public final ImmutableMinecraftHelp withMessageProvider(MinecraftHelp.@NonNull MessageProvider value) {
if (this.messageProvider == value) return this;
MinecraftHelp.@NonNull MessageProvider newValue = Objects.requireNonNull(value, "messageProvider");
return new ImmutableMinecraftHelp<>(
this,
this.commandManager,
this.audienceProvider,
this.commandPrefix,
this.commandFilter,
this.descriptionDecorator,
this.messages,
newValue,
this.colors,
this.headerFooterLength,
this.maxResultsPerPage);
}
/**
* Copy the current immutable object by setting a value for the {@link MinecraftHelp#colors() colors} attribute.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for colors
* @return A modified copy of the {@code this} object
*/
public final ImmutableMinecraftHelp withColors(MinecraftHelp.@NonNull HelpColors value) {
if (this.colors == value) return this;
MinecraftHelp.@NonNull HelpColors newValue = Objects.requireNonNull(value, "colors");
return new ImmutableMinecraftHelp<>(
this,
this.commandManager,
this.audienceProvider,
this.commandPrefix,
this.commandFilter,
this.descriptionDecorator,
this.messages,
this.messageProvider,
newValue,
this.headerFooterLength,
this.maxResultsPerPage);
}
/**
* Copy the current immutable object by setting a value for the {@link MinecraftHelp#headerFooterLength() headerFooterLength} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for headerFooterLength
* @return A modified copy of the {@code this} object
*/
public final ImmutableMinecraftHelp withHeaderFooterLength(@NonNegative int value) {
if (this.headerFooterLength == value) return this;
return new ImmutableMinecraftHelp<>(
this,
this.commandManager,
this.audienceProvider,
this.commandPrefix,
this.commandFilter,
this.descriptionDecorator,
this.messages,
this.messageProvider,
this.colors,
value,
this.maxResultsPerPage);
}
/**
* Copy the current immutable object by setting a value for the {@link MinecraftHelp#maxResultsPerPage() maxResultsPerPage} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for maxResultsPerPage
* @return A modified copy of the {@code this} object
*/
public final ImmutableMinecraftHelp withMaxResultsPerPage(@NonNegative int value) {
if (this.maxResultsPerPage == value) return this;
return new ImmutableMinecraftHelp<>(
this,
this.commandManager,
this.audienceProvider,
this.commandPrefix,
this.commandFilter,
this.descriptionDecorator,
this.messages,
this.messageProvider,
this.colors,
this.headerFooterLength,
value);
}
/**
* This instance is equal to all instances of {@code ImmutableMinecraftHelp} that have equal attribute values.
* @return {@code true} if {@code this} is equal to {@code another} instance
*/
@Override
public boolean equals(Object another) {
if (this == another) return true;
return another instanceof ImmutableMinecraftHelp>
&& equalTo(0, (ImmutableMinecraftHelp>) another);
}
private boolean equalTo(int synthetic, ImmutableMinecraftHelp> another) {
return commandManager.equals(another.commandManager)
&& audienceProvider.equals(another.audienceProvider)
&& commandPrefix.equals(another.commandPrefix)
&& helpHandler.equals(another.helpHandler)
&& commandFilter.equals(another.commandFilter)
&& descriptionDecorator.equals(another.descriptionDecorator)
&& messages.equals(another.messages)
&& messageProvider.equals(another.messageProvider)
&& colors.equals(another.colors)
&& headerFooterLength == another.headerFooterLength
&& maxResultsPerPage == another.maxResultsPerPage;
}
/**
* Computes a hash code from attributes: {@code commandManager}, {@code audienceProvider}, {@code commandPrefix}, {@code helpHandler}, {@code commandFilter}, {@code descriptionDecorator}, {@code messages}, {@code messageProvider}, {@code colors}, {@code headerFooterLength}, {@code maxResultsPerPage}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + commandManager.hashCode();
h += (h << 5) + audienceProvider.hashCode();
h += (h << 5) + commandPrefix.hashCode();
h += (h << 5) + helpHandler.hashCode();
h += (h << 5) + commandFilter.hashCode();
h += (h << 5) + descriptionDecorator.hashCode();
h += (h << 5) + messages.hashCode();
h += (h << 5) + messageProvider.hashCode();
h += (h << 5) + colors.hashCode();
h += (h << 5) + headerFooterLength;
h += (h << 5) + maxResultsPerPage;
return h;
}
/**
* Prints the immutable value {@code MinecraftHelp} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return "MinecraftHelp{"
+ "commandManager=" + commandManager
+ ", audienceProvider=" + audienceProvider
+ ", commandPrefix=" + commandPrefix
+ ", helpHandler=" + helpHandler
+ ", commandFilter=" + commandFilter
+ ", descriptionDecorator=" + descriptionDecorator
+ ", messages=" + messages
+ ", messageProvider=" + messageProvider
+ ", colors=" + colors
+ ", headerFooterLength=" + headerFooterLength
+ ", maxResultsPerPage=" + maxResultsPerPage
+ "}";
}
/**
* Construct a new immutable {@code MinecraftHelp} instance.
* @param generic parameter C
* @param commandManager The value for the {@code commandManager} attribute
* @param audienceProvider The value for the {@code audienceProvider} attribute
* @param commandPrefix The value for the {@code commandPrefix} attribute
* @param commandFilter The value for the {@code commandFilter} attribute
* @param descriptionDecorator The value for the {@code descriptionDecorator} attribute
* @param messages The value for the {@code messages} attribute
* @param messageProvider The value for the {@code messageProvider} attribute
* @param colors The value for the {@code colors} attribute
* @param headerFooterLength The value for the {@code headerFooterLength} attribute
* @param maxResultsPerPage The value for the {@code maxResultsPerPage} attribute
* @return An immutable MinecraftHelp instance
*/
public static ImmutableMinecraftHelp of(org.incendo.cloud.@NonNull CommandManager commandManager, org.incendo.cloud.minecraft.extras.@NonNull AudienceProvider audienceProvider, java.lang.@NonNull String commandPrefix, org.incendo.cloud.help.@NonNull CommandPredicate commandFilter, MinecraftHelp.@NonNull DescriptionDecorator descriptionDecorator, java.util.Map messages, MinecraftHelp.@NonNull MessageProvider messageProvider, MinecraftHelp.@NonNull HelpColors colors, @NonNegative int headerFooterLength, @NonNegative int maxResultsPerPage) {
return new ImmutableMinecraftHelp<>(commandManager, audienceProvider, commandPrefix, commandFilter, descriptionDecorator, messages, messageProvider, colors, headerFooterLength, maxResultsPerPage);
}
/**
* Creates an immutable copy of a {@link MinecraftHelp} value.
* Uses accessors to get values to initialize the new immutable instance.
* If an instance is already immutable, it is returned as is.
* @param generic parameter C
* @param instance The instance to copy
* @return A copied immutable MinecraftHelp instance
*/
public static ImmutableMinecraftHelp copyOf(MinecraftHelp instance) {
if (instance instanceof ImmutableMinecraftHelp>) {
return (ImmutableMinecraftHelp) instance;
}
return ((ImmutableMinecraftHelp.Builder) ImmutableMinecraftHelp.builder())
.commandManager(instance.commandManager())
.audienceProvider(instance.audienceProvider())
.commandPrefix(instance.commandPrefix())
.commandFilter(instance.commandFilter())
.descriptionDecorator(instance.descriptionDecorator())
.messages(instance.messages())
.messageProvider(instance.messageProvider())
.colors(instance.colors())
.headerFooterLength(instance.headerFooterLength())
.maxResultsPerPage(instance.maxResultsPerPage())
.build();
}
/**
* Creates a builder for {@link ImmutableMinecraftHelp ImmutableMinecraftHelp}.
*
* ImmutableMinecraftHelp.<C>builder()
* .commandManager(org.incendo.cloud.@org.checkerframework.checker.nullness.qual.NonNull CommandManager<C>) // required {@link MinecraftHelp#commandManager() commandManager}
* .audienceProvider(org.incendo.cloud.minecraft.extras.@org.checkerframework.checker.nullness.qual.NonNull AudienceProvider<C>) // required {@link MinecraftHelp#audienceProvider() audienceProvider}
* .commandPrefix(@org.checkerframework.checker.nullness.qual.NonNull String) // required {@link MinecraftHelp#commandPrefix() commandPrefix}
* .commandFilter(org.incendo.cloud.help.@org.checkerframework.checker.nullness.qual.NonNull CommandPredicate<C>) // optional {@link MinecraftHelp#commandFilter() commandFilter}
* .descriptionDecorator(org.incendo.cloud.minecraft.extras.MinecraftHelp.@org.checkerframework.checker.nullness.qual.NonNull DescriptionDecorator<C>) // optional {@link MinecraftHelp#descriptionDecorator() descriptionDecorator}
* .messages|messages(String => String) // {@link MinecraftHelp#messages() messages} mappings
* .messageProvider(org.incendo.cloud.minecraft.extras.MinecraftHelp.@org.checkerframework.checker.nullness.qual.NonNull MessageProvider<C>) // optional {@link MinecraftHelp#messageProvider() messageProvider}
* .colors(org.incendo.cloud.minecraft.extras.MinecraftHelp.@org.checkerframework.checker.nullness.qual.NonNull HelpColors) // optional {@link MinecraftHelp#colors() colors}
* .headerFooterLength(@org.checkerframework.checker.index.qual.NonNegative int) // optional {@link MinecraftHelp#headerFooterLength() headerFooterLength}
* .maxResultsPerPage(@org.checkerframework.checker.index.qual.NonNegative int) // optional {@link MinecraftHelp#maxResultsPerPage() maxResultsPerPage}
* .build();
*
* @param generic parameter C
* @return A new ImmutableMinecraftHelp builder
*/
public static CommandManagerBuildStage builder() {
return new ImmutableMinecraftHelp.Builder<>();
}
/**
* Builds instances of type {@link ImmutableMinecraftHelp ImmutableMinecraftHelp}.
* Initialize attributes and then invoke the {@link #build()} method to create an
* immutable instance.
* {@code Builder} is not thread-safe and generally should not be stored in a field or collection,
* but instead used immediately to create instances.
*/
@Generated(from = "MinecraftHelp", generator = "Immutables")
public static final class Builder
implements CommandManagerBuildStage, AudienceProviderBuildStage, CommandPrefixBuildStage, BuildFinal {
private static final long INIT_BIT_COMMAND_MANAGER = 0x1L;
private static final long INIT_BIT_AUDIENCE_PROVIDER = 0x2L;
private static final long INIT_BIT_COMMAND_PREFIX = 0x4L;
private static final long OPT_BIT_COMMAND_FILTER = 0x1L;
private static final long OPT_BIT_DESCRIPTION_DECORATOR = 0x2L;
private static final long OPT_BIT_MESSAGE_PROVIDER = 0x4L;
private static final long OPT_BIT_COLORS = 0x8L;
private static final long OPT_BIT_HEADER_FOOTER_LENGTH = 0x10L;
private static final long OPT_BIT_MAX_RESULTS_PER_PAGE = 0x20L;
private long initBits = 0x7L;
private long optBits;
private org.incendo.cloud.@NonNull CommandManager commandManager;
private org.incendo.cloud.minecraft.extras.@NonNull AudienceProvider audienceProvider;
private java.lang.@NonNull String commandPrefix;
private org.incendo.cloud.help.@NonNull CommandPredicate commandFilter;
private MinecraftHelp.@NonNull DescriptionDecorator descriptionDecorator;
private final java.util.Map messages = new LinkedHashMap();
private MinecraftHelp.@NonNull MessageProvider messageProvider;
private MinecraftHelp.@NonNull HelpColors colors;
private @NonNegative int headerFooterLength;
private @NonNegative int maxResultsPerPage;
private Builder() {
}
/**
* Initializes the value for the {@link MinecraftHelp#commandManager() commandManager} attribute.
* @param commandManager The value for commandManager
* @return {@code this} builder for use in a chained invocation
*/
public final Builder commandManager(org.incendo.cloud.@NonNull CommandManager commandManager) {
checkNotIsSet(commandManagerIsSet(), "commandManager");
this.commandManager = Objects.requireNonNull(commandManager, "commandManager");
initBits &= ~INIT_BIT_COMMAND_MANAGER;
return this;
}
/**
* Initializes the value for the {@link MinecraftHelp#audienceProvider() audienceProvider} attribute.
* @param audienceProvider The value for audienceProvider
* @return {@code this} builder for use in a chained invocation
*/
public final Builder audienceProvider(org.incendo.cloud.minecraft.extras.@NonNull AudienceProvider audienceProvider) {
checkNotIsSet(audienceProviderIsSet(), "audienceProvider");
this.audienceProvider = Objects.requireNonNull(audienceProvider, "audienceProvider");
initBits &= ~INIT_BIT_AUDIENCE_PROVIDER;
return this;
}
/**
* Initializes the value for the {@link MinecraftHelp#commandPrefix() commandPrefix} attribute.
* @param commandPrefix The value for commandPrefix
* @return {@code this} builder for use in a chained invocation
*/
public final Builder commandPrefix(java.lang.@NonNull String commandPrefix) {
checkNotIsSet(commandPrefixIsSet(), "commandPrefix");
this.commandPrefix = Objects.requireNonNull(commandPrefix, "commandPrefix");
initBits &= ~INIT_BIT_COMMAND_PREFIX;
return this;
}
/**
* Initializes the value for the {@link MinecraftHelp#commandFilter() commandFilter} attribute.
* If not set, this attribute will have a default value as returned by the initializer of {@link MinecraftHelp#commandFilter() commandFilter}.
* @param commandFilter The value for commandFilter
* @return {@code this} builder for use in a chained invocation
*/
public final Builder commandFilter(org.incendo.cloud.help.@NonNull CommandPredicate commandFilter) {
checkNotIsSet(commandFilterIsSet(), "commandFilter");
this.commandFilter = Objects.requireNonNull(commandFilter, "commandFilter");
optBits |= OPT_BIT_COMMAND_FILTER;
return this;
}
/**
* Initializes the value for the {@link MinecraftHelp#descriptionDecorator() descriptionDecorator} attribute.
* If not set, this attribute will have a default value as returned by the initializer of {@link MinecraftHelp#descriptionDecorator() descriptionDecorator}.
* @param descriptionDecorator The value for descriptionDecorator
* @return {@code this} builder for use in a chained invocation
*/
public final Builder descriptionDecorator(MinecraftHelp.@NonNull DescriptionDecorator descriptionDecorator) {
checkNotIsSet(descriptionDecoratorIsSet(), "descriptionDecorator");
this.descriptionDecorator = Objects.requireNonNull(descriptionDecorator, "descriptionDecorator");
optBits |= OPT_BIT_DESCRIPTION_DECORATOR;
return this;
}
/**
* Put one entry to the {@link MinecraftHelp#messages() messages} map.
* @param key The key in the messages map
* @param value The associated value in the messages map
* @return {@code this} builder for use in a chained invocation
*/
public final Builder messages(String key, String value) {
this.messages.put(
Objects.requireNonNull(key, "messages key"),
Objects.requireNonNull(value, value == null ? "messages value for key: " + key : null));
return this;
}
/**
* Put one entry to the {@link MinecraftHelp#messages() messages} map. Nulls are not permitted
* @param entry The key and value entry
* @return {@code this} builder for use in a chained invocation
*/
public final Builder messages(java.util.Map.Entry entry) {
String k = entry.getKey();
String v = entry.getValue();
this.messages.put(
Objects.requireNonNull(k, "messages key"),
Objects.requireNonNull(v, v == null ? "messages value for key: " + k : null));
return this;
}
/**
* Put all mappings from the specified map as entries to {@link MinecraftHelp#messages() messages} map. Nulls are not permitted
* @param entries The entries that will be added to the messages map
* @return {@code this} builder for use in a chained invocation
*/
public final Builder messages(java.util.Map entries) {
for (java.util.Map.Entry e : entries.entrySet()) {
String k = e.getKey();
String v = e.getValue();
this.messages.put(
Objects.requireNonNull(k, "messages key"),
Objects.requireNonNull(v, v == null ? "messages value for key: " + k : null));
}
return this;
}
/**
* Initializes the value for the {@link MinecraftHelp#messageProvider() messageProvider} attribute.
* If not set, this attribute will have a default value as returned by the initializer of {@link MinecraftHelp#messageProvider() messageProvider}.
* @param messageProvider The value for messageProvider
* @return {@code this} builder for use in a chained invocation
*/
public final Builder messageProvider(MinecraftHelp.@NonNull MessageProvider messageProvider) {
checkNotIsSet(messageProviderIsSet(), "messageProvider");
this.messageProvider = Objects.requireNonNull(messageProvider, "messageProvider");
optBits |= OPT_BIT_MESSAGE_PROVIDER;
return this;
}
/**
* Initializes the value for the {@link MinecraftHelp#colors() colors} attribute.
* If not set, this attribute will have a default value as returned by the initializer of {@link MinecraftHelp#colors() colors}.
* @param colors The value for colors
* @return {@code this} builder for use in a chained invocation
*/
public final Builder colors(MinecraftHelp.@NonNull HelpColors colors) {
checkNotIsSet(colorsIsSet(), "colors");
this.colors = Objects.requireNonNull(colors, "colors");
optBits |= OPT_BIT_COLORS;
return this;
}
/**
* Initializes the value for the {@link MinecraftHelp#headerFooterLength() headerFooterLength} attribute.
* If not set, this attribute will have a default value as returned by the initializer of {@link MinecraftHelp#headerFooterLength() headerFooterLength}.
* @param headerFooterLength The value for headerFooterLength
* @return {@code this} builder for use in a chained invocation
*/
public final Builder headerFooterLength(@NonNegative int headerFooterLength) {
checkNotIsSet(headerFooterLengthIsSet(), "headerFooterLength");
this.headerFooterLength = headerFooterLength;
optBits |= OPT_BIT_HEADER_FOOTER_LENGTH;
return this;
}
/**
* Initializes the value for the {@link MinecraftHelp#maxResultsPerPage() maxResultsPerPage} attribute.
* If not set, this attribute will have a default value as returned by the initializer of {@link MinecraftHelp#maxResultsPerPage() maxResultsPerPage}.
* @param maxResultsPerPage The value for maxResultsPerPage
* @return {@code this} builder for use in a chained invocation
*/
public final Builder maxResultsPerPage(@NonNegative int maxResultsPerPage) {
checkNotIsSet(maxResultsPerPageIsSet(), "maxResultsPerPage");
this.maxResultsPerPage = maxResultsPerPage;
optBits |= OPT_BIT_MAX_RESULTS_PER_PAGE;
return this;
}
/**
* Builds a new {@link ImmutableMinecraftHelp ImmutableMinecraftHelp}.
* @return An immutable instance of MinecraftHelp
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableMinecraftHelp build() {
checkRequiredAttributes();
return new ImmutableMinecraftHelp(this);
}
private boolean commandFilterIsSet() {
return (optBits & OPT_BIT_COMMAND_FILTER) != 0;
}
private boolean descriptionDecoratorIsSet() {
return (optBits & OPT_BIT_DESCRIPTION_DECORATOR) != 0;
}
private boolean messageProviderIsSet() {
return (optBits & OPT_BIT_MESSAGE_PROVIDER) != 0;
}
private boolean colorsIsSet() {
return (optBits & OPT_BIT_COLORS) != 0;
}
private boolean headerFooterLengthIsSet() {
return (optBits & OPT_BIT_HEADER_FOOTER_LENGTH) != 0;
}
private boolean maxResultsPerPageIsSet() {
return (optBits & OPT_BIT_MAX_RESULTS_PER_PAGE) != 0;
}
private boolean commandManagerIsSet() {
return (initBits & INIT_BIT_COMMAND_MANAGER) == 0;
}
private boolean audienceProviderIsSet() {
return (initBits & INIT_BIT_AUDIENCE_PROVIDER) == 0;
}
private boolean commandPrefixIsSet() {
return (initBits & INIT_BIT_COMMAND_PREFIX) == 0;
}
private static void checkNotIsSet(boolean isSet, String name) {
if (isSet) throw new IllegalStateException("Builder of MinecraftHelp is strict, attribute is already set: ".concat(name));
}
private void checkRequiredAttributes() {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList<>();
if (!commandManagerIsSet()) attributes.add("commandManager");
if (!audienceProviderIsSet()) attributes.add("audienceProvider");
if (!commandPrefixIsSet()) attributes.add("commandPrefix");
return "Cannot build MinecraftHelp, some of required attributes are not set " + attributes;
}
}
@Generated(from = "MinecraftHelp", generator = "Immutables")
public interface CommandManagerBuildStage {
/**
* Initializes the value for the {@link MinecraftHelp#commandManager() commandManager} attribute.
* @param commandManager The value for commandManager
* @return {@code this} builder for use in a chained invocation
*/
AudienceProviderBuildStage commandManager(org.incendo.cloud.@NonNull CommandManager commandManager);
}
@Generated(from = "MinecraftHelp", generator = "Immutables")
public interface AudienceProviderBuildStage {
/**
* Initializes the value for the {@link MinecraftHelp#audienceProvider() audienceProvider} attribute.
* @param audienceProvider The value for audienceProvider
* @return {@code this} builder for use in a chained invocation
*/
CommandPrefixBuildStage audienceProvider(org.incendo.cloud.minecraft.extras.@NonNull AudienceProvider audienceProvider);
}
@Generated(from = "MinecraftHelp", generator = "Immutables")
public interface CommandPrefixBuildStage {
/**
* Initializes the value for the {@link MinecraftHelp#commandPrefix() commandPrefix} attribute.
* @param commandPrefix The value for commandPrefix
* @return {@code this} builder for use in a chained invocation
*/
BuildFinal commandPrefix(java.lang.@NonNull String commandPrefix);
}
@Generated(from = "MinecraftHelp", generator = "Immutables")
public interface BuildFinal {
/**
* Initializes the value for the {@link MinecraftHelp#commandFilter() commandFilter} attribute.
* If not set, this attribute will have a default value as returned by the initializer of {@link MinecraftHelp#commandFilter() commandFilter}.
* @param commandFilter The value for commandFilter
* @return {@code this} builder for use in a chained invocation
*/
BuildFinal commandFilter(org.incendo.cloud.help.@NonNull CommandPredicate commandFilter);
/**
* Initializes the value for the {@link MinecraftHelp#descriptionDecorator() descriptionDecorator} attribute.
* If not set, this attribute will have a default value as returned by the initializer of {@link MinecraftHelp#descriptionDecorator() descriptionDecorator}.
* @param descriptionDecorator The value for descriptionDecorator
* @return {@code this} builder for use in a chained invocation
*/
BuildFinal descriptionDecorator(MinecraftHelp.@NonNull DescriptionDecorator descriptionDecorator);
/**
* Put one entry to the {@link MinecraftHelp#messages() messages} map.
* @param key The key in the messages map
* @param value The associated value in the messages map
* @return {@code this} builder for use in a chained invocation
*/
BuildFinal messages(String key, String value);
/**
* Put one entry to the {@link MinecraftHelp#messages() messages} map. Nulls are not permitted
* @param entry The key and value entry
* @return {@code this} builder for use in a chained invocation
*/
BuildFinal messages(java.util.Map.Entry entry);
/**
* Put all mappings from the specified map as entries to {@link MinecraftHelp#messages() messages} map. Nulls are not permitted
* @param entries The entries that will be added to the messages map
* @return {@code this} builder for use in a chained invocation
*/
BuildFinal messages(java.util.Map entries);
/**
* Initializes the value for the {@link MinecraftHelp#messageProvider() messageProvider} attribute.
* If not set, this attribute will have a default value as returned by the initializer of {@link MinecraftHelp#messageProvider() messageProvider}.
* @param messageProvider The value for messageProvider
* @return {@code this} builder for use in a chained invocation
*/
BuildFinal messageProvider(MinecraftHelp.@NonNull MessageProvider messageProvider);
/**
* Initializes the value for the {@link MinecraftHelp#colors() colors} attribute.
* If not set, this attribute will have a default value as returned by the initializer of {@link MinecraftHelp#colors() colors}.
* @param colors The value for colors
* @return {@code this} builder for use in a chained invocation
*/
BuildFinal colors(MinecraftHelp.@NonNull HelpColors colors);
/**
* Initializes the value for the {@link MinecraftHelp#headerFooterLength() headerFooterLength} attribute.
* If not set, this attribute will have a default value as returned by the initializer of {@link MinecraftHelp#headerFooterLength() headerFooterLength}.
* @param headerFooterLength The value for headerFooterLength
* @return {@code this} builder for use in a chained invocation
*/
BuildFinal headerFooterLength(@NonNegative int headerFooterLength);
/**
* Initializes the value for the {@link MinecraftHelp#maxResultsPerPage() maxResultsPerPage} attribute.
* If not set, this attribute will have a default value as returned by the initializer of {@link MinecraftHelp#maxResultsPerPage() maxResultsPerPage}.
* @param maxResultsPerPage The value for maxResultsPerPage
* @return {@code this} builder for use in a chained invocation
*/
BuildFinal maxResultsPerPage(@NonNegative int maxResultsPerPage);
/**
* Builds a new {@link ImmutableMinecraftHelp ImmutableMinecraftHelp}.
* @return An immutable instance of MinecraftHelp
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
ImmutableMinecraftHelp build();
}
private static java.util.Map createUnmodifiableMap(boolean checkNulls, boolean skipNulls, java.util.Map extends K, ? extends V> map) {
switch (map.size()) {
case 0: return Collections.emptyMap();
case 1: {
java.util.Map.Entry extends K, ? extends V> e = map.entrySet().iterator().next();
K k = e.getKey();
V v = e.getValue();
if (checkNulls) {
Objects.requireNonNull(k, "key");
Objects.requireNonNull(v, v == null ? "value for key: " + k : null);
}
if (skipNulls && (k == null || v == null)) {
return Collections.emptyMap();
}
return Collections.singletonMap(k, v);
}
default: {
java.util.Map linkedMap = new LinkedHashMap<>(map.size() * 4 / 3 + 1);
if (skipNulls || checkNulls) {
for (java.util.Map.Entry extends K, ? extends V> e : map.entrySet()) {
K k = e.getKey();
V v = e.getValue();
if (skipNulls) {
if (k == null || v == null) continue;
} else if (checkNulls) {
Objects.requireNonNull(k, "key");
Objects.requireNonNull(v, v == null ? "value for key: " + k : null);
}
linkedMap.put(k, v);
}
} else {
linkedMap.putAll(map);
}
return Collections.unmodifiableMap(linkedMap);
}
}
}
}