From 28025895e0da1e6079264dbfe951e7fd9bf069d8 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 11 Aug 2019 23:28:33 +0800 Subject: Scrollable Entry List? --- .../java/me/shedaniel/rei/impl/SearchArgument.java | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/main/java/me/shedaniel/rei/impl/SearchArgument.java (limited to 'src/main/java/me/shedaniel/rei/impl/SearchArgument.java') diff --git a/src/main/java/me/shedaniel/rei/impl/SearchArgument.java b/src/main/java/me/shedaniel/rei/impl/SearchArgument.java new file mode 100644 index 000000000..7c53c4fa9 --- /dev/null +++ b/src/main/java/me/shedaniel/rei/impl/SearchArgument.java @@ -0,0 +1,58 @@ +/* + * Roughly Enough Items by Danielshe. + * Licensed under the MIT License. + */ + +package me.shedaniel.rei.impl; + +import java.util.Locale; +import java.util.function.Function; + +public class SearchArgument { + + public static final SearchArgument ALWAYS = new SearchArgument(ArgumentType.ALWAYS, "", true); + private ArgumentType argumentType; + private String text; + public final Function INCLUDE = s -> s.contains(text); + public final Function NOT_INCLUDE = s -> !s.contains(text); + private boolean include; + + public SearchArgument(ArgumentType argumentType, String text, boolean include) { + this(argumentType, text, include, true); + } + + public SearchArgument(ArgumentType argumentType, String text, boolean include, boolean autoLowerCase) { + this.argumentType = argumentType; + this.text = autoLowerCase ? text.toLowerCase(Locale.ROOT) : text; + this.include = include; + } + + public Function getFunction(boolean include) { + return include ? INCLUDE : NOT_INCLUDE; + } + + public ArgumentType getArgumentType() { + return argumentType; + } + + public String getText() { + return text; + } + + public boolean isInclude() { + return include; + } + + @Override + public String toString() { + return String.format("Argument[%s]: name = %s, include = %b", argumentType.name(), text, include); + } + + public enum ArgumentType { + TEXT, + MOD, + TOOLTIP, + ALWAYS + } + +} -- cgit