mirror of
https://github.com/Flowsqy/ShopChest.git
synced 2025-02-08 12:31:19 +01:00
Add basic providers
This commit is contained in:
parent
a475cdc5e6
commit
615438d55a
@ -0,0 +1,25 @@
|
||||
package de.epiceric.shopchest.config.hologram.provider;
|
||||
|
||||
import de.epiceric.shopchest.config.hologram.HologramFormat;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ConstantProvider<T> implements RequirementProvider<T> {
|
||||
|
||||
private final T constant;
|
||||
|
||||
public ConstantProvider(T constant) {
|
||||
this.constant = constant;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public T apply(Map<HologramFormat.Requirement, Object> requirementObjectMap) {
|
||||
return constant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return constant.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package de.epiceric.shopchest.config.hologram.provider;
|
||||
|
||||
import de.epiceric.shopchest.config.hologram.HologramFormat;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class MapProvider<T> implements RequirementProvider<T> {
|
||||
|
||||
protected final HologramFormat.Requirement requirement;
|
||||
|
||||
public MapProvider(HologramFormat.Requirement requirement) {
|
||||
this.requirement = requirement;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return requirement.toString();
|
||||
}
|
||||
|
||||
public final static class StringMapProvider extends MapProvider<String> {
|
||||
|
||||
public StringMapProvider(HologramFormat.Requirement requirement) {
|
||||
super(requirement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apply(Map<HologramFormat.Requirement, Object> requirementValues) {
|
||||
return (String) requirementValues.get(requirement);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final static class BooleanMapProvider extends MapProvider<Boolean> {
|
||||
|
||||
public BooleanMapProvider(HologramFormat.Requirement requirement) {
|
||||
super(requirement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean apply(Map<HologramFormat.Requirement, Object> requirementValues) {
|
||||
return (Boolean) requirementValues.get(requirement);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final static class DoubleMapProvider extends MapProvider<Double> {
|
||||
|
||||
public DoubleMapProvider(HologramFormat.Requirement requirement) {
|
||||
super(requirement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double apply(Map<HologramFormat.Requirement, Object> requirementValues) {
|
||||
return (Double) requirementValues.get(requirement);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package de.epiceric.shopchest.config.hologram.provider;
|
||||
|
||||
import de.epiceric.shopchest.config.hologram.HologramFormat;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
public interface RequirementProvider<T> extends Function<Map<HologramFormat.Requirement, Object>, T> {
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user