CommonCore/testsrc/de/steamwar/command/CacheCommand.java

39 Zeilen
1.1 KiB
Java

2022-06-20 14:06:28 +02:00
package de.steamwar.command;
import de.steamwar.command.dto.TestSWCommand;
import de.steamwar.command.dto.TestTypeMapper;
import java.util.Arrays;
import java.util.Collection;
import java.util.concurrent.atomic.AtomicInteger;
public class CacheCommand extends TestSWCommand {
public CacheCommand() {
super("typemapper");
}
@Register
public void test(String sender, int tabCompleteTest) {
}
private AtomicInteger count = new AtomicInteger();
@Cached
@Mapper(value = "int", local = true)
public AbstractTypeMapper<String, Integer> typeMapper() {
System.out.println("TypeMapper register");
return new TestTypeMapper<Integer>() {
@Override
public Integer map(String sender, String[] previousArguments, String s) {
return Integer.parseInt(s);
}
@Override
public Collection<String> tabCompletes(String sender, String[] previousArguments, String s) {
return Arrays.asList(count.getAndIncrement() + "");
}
};
}
}