🎨 @Annotation final -> final @Annotation
This commit is contained in:
parent
a6b98ca278
commit
7f013124b2
113 changed files with 844 additions and 842 deletions
|
|
@ -77,9 +77,9 @@ public final class AnnotationParser<C> {
|
|||
* {@link ParserParameter}. Mappers for the
|
||||
* parser parameters can be registered using {@link #registerAnnotationMapper(Class, Function)}
|
||||
*/
|
||||
public AnnotationParser(@NonNull final CommandManager<C> manager,
|
||||
@NonNull final Class<C> commandSenderClass,
|
||||
@NonNull final Function<@NonNull ParserParameters, @NonNull CommandMeta> metaMapper) {
|
||||
public AnnotationParser(final @NonNull CommandManager<C> manager,
|
||||
final @NonNull Class<C> commandSenderClass,
|
||||
final @NonNull Function<@NonNull ParserParameters, @NonNull CommandMeta> metaMapper) {
|
||||
this.commandSenderClass = commandSenderClass;
|
||||
this.manager = manager;
|
||||
this.metaFactory = new MetaFactory(this, metaMapper);
|
||||
|
|
@ -96,8 +96,8 @@ public final class AnnotationParser<C> {
|
|||
* @param mapper Mapping function
|
||||
* @param <A> Annotation type
|
||||
*/
|
||||
public <A extends Annotation> void registerAnnotationMapper(@NonNull final Class<A> annotation,
|
||||
@NonNull final Function<@NonNull A,
|
||||
public <A extends Annotation> void registerAnnotationMapper(final @NonNull Class<A> annotation,
|
||||
final @NonNull Function<@NonNull A,
|
||||
@NonNull ParserParameters> mapper) {
|
||||
this.annotationMappers.put(annotation, mapper);
|
||||
}
|
||||
|
|
@ -110,7 +110,7 @@ public final class AnnotationParser<C> {
|
|||
* @param <T> Type of the instance
|
||||
* @return Collection of parsed annotations
|
||||
*/
|
||||
public <T> @NonNull Collection<@NonNull Command<C>> parse(@NonNull final T instance) {
|
||||
public <T> @NonNull Collection<@NonNull Command<C>> parse(final @NonNull T instance) {
|
||||
final Method[] methods = instance.getClass().getDeclaredMethods();
|
||||
final Collection<CommandMethodPair> commandMethodPairs = new ArrayList<>();
|
||||
for (final Method method : methods) {
|
||||
|
|
@ -138,8 +138,8 @@ public final class AnnotationParser<C> {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
private @NonNull Collection<@NonNull Command<C>> construct(
|
||||
@NonNull final Object instance,
|
||||
@NonNull final Collection<@NonNull CommandMethodPair> methodPairs) {
|
||||
final @NonNull Object instance,
|
||||
final @NonNull Collection<@NonNull CommandMethodPair> methodPairs) {
|
||||
final Collection<Command<C>> commands = new ArrayList<>();
|
||||
for (final CommandMethodPair commandMethodPair : methodPairs) {
|
||||
final CommandMethod commandMethod = commandMethodPair.getCommandMethod();
|
||||
|
|
@ -248,9 +248,9 @@ public final class AnnotationParser<C> {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private @NonNull CommandArgument<C, ?> buildArgument(@NonNull final Method method,
|
||||
@Nullable final SyntaxFragment syntaxFragment,
|
||||
@NonNull final ArgumentParameterPair argumentPair) {
|
||||
private @NonNull CommandArgument<C, ?> buildArgument(final @NonNull Method method,
|
||||
final @Nullable SyntaxFragment syntaxFragment,
|
||||
final @NonNull ArgumentParameterPair argumentPair) {
|
||||
final Parameter parameter = argumentPair.getParameter();
|
||||
final Collection<Annotation> annotations = Arrays.asList(parameter.getAnnotations());
|
||||
final TypeToken<?> token = TypeToken.get(parameter.getParameterizedType());
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ import java.util.function.Function;
|
|||
class ArgumentExtractor implements Function<@NonNull Method, @NonNull Collection<@NonNull ArgumentParameterPair>> {
|
||||
|
||||
@Override
|
||||
public @NonNull Collection<@NonNull ArgumentParameterPair> apply(@NonNull final Method method) {
|
||||
public @NonNull Collection<@NonNull ArgumentParameterPair> apply(final @NonNull Method method) {
|
||||
final Collection<ArgumentParameterPair> arguments = new ArrayList<>();
|
||||
for (final Parameter parameter : method.getParameters()) {
|
||||
if (!parameter.isAnnotationPresent(Argument.class)) {
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ final class ArgumentParameterPair {
|
|||
private final Parameter parameter;
|
||||
private final Argument argument;
|
||||
|
||||
ArgumentParameterPair(@NonNull final Parameter parameter,
|
||||
@NonNull final Argument argument) {
|
||||
ArgumentParameterPair(final @NonNull Parameter parameter,
|
||||
final @NonNull Argument argument) {
|
||||
this.parameter = parameter;
|
||||
this.argument = argument;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ final class CommandMethodPair {
|
|||
private final Method method;
|
||||
private final CommandMethod commandMethod;
|
||||
|
||||
CommandMethodPair(@NonNull final Method method,
|
||||
@NonNull final CommandMethod commandMethod) {
|
||||
CommandMethodPair(final @NonNull Method method,
|
||||
final @NonNull CommandMethod commandMethod) {
|
||||
this.method = method;
|
||||
this.commandMethod = commandMethod;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,12 +43,12 @@ final class FlagExtractor implements Function<@NonNull Method, Collection<@NonNu
|
|||
|
||||
private final CommandManager<?> commandManager;
|
||||
|
||||
FlagExtractor(@NonNull final CommandManager<?> commandManager) {
|
||||
FlagExtractor(final @NonNull CommandManager<?> commandManager) {
|
||||
this.commandManager = commandManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Collection<@NonNull CommandFlag<?>> apply(@NonNull final Method method) {
|
||||
public @NonNull Collection<@NonNull CommandFlag<?>> apply(final @NonNull Method method) {
|
||||
final Collection<CommandFlag<?>> flags = new LinkedList<>();
|
||||
for (final Parameter parameter : method.getParameters()) {
|
||||
if (!parameter.isAnnotationPresent(Flag.class)) {
|
||||
|
|
|
|||
|
|
@ -35,14 +35,14 @@ class MetaFactory implements Function<@NonNull Annotation @NonNull [], @NonNull
|
|||
private final AnnotationParser<?> annotationParser;
|
||||
private final Function<ParserParameters, CommandMeta> metaMapper;
|
||||
|
||||
MetaFactory(@NonNull final AnnotationParser<?> annotationParser,
|
||||
@NonNull final Function<@NonNull ParserParameters, @NonNull CommandMeta> metaMapper) {
|
||||
MetaFactory(final @NonNull AnnotationParser<?> annotationParser,
|
||||
final @NonNull Function<@NonNull ParserParameters, @NonNull CommandMeta> metaMapper) {
|
||||
this.annotationParser = annotationParser;
|
||||
this.metaMapper = metaMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull CommandMeta apply(@NonNull final Annotation @NonNull [] annotations) {
|
||||
public @NonNull CommandMeta apply(final @NonNull Annotation @NonNull [] annotations) {
|
||||
final ParserParameters parameters = ParserParameters.empty();
|
||||
for (final Annotation annotation : annotations) {
|
||||
@SuppressWarnings("ALL") final Function function = this.annotationParser.getAnnotationMappers()
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ class MethodCommandExecutionHandler<C> implements CommandExecutionHandler<C> {
|
|||
private final MethodHandle methodHandle;
|
||||
private final Map<String, CommandArgument<C, ?>> commandArguments;
|
||||
|
||||
MethodCommandExecutionHandler(@NonNull final Object instance,
|
||||
@NonNull final Map<@NonNull String,
|
||||
MethodCommandExecutionHandler(final @NonNull Object instance,
|
||||
final @NonNull Map<@NonNull String,
|
||||
@NonNull CommandArgument<@NonNull C, @NonNull ?>> commandArguments,
|
||||
@NonNull final Method method) throws Exception {
|
||||
this.commandArguments = commandArguments;
|
||||
|
|
@ -54,7 +54,7 @@ class MethodCommandExecutionHandler<C> implements CommandExecutionHandler<C> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void execute(@NonNull final CommandContext<C> commandContext) {
|
||||
public void execute(final @NonNull CommandContext<C> commandContext) {
|
||||
final List<Object> arguments = new ArrayList<>(this.parameters.length);
|
||||
final FlagContext flagContext = commandContext.flags();
|
||||
|
||||
|
|
|
|||
|
|
@ -33,9 +33,9 @@ final class SyntaxFragment {
|
|||
private final List<String> minor;
|
||||
private final ArgumentMode argumentMode;
|
||||
|
||||
SyntaxFragment(@NonNull final String major,
|
||||
@NonNull final List<@NonNull String> minor,
|
||||
@NonNull final ArgumentMode argumentMode) {
|
||||
SyntaxFragment(final @NonNull String major,
|
||||
final @NonNull List<@NonNull String> minor,
|
||||
final @NonNull ArgumentMode argumentMode) {
|
||||
this.major = major;
|
||||
this.minor = minor;
|
||||
this.argumentMode = argumentMode;
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ final class SyntaxParser implements Function<@NonNull String, @NonNull LinkedHas
|
|||
.asPredicate();
|
||||
|
||||
@Override
|
||||
public @NonNull LinkedHashMap<@NonNull String, @NonNull SyntaxFragment> apply(@NonNull final String syntax) {
|
||||
public @NonNull LinkedHashMap<@NonNull String, @NonNull SyntaxFragment> apply(final @NonNull String syntax) {
|
||||
final StringTokenizer stringTokenizer = new StringTokenizer(syntax, " ");
|
||||
final LinkedHashMap<String, SyntaxFragment> map = new LinkedHashMap<>();
|
||||
while (stringTokenizer.hasMoreTokens()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue