ru.cwcode.commands.extra.RepositoryAccessor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Common Show documentation
Show all versions of Common Show documentation
Common of commands library (Minecraft)
package ru.cwcode.commands.extra;
import ru.cwcode.commands.Argument;
import ru.cwcode.commands.api.Sender;
import ru.cwcode.commands.extra.command.argument.KeyArgument;
import java.util.Collection;
import java.util.function.BiFunction;
import java.util.function.Function;
public class RepositoryAccessor {
private final BiFunction elementToKey;
private final BiFunction keyToElement;
private final Function keyToString;
private final Function stringToKey;
private final Function> keys;
public RepositoryAccessor(BiFunction elementToKey,
BiFunction keyToElement,
Function keyToString,
Function stringToKey,
Function> keys) {
this.elementToKey = elementToKey;
this.keyToElement = keyToElement;
this.keyToString = keyToString;
this.stringToKey = stringToKey;
this.keys = keys;
}
public Collection keys(S sender) {
return keys.apply(sender);
}
public K elementToKey(E element, S sender) {
return elementToKey.apply(element, sender);
}
public E keyToElement(S sender, K key) {
return keyToElement.apply(key, sender);
}
public String keyToString(K key) {
return keyToString.apply(key);
}
public K stringToKey(String string) {
return stringToKey.apply(string);
}
public Argument keyArgument() {
return new KeyArgument(this); //мб стоит 1 сохранить
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy