Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package fr.zcraft.quartzlib.components.commands;

import fr.zcraft.quartzlib.components.commands.exceptions.ArgumentParseException;

@FunctionalInterface
public interface ArgumentType<T> {
T parse(String raw) throws ArgumentParseException;

default boolean isValid(String raw) {
try {
parse(raw);
return true;
} catch (ArgumentParseException ignored) {
return false;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package fr.zcraft.quartzlib.components.commands;

class ArgumentTypeWrapper<T> {
private final Class<T> resultType;
private final ArgumentType<T> typeHandler;

public ArgumentTypeWrapper(Class<T> resultType, ArgumentType<T> typeHandler) {
this.resultType = resultType;
this.typeHandler = typeHandler;
}

public ArgumentType<T> getTypeHandler() {
return typeHandler;
}

public Class<T> getResultType() {
return resultType;
}
}
Loading