Deprecate argument newBuilder methods and add builder methods to align with newer arguments (#419)
This commit is contained in:
parent
306a1def9a
commit
99d388b708
39 changed files with 634 additions and 204 deletions
|
|
@ -37,6 +37,7 @@ import java.util.function.BiFunction;
|
|||
import net.dv8tion.jda.api.entities.MessageChannel;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import org.apiguardian.api.API;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
|
@ -72,15 +73,31 @@ public final class ChannelArgument<C> extends CommandArgument<C, MessageChannel>
|
|||
this.modes = modes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link Builder}.
|
||||
*
|
||||
* @param name argument name
|
||||
* @param <C> sender type
|
||||
* @return new {@link Builder}
|
||||
* @since 1.8.0
|
||||
*/
|
||||
@API(status = API.Status.STABLE, since = "1.8.0")
|
||||
public static <C> @NonNull Builder<C> builder(final @NonNull String name) {
|
||||
return new Builder<>(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new builder
|
||||
*
|
||||
* @param name Name of the component
|
||||
* @param name Name of the argument
|
||||
* @param <C> Command sender type
|
||||
* @return Created builder
|
||||
* @deprecated prefer {@link #builder(String)}
|
||||
*/
|
||||
@API(status = API.Status.DEPRECATED, since = "1.8.0")
|
||||
@Deprecated
|
||||
public static <C> @NonNull Builder<C> newBuilder(final @NonNull String name) {
|
||||
return new Builder<>(name);
|
||||
return builder(name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -91,7 +108,7 @@ public final class ChannelArgument<C> extends CommandArgument<C, MessageChannel>
|
|||
* @return Created component
|
||||
*/
|
||||
public static <C> @NonNull CommandArgument<C, MessageChannel> of(final @NonNull String name) {
|
||||
return ChannelArgument.<C>newBuilder(name).asRequired().build();
|
||||
return ChannelArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -102,7 +119,7 @@ public final class ChannelArgument<C> extends CommandArgument<C, MessageChannel>
|
|||
* @return Created component
|
||||
*/
|
||||
public static <C> @NonNull CommandArgument<C, MessageChannel> optional(final @NonNull String name) {
|
||||
return ChannelArgument.<C>newBuilder(name).asOptional().build();
|
||||
return ChannelArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import java.util.Set;
|
|||
import java.util.function.BiFunction;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import org.apiguardian.api.API;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
|
@ -63,15 +64,31 @@ public final class RoleArgument<C> extends CommandArgument<C, Role> {
|
|||
this.modes = modes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link Builder}.
|
||||
*
|
||||
* @param name argument name
|
||||
* @param <C> sender type
|
||||
* @return new {@link Builder}
|
||||
* @since 1.8.0
|
||||
*/
|
||||
@API(status = API.Status.STABLE, since = "1.8.0")
|
||||
public static <C> @NonNull Builder<C> builder(final @NonNull String name) {
|
||||
return new Builder<>(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new builder
|
||||
*
|
||||
* @param name Name of the component
|
||||
* @param name Name of the argument
|
||||
* @param <C> Command sender type
|
||||
* @return Created builder
|
||||
* @deprecated prefer {@link #builder(String)}
|
||||
*/
|
||||
@API(status = API.Status.DEPRECATED, since = "1.8.0")
|
||||
@Deprecated
|
||||
public static <C> @NonNull Builder<C> newBuilder(final @NonNull String name) {
|
||||
return new Builder<>(name);
|
||||
return builder(name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -82,7 +99,7 @@ public final class RoleArgument<C> extends CommandArgument<C, Role> {
|
|||
* @return Created component
|
||||
*/
|
||||
public static <C> @NonNull CommandArgument<C, Role> of(final @NonNull String name) {
|
||||
return RoleArgument.<C>newBuilder(name).asRequired().build();
|
||||
return RoleArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -93,7 +110,7 @@ public final class RoleArgument<C> extends CommandArgument<C, Role> {
|
|||
* @return Created component
|
||||
*/
|
||||
public static <C> @NonNull CommandArgument<C, Role> optional(final @NonNull String name) {
|
||||
return RoleArgument.<C>newBuilder(name).asOptional().build();
|
||||
return RoleArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ import java.util.stream.Collectors;
|
|||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import org.apiguardian.api.API;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
|
@ -78,15 +79,31 @@ public final class UserArgument<C> extends CommandArgument<C, User> {
|
|||
this.isolationLevel = isolationLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link Builder}.
|
||||
*
|
||||
* @param name argument name
|
||||
* @param <C> sender type
|
||||
* @return new {@link Builder}
|
||||
* @since 1.8.0
|
||||
*/
|
||||
@API(status = API.Status.STABLE, since = "1.8.0")
|
||||
public static <C> @NonNull Builder<C> builder(final @NonNull String name) {
|
||||
return new Builder<>(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new builder
|
||||
*
|
||||
* @param name Name of the component
|
||||
* @param name Name of the argument
|
||||
* @param <C> Command sender type
|
||||
* @return Created builder
|
||||
* @deprecated prefer {@link #builder(String)}
|
||||
*/
|
||||
@API(status = API.Status.DEPRECATED, since = "1.8.0")
|
||||
@Deprecated
|
||||
public static <C> @NonNull Builder<C> newBuilder(final @NonNull String name) {
|
||||
return new Builder<>(name);
|
||||
return builder(name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -97,7 +114,7 @@ public final class UserArgument<C> extends CommandArgument<C, User> {
|
|||
* @return Created component
|
||||
*/
|
||||
public static <C> @NonNull CommandArgument<C, User> of(final @NonNull String name) {
|
||||
return UserArgument.<C>newBuilder(name).withParserMode(ParserMode.MENTION).asRequired().build();
|
||||
return UserArgument.<C>builder(name).withParserMode(ParserMode.MENTION).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -108,7 +125,7 @@ public final class UserArgument<C> extends CommandArgument<C, User> {
|
|||
* @return Created component
|
||||
*/
|
||||
public static <C> @NonNull CommandArgument<C, User> optional(final @NonNull String name) {
|
||||
return UserArgument.<C>newBuilder(name).withParserMode(ParserMode.MENTION).asOptional().build();
|
||||
return UserArgument.<C>builder(name).withParserMode(ParserMode.MENTION).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue