ru.cwcode.commands.arguments.basic.DynamicArg Maven / Gradle / Ivy
package ru.cwcode.commands.arguments.basic;
import ru.cwcode.commands.Argument;
import ru.cwcode.commands.api.Sender;
import java.util.List;
import java.util.function.Function;
import java.util.function.Predicate;
@Deprecated
public class DynamicArg extends Argument {
final Function> dynamicArgument;
final Predicate predicate;
private final String name;
public DynamicArg(String name, Function> dynamicArgument, Predicate predicate) {
this.dynamicArgument = dynamicArgument;
this.predicate = predicate;
this.name = name;
}
@Override
public Boolean toBoolean() {
return Boolean.parseBoolean(raw);
}
@Override
public boolean valid(String raw) {
return predicate.test(raw);
}
@Override
public List completions(Sender sender) {
return dynamicArgument.apply(sender);
}
@Override
public String argumentName() {
return name;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy