refactor(reflection): migrate to using cutin library
This commit is contained in:
@@ -4,9 +4,16 @@ import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import net.tomatentum.cutin.MethodParser;
|
||||
import net.tomatentum.cutin.util.ReflectionUtil;
|
||||
import net.tomatentum.marinara.interaction.annotation.AutoComplete;
|
||||
|
||||
public class AutocompleteParser implements AnnotationParser {
|
||||
public class AutocompleteParser implements MethodParser {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
private Method method;
|
||||
private Consumer<String[]> consumer;
|
||||
@@ -21,13 +28,8 @@ public class AutocompleteParser implements AnnotationParser {
|
||||
String[] autocompletes = Arrays.stream(this.method.getAnnotationsByType(AutoComplete.class))
|
||||
.map(AutoComplete::value)
|
||||
.toArray(String[]::new);
|
||||
this.consumer.accept(autocompletes);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Method getMethod() {
|
||||
return this.method;
|
||||
logger.trace("Parsed AutoComplete annotation {} for method {}", autocompletes, ReflectionUtil.getFullMethodName(method));
|
||||
this.consumer.accept(autocompletes);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user