⚡ Fix dependency graph and replace Guava
This commit is contained in:
parent
4ca47777a3
commit
e914d04450
35 changed files with 184 additions and 191 deletions
|
|
@ -1,6 +1,5 @@
|
|||
dependencies {
|
||||
api project(':cloud-services')
|
||||
api 'com.google.guava:guava:29.0-jre'
|
||||
testImplementation 'org.openjdk.jmh:jmh-core:1.25.2'
|
||||
testImplementation 'org.openjdk.jmh:jmh-generator-annprocess:1.25.2'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,9 +44,7 @@ import cloud.commandframework.execution.preprocessor.AcceptingCommandPreprocesso
|
|||
import cloud.commandframework.execution.preprocessor.CommandPreprocessingContext;
|
||||
import cloud.commandframework.execution.preprocessor.CommandPreprocessor;
|
||||
import cloud.commandframework.internal.CommandRegistrationHandler;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import io.leangen.geantyref.TypeToken;
|
||||
import cloud.commandframework.meta.CommandMeta;
|
||||
import cloud.commandframework.permission.CommandPermission;
|
||||
import cloud.commandframework.permission.OrPermission;
|
||||
|
|
@ -59,6 +57,7 @@ import javax.annotation.Nullable;
|
|||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -76,13 +75,13 @@ import java.util.function.Function;
|
|||
@SuppressWarnings("unused")
|
||||
public abstract class CommandManager<C> {
|
||||
|
||||
private final Map<Class<? extends Exception>, BiConsumer<C, ? extends Exception>> exceptionHandlers = Maps.newHashMap();
|
||||
private final Map<Class<? extends Exception>, BiConsumer<C, ? extends Exception>> exceptionHandlers = new HashMap<>();
|
||||
private final EnumSet<ManagerSettings> managerSettings = EnumSet.of(ManagerSettings.ENFORCE_INTERMEDIARY_PERMISSIONS);
|
||||
|
||||
private final CommandContextFactory<C> commandContextFactory = new StandardCommandContextFactory<>();
|
||||
private final ServicePipeline servicePipeline = ServicePipeline.builder().build();
|
||||
private final ParserRegistry<C> parserRegistry = new StandardParserRegistry<>();
|
||||
private final Collection<Command<C>> commands = Lists.newLinkedList();
|
||||
private final Collection<Command<C>> commands = new LinkedList<>();
|
||||
private final CommandExecutionCoordinator<C> commandExecutionCoordinator;
|
||||
private final CommandTree<C> commandTree;
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
package cloud.commandframework.arguments;
|
||||
|
||||
import cloud.commandframework.arguments.parser.ArgumentParser;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import io.leangen.geantyref.TypeToken;
|
||||
import cloud.commandframework.Command;
|
||||
import cloud.commandframework.CommandManager;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
||||
|
|
@ -180,7 +180,7 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>
|
|||
@Nonnull
|
||||
public static <C, T> CommandArgument.Builder<C, T> ofType(@Nonnull final Class<T> clazz,
|
||||
@Nonnull final String name) {
|
||||
return new Builder<>(TypeToken.of(clazz), name);
|
||||
return new Builder<>(TypeToken.get(clazz), name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
//
|
||||
package cloud.commandframework.arguments.parser;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import io.leangen.geantyref.TypeToken;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Objects;
|
||||
|
|
|
|||
|
|
@ -23,10 +23,9 @@
|
|||
//
|
||||
package cloud.commandframework.arguments.parser;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
|
@ -34,7 +33,7 @@ import java.util.Map;
|
|||
*/
|
||||
public final class ParserParameters {
|
||||
|
||||
private final Map<ParserParameter<?>, Object> internalMap = Maps.newHashMap();
|
||||
private final Map<ParserParameter<?>, Object> internalMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Get an empty {@link ParserParameters} instance
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
//
|
||||
package cloud.commandframework.arguments.parser;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import io.leangen.geantyref.TypeToken;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.lang.annotation.Annotation;
|
||||
|
|
@ -34,7 +34,7 @@ import java.util.function.Function;
|
|||
|
||||
/**
|
||||
* Registry of {@link ArgumentParser} that allows these arguments to be
|
||||
* referenced by a {@link Class} (or really, a {@link com.google.common.reflect.TypeToken})
|
||||
* referenced by a {@link Class} (or really, a {@link TypeToken})
|
||||
* or a {@link String} key
|
||||
*
|
||||
* @param <C> Command sender type
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
//
|
||||
package cloud.commandframework.arguments.parser;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import io.leangen.geantyref.TypeToken;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
|
@ -35,27 +35,27 @@ public final class StandardParameters {
|
|||
/**
|
||||
* Minimum value accepted by a numerical parser
|
||||
*/
|
||||
public static final ParserParameter<Number> RANGE_MIN = create("min", TypeToken.of(Number.class));
|
||||
public static final ParserParameter<Number> RANGE_MIN = create("min", TypeToken.get(Number.class));
|
||||
/**
|
||||
* Maximum value accepted by a numerical parser
|
||||
*/
|
||||
public static final ParserParameter<Number> RANGE_MAX = create("max", TypeToken.of(Number.class));
|
||||
public static final ParserParameter<Number> RANGE_MAX = create("max", TypeToken.get(Number.class));
|
||||
/**
|
||||
* Command description
|
||||
*/
|
||||
public static final ParserParameter<String> DESCRIPTION = create("description", TypeToken.of(String.class));
|
||||
public static final ParserParameter<String> DESCRIPTION = create("description", TypeToken.get(String.class));
|
||||
/**
|
||||
* Command confirmation
|
||||
*/
|
||||
public static final ParserParameter<Boolean> CONFIRMATION = create("confirmation", TypeToken.of(Boolean.class));
|
||||
public static final ParserParameter<Boolean> CONFIRMATION = create("confirmation", TypeToken.get(Boolean.class));
|
||||
/**
|
||||
* Command completions
|
||||
*/
|
||||
public static final ParserParameter<String[]> COMPLETIONS = create("completions", TypeToken.of(String[].class));
|
||||
public static final ParserParameter<String[]> COMPLETIONS = create("completions", TypeToken.get(String[].class));
|
||||
/**
|
||||
* The command should be hidden from help menus, etc
|
||||
*/
|
||||
public static final ParserParameter<Boolean> HIDDEN = create("hidden", TypeToken.of(Boolean.class));
|
||||
public static final ParserParameter<Boolean> HIDDEN = create("hidden", TypeToken.get(Boolean.class));
|
||||
|
||||
private StandardParameters() {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@
|
|||
//
|
||||
package cloud.commandframework.arguments.parser;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import cloud.commandframework.annotations.specifier.Completions;
|
||||
import cloud.commandframework.annotations.specifier.Range;
|
||||
import cloud.commandframework.arguments.standard.BooleanArgument;
|
||||
|
|
@ -36,6 +34,8 @@ import cloud.commandframework.arguments.standard.FloatArgument;
|
|||
import cloud.commandframework.arguments.standard.IntegerArgument;
|
||||
import cloud.commandframework.arguments.standard.ShortArgument;
|
||||
import cloud.commandframework.arguments.standard.StringArgument;
|
||||
import io.leangen.geantyref.GenericTypeReflector;
|
||||
import io.leangen.geantyref.TypeToken;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.lang.annotation.Annotation;
|
||||
|
|
@ -54,16 +54,18 @@ import java.util.function.Function;
|
|||
*/
|
||||
public final class StandardParserRegistry<C> implements ParserRegistry<C> {
|
||||
|
||||
private static final Map<Class<?>, Class<?>> PRIMITIVE_MAPPINGS = ImmutableMap.<Class<?>, Class<?>>builder()
|
||||
.put(char.class, Character.class)
|
||||
.put(int.class, Integer.class)
|
||||
.put(short.class, Short.class)
|
||||
.put(byte.class, Byte.class)
|
||||
.put(float.class, Float.class)
|
||||
.put(double.class, Double.class)
|
||||
.put(long.class, Long.class)
|
||||
.put(boolean.class, Boolean.class)
|
||||
.build();
|
||||
private static final Map<Class<?>, Class<?>> PRIMITIVE_MAPPINGS = new HashMap<Class<?>, Class<?>>() {
|
||||
{
|
||||
put(char.class, Character .class);
|
||||
put(int.class, Integer .class);
|
||||
put(short.class, Short .class);
|
||||
put(byte.class, Byte .class);
|
||||
put(float.class, Float .class);
|
||||
put(double.class, Double .class);
|
||||
put(long.class, Long .class);
|
||||
put(boolean.class, Boolean .class);
|
||||
}
|
||||
};
|
||||
|
||||
private final Map<String, Function<ParserParameters, ArgumentParser<C, ?>>> namedParsers = new HashMap<>();
|
||||
private final Map<TypeToken<?>, Function<ParserParameters, ArgumentParser<C, ?>>> parserSuppliers = new HashMap<>();
|
||||
|
|
@ -80,28 +82,28 @@ public final class StandardParserRegistry<C> implements ParserRegistry<C> {
|
|||
this.<Completions, String>registerAnnotationMapper(Completions.class, new CompletionsMapper());
|
||||
|
||||
/* Register standard types */
|
||||
this.registerParserSupplier(TypeToken.of(Byte.class), options ->
|
||||
this.registerParserSupplier(TypeToken.get(Byte.class), options ->
|
||||
new ByteArgument.ByteParser<C>((byte) options.get(StandardParameters.RANGE_MIN, Byte.MIN_VALUE),
|
||||
(byte) options.get(StandardParameters.RANGE_MAX, Byte.MAX_VALUE)));
|
||||
this.registerParserSupplier(TypeToken.of(Short.class), options ->
|
||||
this.registerParserSupplier(TypeToken.get(Short.class), options ->
|
||||
new ShortArgument.ShortParser<C>((short) options.get(StandardParameters.RANGE_MIN, Short.MIN_VALUE),
|
||||
(short) options.get(StandardParameters.RANGE_MAX, Short.MAX_VALUE)));
|
||||
this.registerParserSupplier(TypeToken.of(Integer.class), options ->
|
||||
this.registerParserSupplier(TypeToken.get(Integer.class), options ->
|
||||
new IntegerArgument.IntegerParser<C>((int) options.get(StandardParameters.RANGE_MIN, Integer.MIN_VALUE),
|
||||
(int) options.get(StandardParameters.RANGE_MAX, Integer.MAX_VALUE)));
|
||||
this.registerParserSupplier(TypeToken.of(Float.class), options ->
|
||||
this.registerParserSupplier(TypeToken.get(Float.class), options ->
|
||||
new FloatArgument.FloatParser<C>((float) options.get(StandardParameters.RANGE_MIN, Float.MIN_VALUE),
|
||||
(float) options.get(StandardParameters.RANGE_MAX, Float.MAX_VALUE)));
|
||||
this.registerParserSupplier(TypeToken.of(Double.class), options ->
|
||||
this.registerParserSupplier(TypeToken.get(Double.class), options ->
|
||||
new DoubleArgument.DoubleParser<C>((double) options.get(StandardParameters.RANGE_MIN, Double.MIN_VALUE),
|
||||
(double) options.get(StandardParameters.RANGE_MAX, Double.MAX_VALUE)));
|
||||
this.registerParserSupplier(TypeToken.of(Character.class), options -> new CharArgument.CharacterParser<C>());
|
||||
this.registerParserSupplier(TypeToken.get(Character.class), options -> new CharArgument.CharacterParser<C>());
|
||||
/* Make this one less awful */
|
||||
this.registerParserSupplier(TypeToken.of(String.class), options -> new StringArgument.StringParser<C>(
|
||||
this.registerParserSupplier(TypeToken.get(String.class), options -> new StringArgument.StringParser<C>(
|
||||
StringArgument.StringMode.SINGLE, (context, s) ->
|
||||
Arrays.asList(options.get(StandardParameters.COMPLETIONS, new String[0]))));
|
||||
/* Add options to this */
|
||||
this.registerParserSupplier(TypeToken.of(Boolean.class), options -> new BooleanArgument.BooleanParser<>(false));
|
||||
this.registerParserSupplier(TypeToken.get(Boolean.class), options -> new BooleanArgument.BooleanParser<>(false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -146,17 +148,17 @@ public final class StandardParserRegistry<C> implements ParserRegistry<C> {
|
|||
public <T> Optional<ArgumentParser<C, T>> createParser(@Nonnull final TypeToken<T> type,
|
||||
@Nonnull final ParserParameters parserParameters) {
|
||||
final TypeToken<?> actualType;
|
||||
if (type.isPrimitive()) {
|
||||
actualType = TypeToken.of(PRIMITIVE_MAPPINGS.get(type.getRawType()));
|
||||
if (GenericTypeReflector.erase(type.getType()).isPrimitive()) {
|
||||
actualType = TypeToken.get(PRIMITIVE_MAPPINGS.get(GenericTypeReflector.erase(type.getType())));
|
||||
} else {
|
||||
actualType = type;
|
||||
}
|
||||
final Function<ParserParameters, ArgumentParser<C, ?>> producer = this.parserSuppliers.get(actualType);
|
||||
if (producer == null) {
|
||||
/* Give enums special treatment */
|
||||
if (actualType.isSubtypeOf(Enum.class)) {
|
||||
if (GenericTypeReflector.isSuperType(Enum.class, actualType.getType())) {
|
||||
@SuppressWarnings("all") final EnumArgument.EnumParser enumArgument
|
||||
= new EnumArgument.EnumParser((Class<Enum>) actualType.getRawType());
|
||||
= new EnumArgument.EnumParser((Class<Enum>) GenericTypeReflector.erase(actualType.getType()));
|
||||
// noinspection all
|
||||
return Optional.of(enumArgument);
|
||||
}
|
||||
|
|
@ -181,15 +183,20 @@ public final class StandardParserRegistry<C> implements ParserRegistry<C> {
|
|||
}
|
||||
|
||||
|
||||
private static boolean isPrimitive(@Nonnull final TypeToken<?> type) {
|
||||
return GenericTypeReflector.erase(type.getType()).isPrimitive();
|
||||
}
|
||||
|
||||
|
||||
private static final class RangeMapper<T> implements BiFunction<Range, TypeToken<?>, ParserParameters> {
|
||||
|
||||
@Override
|
||||
public ParserParameters apply(final Range range, final TypeToken<?> type) {
|
||||
final Class<?> clazz;
|
||||
if (type.isPrimitive()) {
|
||||
clazz = PRIMITIVE_MAPPINGS.get(type.getRawType());
|
||||
if (isPrimitive(type)) {
|
||||
clazz = PRIMITIVE_MAPPINGS.get(GenericTypeReflector.erase(type.getType()));
|
||||
} else {
|
||||
clazz = type.getRawType();
|
||||
clazz = GenericTypeReflector.erase(type.getType());
|
||||
}
|
||||
if (!Number.class.isAssignableFrom(clazz)) {
|
||||
return ParserParameters.empty();
|
||||
|
|
@ -256,7 +263,7 @@ public final class StandardParserRegistry<C> implements ParserRegistry<C> {
|
|||
|
||||
@Override
|
||||
public ParserParameters apply(final Completions completions, final TypeToken<?> token) {
|
||||
if (token.getRawType().equals(String.class)) {
|
||||
if (GenericTypeReflector.erase(token.getType()).equals(String.class)) {
|
||||
final String[] splitCompletions = completions.value().replace(" ", "").split(",");
|
||||
return ParserParameters.single(StandardParameters.COMPLETIONS, splitCompletions);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,10 +24,10 @@
|
|||
package cloud.commandframework.context;
|
||||
|
||||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
|
|
@ -38,8 +38,8 @@ import java.util.Optional;
|
|||
*/
|
||||
public final class CommandContext<C> {
|
||||
|
||||
private final Map<CommandArgument<C, ?>, ArgumentTiming> argumentTimings = Maps.newHashMap();
|
||||
private final Map<String, Object> internalStorage = Maps.newHashMap();
|
||||
private final Map<CommandArgument<C, ?>, ArgumentTiming> argumentTimings = new HashMap<>();
|
||||
private final Map<String, Object> internalStorage = new HashMap<>();
|
||||
private final C commandSender;
|
||||
private final boolean suggestions;
|
||||
|
||||
|
|
@ -197,6 +197,7 @@ public final class CommandContext<C> {
|
|||
*
|
||||
* @param start Start time (in nanoseconds)
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public ArgumentTiming(final long start) {
|
||||
this(start, -1, false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,16 +23,17 @@
|
|||
//
|
||||
package cloud.commandframework.extra.confirmation;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import cloud.commandframework.CommandManager;
|
||||
import cloud.commandframework.execution.CommandExecutionHandler;
|
||||
import cloud.commandframework.execution.postprocessor.CommandPostprocessingContext;
|
||||
import cloud.commandframework.execution.postprocessor.CommandPostprocessor;
|
||||
import cloud.commandframework.meta.SimpleCommandMeta;
|
||||
import cloud.commandframework.services.types.ConsumerService;
|
||||
import cloud.commandframework.types.tuples.Pair;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
|
@ -55,10 +56,13 @@ public class CommandConfirmationManager<C> {
|
|||
* Meta data stored for commands that require confirmation
|
||||
*/
|
||||
public static final String CONFIRMATION_REQUIRED_META = "__REQUIRE_CONFIRMATION__";
|
||||
private static final int MAXIMUM_PENDING_SIZE = 100;
|
||||
|
||||
private final Consumer<CommandPostprocessingContext<C>> notifier;
|
||||
private final Consumer<C> errorNotifier;
|
||||
private final Cache<C, CommandPostprocessingContext<C>> pendingCommands;
|
||||
private final Map<C, Pair<CommandPostprocessingContext<C>, Long>> pendingCommands;
|
||||
|
||||
private final long timeoutMillis;
|
||||
|
||||
/**
|
||||
* Create a new confirmation manager instance
|
||||
|
|
@ -74,7 +78,13 @@ public class CommandConfirmationManager<C> {
|
|||
@Nonnull final Consumer<C> errorNotifier) {
|
||||
this.notifier = notifier;
|
||||
this.errorNotifier = errorNotifier;
|
||||
this.pendingCommands = CacheBuilder.newBuilder().expireAfterWrite(timeout, timeoutTimeUnit).concurrencyLevel(1).build();
|
||||
this.pendingCommands = new LinkedHashMap<C, Pair<CommandPostprocessingContext<C>, Long>>() {
|
||||
@Override
|
||||
protected boolean removeEldestEntry(final Map.Entry<C, Pair<CommandPostprocessingContext<C>, Long>> eldest) {
|
||||
return this.size() > MAXIMUM_PENDING_SIZE;
|
||||
}
|
||||
};
|
||||
this.timeoutMillis = timeoutTimeUnit.toMillis(timeout);
|
||||
}
|
||||
|
||||
private void notifyConsumer(@Nonnull final CommandPostprocessingContext<C> context) {
|
||||
|
|
@ -82,7 +92,7 @@ public class CommandConfirmationManager<C> {
|
|||
}
|
||||
|
||||
private void addPending(@Nonnull final CommandPostprocessingContext<C> context) {
|
||||
this.pendingCommands.put(context.getCommandContext().getSender(), context);
|
||||
this.pendingCommands.put(context.getCommandContext().getSender(), Pair.of(context, System.currentTimeMillis()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -93,7 +103,13 @@ public class CommandConfirmationManager<C> {
|
|||
*/
|
||||
@Nonnull
|
||||
public Optional<CommandPostprocessingContext<C>> getPending(@Nonnull final C sender) {
|
||||
return Optional.ofNullable(this.pendingCommands.getIfPresent(sender));
|
||||
final Pair<CommandPostprocessingContext<C>, Long> pair = this.pendingCommands.remove(sender);
|
||||
if (pair != null) {
|
||||
if (System.currentTimeMillis() < pair.getSecond() + this.timeoutMillis) {
|
||||
return Optional.of(pair.getFirst());
|
||||
}
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -23,9 +23,8 @@
|
|||
//
|
||||
package cloud.commandframework.types.tuples;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Immutable generic 2-tuple
|
||||
|
|
@ -90,13 +89,13 @@ public class Pair<U, V> implements Tuple {
|
|||
return false;
|
||||
}
|
||||
final Pair<?, ?> pair = (Pair<?, ?>) o;
|
||||
return Objects.equal(getFirst(), pair.getFirst())
|
||||
&& Objects.equal(getSecond(), pair.getSecond());
|
||||
return Objects.equals(getFirst(), pair.getFirst())
|
||||
&& Objects.equals(getSecond(), pair.getSecond());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int hashCode() {
|
||||
return Objects.hashCode(getFirst(), getSecond());
|
||||
return Objects.hash(getFirst(), getSecond());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -23,9 +23,8 @@
|
|||
//
|
||||
package cloud.commandframework.types.tuples;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Immutable generic 5-tuple
|
||||
|
|
@ -126,15 +125,15 @@ public class Quartet<U, V, W, X> implements Tuple {
|
|||
return false;
|
||||
}
|
||||
final Quartet<?, ?, ?, ?> quartet = (Quartet<?, ?, ?, ?>) o;
|
||||
return Objects.equal(getFirst(), quartet.getFirst())
|
||||
&& Objects.equal(getSecond(), quartet.getSecond())
|
||||
&& Objects.equal(getThird(), quartet.getThird())
|
||||
&& Objects.equal(getFourth(), quartet.getFourth());
|
||||
return Objects.equals(getFirst(), quartet.getFirst())
|
||||
&& Objects.equals(getSecond(), quartet.getSecond())
|
||||
&& Objects.equals(getThird(), quartet.getThird())
|
||||
&& Objects.equals(getFourth(), quartet.getFourth());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int hashCode() {
|
||||
return Objects.hashCode(getFirst(), getSecond(), getThird(), getFourth());
|
||||
return Objects.hash(getFirst(), getSecond(), getThird(), getFourth());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -23,9 +23,8 @@
|
|||
//
|
||||
package cloud.commandframework.types.tuples;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Immutable generic 5-tuple
|
||||
|
|
@ -144,16 +143,16 @@ public class Quintet<U, V, W, X, Y> implements Tuple {
|
|||
return false;
|
||||
}
|
||||
final Quintet<?, ?, ?, ?, ?> quintet = (Quintet<?, ?, ?, ?, ?>) o;
|
||||
return Objects.equal(getFirst(), quintet.getFirst())
|
||||
&& Objects.equal(getSecond(), quintet.getSecond())
|
||||
&& Objects.equal(getThird(), quintet.getThird())
|
||||
&& Objects.equal(getFourth(), quintet.getFourth())
|
||||
&& Objects.equal(getFifth(), quintet.getFifth());
|
||||
return Objects.equals(getFirst(), quintet.getFirst())
|
||||
&& Objects.equals(getSecond(), quintet.getSecond())
|
||||
&& Objects.equals(getThird(), quintet.getThird())
|
||||
&& Objects.equals(getFourth(), quintet.getFourth())
|
||||
&& Objects.equals(getFifth(), quintet.getFifth());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int hashCode() {
|
||||
return Objects.hashCode(getFirst(), getSecond(), getThird(), getFourth(), getFifth());
|
||||
return Objects.hash(getFirst(), getSecond(), getThird(), getFourth(), getFifth());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -23,9 +23,8 @@
|
|||
//
|
||||
package cloud.commandframework.types.tuples;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Immutable generic 6-tuple
|
||||
|
|
@ -162,17 +161,17 @@ public class Sextet<U, V, W, X, Y, Z> implements Tuple {
|
|||
return false;
|
||||
}
|
||||
final Sextet<?, ?, ?, ?, ?, ?> sextet = (Sextet<?, ?, ?, ?, ?, ?>) o;
|
||||
return Objects.equal(getFirst(), sextet.getFirst())
|
||||
&& Objects.equal(getSecond(), sextet.getSecond())
|
||||
&& Objects.equal(getThird(), sextet.getThird())
|
||||
&& Objects.equal(getFourth(), sextet.getFourth())
|
||||
&& Objects.equal(getFifth(), sextet.getFifth())
|
||||
&& Objects.equal(getSixth(), sextet.getSixth());
|
||||
return Objects.equals(getFirst(), sextet.getFirst())
|
||||
&& Objects.equals(getSecond(), sextet.getSecond())
|
||||
&& Objects.equals(getThird(), sextet.getThird())
|
||||
&& Objects.equals(getFourth(), sextet.getFourth())
|
||||
&& Objects.equals(getFifth(), sextet.getFifth())
|
||||
&& Objects.equals(getSixth(), sextet.getSixth());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int hashCode() {
|
||||
return Objects.hashCode(getFirst(), getSecond(), getThird(), getFourth(), getFifth(), getSixth());
|
||||
return Objects.hash(getFirst(), getSecond(), getThird(), getFourth(), getFifth(), getSixth());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -23,9 +23,8 @@
|
|||
//
|
||||
package cloud.commandframework.types.tuples;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Immutable generic 3-tuple
|
||||
|
|
@ -108,14 +107,14 @@ public class Triplet<U, V, W> implements Tuple {
|
|||
return false;
|
||||
}
|
||||
final Triplet<?, ?, ?> triplet = (Triplet<?, ?, ?>) o;
|
||||
return Objects.equal(getFirst(), triplet.getFirst())
|
||||
&& Objects.equal(getSecond(), triplet.getSecond())
|
||||
&& Objects.equal(getThird(), triplet.getThird());
|
||||
return Objects.equals(getFirst(), triplet.getFirst())
|
||||
&& Objects.equals(getSecond(), triplet.getSecond())
|
||||
&& Objects.equals(getThird(), triplet.getThird());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int hashCode() {
|
||||
return Objects.hashCode(getFirst(), getSecond(), getThird());
|
||||
return Objects.hash(getFirst(), getSecond(), getThird());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ package cloud.commandframework;
|
|||
|
||||
import cloud.commandframework.annotations.specifier.Range;
|
||||
import cloud.commandframework.arguments.standard.IntegerArgument;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import io.leangen.geantyref.TypeToken;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParser;
|
||||
import cloud.commandframework.arguments.parser.ParserParameters;
|
||||
import cloud.commandframework.arguments.parser.ParserRegistry;
|
||||
|
|
@ -67,7 +67,7 @@ public class ParserRegistryTest {
|
|||
};
|
||||
|
||||
|
||||
final TypeToken<?> parsedType = TypeToken.of(int.class);
|
||||
final TypeToken<?> parsedType = TypeToken.get(int.class);
|
||||
final ParserParameters parserParameters = parserRegistry.parseAnnotations(parsedType, Collections.singleton(range));
|
||||
Assertions.assertTrue(parserParameters.has(StandardParameters.RANGE_MIN));
|
||||
Assertions.assertTrue(parserParameters.has(StandardParameters.RANGE_MAX));
|
||||
|
|
@ -81,6 +81,14 @@ public class ParserRegistryTest {
|
|||
(IntegerArgument.IntegerParser<TestCommandSender>) parser;
|
||||
Assertions.assertEquals(RANGE_MIN, integerParser.getMin());
|
||||
Assertions.assertEquals(RANGE_MAX, integerParser.getMax());
|
||||
|
||||
/* Test integer */
|
||||
parserRegistry.createParser(TypeToken.get(int.class), ParserParameters.empty())
|
||||
.orElseThrow(() -> new IllegalArgumentException("No parser found for int.class"));
|
||||
|
||||
/* Test Enum */
|
||||
parserRegistry.createParser(TypeToken.get(CommandManager.ManagerSettings.class), ParserParameters.empty())
|
||||
.orElseThrow(() -> new IllegalArgumentException("No parser found for enum"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue