mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-10 12:50:17 +01:00
Documentation and visibility changes
This commit is contained in:
parent
0e4168ba45
commit
dfae6ad5f8
@ -2,9 +2,25 @@ 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;
|
||||
|
||||
}
|
||||
|
@ -217,6 +217,14 @@ public abstract class Argument<T> {
|
||||
return suggestionCallback != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps this argument's output to another result.
|
||||
*
|
||||
* @param mapper The mapper to use (this argument's input --> desired output)
|
||||
* @param <O> The type of output expected.
|
||||
*
|
||||
* @return A new ArgumentMap that can get this complex object type.
|
||||
*/
|
||||
public <O> ArgumentMap<T, O> map(ArgumentMapper<T, O> mapper) {
|
||||
return new ArgumentMap<>(this, mapper);
|
||||
}
|
||||
|
@ -6,7 +6,8 @@ import net.minestom.server.command.builder.exception.ArgumentSyntaxException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents an argument that maps an existing argument to a vlaue.
|
||||
* Represents an argument that maps an existing argument to a value.
|
||||
*
|
||||
* @param <I> The input (any object)
|
||||
* @param <O> The output (any object)
|
||||
*/
|
||||
@ -15,7 +16,7 @@ public class ArgumentMap<I, O> extends Argument<O> {
|
||||
final Argument<I> argument;
|
||||
final ArgumentMapper<I, O> mapper;
|
||||
|
||||
public ArgumentMap(Argument<I> argument, ArgumentMapper<I, O> mapper) {
|
||||
protected ArgumentMap(Argument<I> argument, ArgumentMapper<I, O> mapper) {
|
||||
super(argument.getId());
|
||||
|
||||
this.argument = argument;
|
||||
|
Loading…
Reference in New Issue
Block a user