/
PrefixInfo.java
39 lines (31 loc) · 986 Bytes
/
PrefixInfo.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package mezz.jei.search;
import mezz.jei.config.SearchMode;
import mezz.jei.ingredients.IIngredientListElementInfo;
import java.util.Collection;
import java.util.Collections;
public class PrefixInfo {
public static final PrefixInfo NO_PREFIX = new PrefixInfo(
() -> SearchMode.ENABLED,
i -> Collections.singleton(i.getName())
);
private final IModeGetter modeGetter;
private final IStringsGetter stringsGetter;
public PrefixInfo(IModeGetter modeGetter, IStringsGetter stringsGetter) {
this.modeGetter = modeGetter;
this.stringsGetter = stringsGetter;
}
public SearchMode getMode() {
return modeGetter.getMode();
}
public Collection<String> getStrings(IIngredientListElementInfo<?> element) {
return this.stringsGetter.getStrings(element);
}
@FunctionalInterface
public interface IStringsGetter {
Collection<String> getStrings(IIngredientListElementInfo<?> element);
}
@FunctionalInterface
public interface IModeGetter {
SearchMode getMode();
}
}