mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-06 00:17:58 +01:00
Move ArgumentMapper inside ArgumentMap
This commit is contained in:
parent
e4c3345da7
commit
ca6ee7c23a
@ -1,26 +0,0 @@
|
||||
package net.minestom.server.command.builder;
|
||||
|
||||
import net.minestom.server.command.builder.exception.ArgumentSyntaxException;
|
||||
|
||||
/**
|
||||
* Represents a lambda that can turn an input into an output
|
||||
* that also allows the throwing of ArgumentSyntaxException
|
||||
*
|
||||
* @param <I> The input expected from the Argument
|
||||
* @param <O> The desired output type from this lambda.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ArgumentMapper<I, O> {
|
||||
|
||||
/**
|
||||
* Accept's I data from the argument and returns O output
|
||||
*
|
||||
* @param i The input processed from an argument
|
||||
*
|
||||
* @return The complex data type that came as a result from this argument
|
||||
* @throws ArgumentSyntaxException If the input can not be turned into the desired output
|
||||
* (E.X. an invalid extension name)
|
||||
*/
|
||||
O accept(I i) throws ArgumentSyntaxException;
|
||||
|
||||
}
|
@ -226,7 +226,7 @@ public abstract class Argument<T> {
|
||||
* @return A new ArgumentMap that can get this complex object type.
|
||||
*/
|
||||
@Beta
|
||||
public <O> ArgumentMap<T, O> map(ArgumentMapper<T, O> mapper) {
|
||||
public <O> ArgumentMap<T, O> map(ArgumentMap.ArgumentMapper<T, O> mapper) {
|
||||
return new ArgumentMap<>(this, mapper);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package net.minestom.server.command.builder.arguments;
|
||||
|
||||
import net.minestom.server.command.builder.ArgumentMapper;
|
||||
import net.minestom.server.command.builder.NodeMaker;
|
||||
import net.minestom.server.command.builder.exception.ArgumentSyntaxException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -32,4 +31,28 @@ public class ArgumentMap<I, O> extends Argument<O> {
|
||||
public void processNodes(@NotNull NodeMaker nodeMaker, boolean executable) {
|
||||
argument.processNodes(nodeMaker, executable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a lambda that can turn an input into an output
|
||||
* that also allows the throwing of ArgumentSyntaxException
|
||||
*
|
||||
* @param <I> The input expected from the Argument
|
||||
* @param <O> The desired output type from this lambda.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ArgumentMapper<I, O> {
|
||||
|
||||
/**
|
||||
* Accept's I data from the argument and returns O output
|
||||
*
|
||||
* @param i The input processed from an argument
|
||||
*
|
||||
* @return The complex data type that came as a result from this argument
|
||||
* @throws ArgumentSyntaxException If the input can not be turned into the desired output
|
||||
* (E.X. an invalid extension name)
|
||||
*/
|
||||
O accept(I i) throws ArgumentSyntaxException;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user