diff --git a/expression/pom.xml b/expression/pom.xml deleted file mode 100644 index 4c6eab3f4..000000000 --- a/expression/pom.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - hscore - me.hsgamer - 4.6.0-SNAPSHOT - - 4.0.0 - - hscore-expression - - - 11 - - - - - com.ezylang - EvalEx - 3.4.0 - - - \ No newline at end of file diff --git a/expression/src/main/java/me/hsgamer/hscore/expression/ExpressionUtils.java b/expression/src/main/java/me/hsgamer/hscore/expression/ExpressionUtils.java deleted file mode 100644 index 878632044..000000000 --- a/expression/src/main/java/me/hsgamer/hscore/expression/ExpressionUtils.java +++ /dev/null @@ -1,87 +0,0 @@ -package me.hsgamer.hscore.expression; - -import com.ezylang.evalex.config.ExpressionConfiguration; -import com.ezylang.evalex.functions.FunctionIfc; -import com.ezylang.evalex.functions.basic.AverageFunction; -import com.ezylang.evalex.functions.string.StringContains; -import com.ezylang.evalex.functions.string.StringEndsWithFunction; -import com.ezylang.evalex.functions.string.StringStartsWithFunction; -import com.ezylang.evalex.operators.OperatorIfc; -import me.hsgamer.hscore.expression.string.*; - -import java.util.Map; -import java.util.function.Function; - -/** - * The expression manager - */ -public final class ExpressionUtils { - private static Function expressionConfigurationModifier; - - static { - expressionConfigurationModifier = configuration -> - configuration.withAdditionalFunctions( - Map.entry("AVG", new AverageFunction()), - Map.entry("STRCT", new StringContains()), - Map.entry("STREDW", new StringEndsWithFunction()), - Map.entry("STREQ", new Equals()), - Map.entry("STREQIC", new EqualsIgnoreCase()), - Map.entry("STRLEN", new Length()), - Map.entry("STRMP", new MatchPattern()), - Map.entry("STRSTW", new StringStartsWithFunction()) - ); - } - - private ExpressionUtils() { - - } - - /** - * Register a function - * - * @param name the name of the function - * @param function the function - */ - public static void registerFunction(String name, FunctionIfc function) { - expressionConfigurationModifier = expressionConfigurationModifier.andThen(configuration -> configuration.withAdditionalFunctions(Map.entry(name, function))); - } - - /** - * Register an operator - * - * @param name the name of the operator - * @param operator the operator - */ - public static void registerOperator(String name, OperatorIfc operator) { - expressionConfigurationModifier = expressionConfigurationModifier.andThen(configuration -> configuration.withAdditionalOperators(Map.entry(name, operator))); - } - - /** - * Get the expression configuration modifier - * - * @return the expression configuration modifier - */ - public static Function getExpressionConfigurationModifier() { - return expressionConfigurationModifier; - } - - /** - * Get the default expression configuration - * - * @return the expression configuration - */ - public static ExpressionConfiguration getDefaultExpressionConfiguration() { - return expressionConfigurationModifier.apply(ExpressionConfiguration.defaultConfiguration()); - } - - /** - * Apply the modifier to the expression configuration - * - * @param configuration the configuration - * - * @return the modified configuration - */ - public static ExpressionConfiguration applyExpressionConfigurationModifier(ExpressionConfiguration configuration) { - return expressionConfigurationModifier.apply(configuration); - } -} diff --git a/expression/src/main/java/me/hsgamer/hscore/expression/StringComparator.java b/expression/src/main/java/me/hsgamer/hscore/expression/StringComparator.java deleted file mode 100644 index 5607b4042..000000000 --- a/expression/src/main/java/me/hsgamer/hscore/expression/StringComparator.java +++ /dev/null @@ -1,27 +0,0 @@ -package me.hsgamer.hscore.expression; - -import com.ezylang.evalex.Expression; -import com.ezylang.evalex.data.EvaluationValue; -import com.ezylang.evalex.functions.AbstractFunction; -import com.ezylang.evalex.parser.Token; -import org.jetbrains.annotations.NotNull; - -/** - * The String Comparator - */ -public abstract class StringComparator extends AbstractFunction { - /** - * Compare the two strings - * - * @param s1 the 1st string - * @param s2 the 2nd string - * - * @return the result - */ - public abstract boolean compare(@NotNull String s1, @NotNull String s2); - - @Override - public EvaluationValue evaluate(Expression expression, Token token, EvaluationValue... evaluationValues) { - return EvaluationValue.booleanValue(compare(evaluationValues[0].getStringValue(), evaluationValues[1].getStringValue())); - } -} diff --git a/expression/src/main/java/me/hsgamer/hscore/expression/package-info.java b/expression/src/main/java/me/hsgamer/hscore/expression/package-info.java deleted file mode 100644 index 2154cadde..000000000 --- a/expression/src/main/java/me/hsgamer/hscore/expression/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Contains the classes to work with expressions in EzyLang's EvalEx - */ -package me.hsgamer.hscore.expression; \ No newline at end of file diff --git a/expression/src/main/java/me/hsgamer/hscore/expression/string/Equals.java b/expression/src/main/java/me/hsgamer/hscore/expression/string/Equals.java deleted file mode 100644 index 332352ecc..000000000 --- a/expression/src/main/java/me/hsgamer/hscore/expression/string/Equals.java +++ /dev/null @@ -1,17 +0,0 @@ -package me.hsgamer.hscore.expression.string; - -import com.ezylang.evalex.functions.FunctionParameter; -import me.hsgamer.hscore.expression.StringComparator; -import org.jetbrains.annotations.NotNull; - -/** - * Check if the 1st string is the same as the 2nd string
Ex: STREQ("str1", "str1") - */ -@FunctionParameter(name = "first") -@FunctionParameter(name = "second") -public class Equals extends StringComparator { - @Override - public boolean compare(@NotNull String s1, @NotNull String s2) { - return s1.equals(s2); - } -} diff --git a/expression/src/main/java/me/hsgamer/hscore/expression/string/EqualsIgnoreCase.java b/expression/src/main/java/me/hsgamer/hscore/expression/string/EqualsIgnoreCase.java deleted file mode 100644 index e4dc5ec54..000000000 --- a/expression/src/main/java/me/hsgamer/hscore/expression/string/EqualsIgnoreCase.java +++ /dev/null @@ -1,18 +0,0 @@ -package me.hsgamer.hscore.expression.string; - -import com.ezylang.evalex.functions.FunctionParameter; -import me.hsgamer.hscore.expression.StringComparator; -import org.jetbrains.annotations.NotNull; - -/** - * Check if the 1st string is the same as the 2nd string (case-insensitive)
Ex: STREQIC("Str1", - * "str1") - */ -@FunctionParameter(name = "first") -@FunctionParameter(name = "second") -public class EqualsIgnoreCase extends StringComparator { - @Override - public boolean compare(@NotNull String s1, @NotNull String s2) { - return s1.equalsIgnoreCase(s2); - } -} diff --git a/expression/src/main/java/me/hsgamer/hscore/expression/string/Length.java b/expression/src/main/java/me/hsgamer/hscore/expression/string/Length.java deleted file mode 100644 index 1f4a45b5a..000000000 --- a/expression/src/main/java/me/hsgamer/hscore/expression/string/Length.java +++ /dev/null @@ -1,20 +0,0 @@ -package me.hsgamer.hscore.expression.string; - -import com.ezylang.evalex.Expression; -import com.ezylang.evalex.data.EvaluationValue; -import com.ezylang.evalex.functions.AbstractFunction; -import com.ezylang.evalex.functions.FunctionParameter; -import com.ezylang.evalex.parser.Token; - -import java.math.BigDecimal; - -/** - * Get the length of the string
Ex: STRLEN("Hello World") - */ -@FunctionParameter(name = "value") -public class Length extends AbstractFunction { - @Override - public EvaluationValue evaluate(Expression expression, Token token, EvaluationValue... evaluationValues) { - return EvaluationValue.numberValue(BigDecimal.valueOf(evaluationValues[0].getStringValue().length())); - } -} diff --git a/expression/src/main/java/me/hsgamer/hscore/expression/string/MatchPattern.java b/expression/src/main/java/me/hsgamer/hscore/expression/string/MatchPattern.java deleted file mode 100644 index 3dea09424..000000000 --- a/expression/src/main/java/me/hsgamer/hscore/expression/string/MatchPattern.java +++ /dev/null @@ -1,18 +0,0 @@ -package me.hsgamer.hscore.expression.string; - -import com.ezylang.evalex.functions.FunctionParameter; -import me.hsgamer.hscore.expression.StringComparator; -import org.jetbrains.annotations.NotNull; - -/** - * Check if the 1st string matches the RegEx pattern from the 2nd string
Ex: STRMP("String", - * "String-?") - */ -@FunctionParameter(name = "string") -@FunctionParameter(name = "pattern") -public class MatchPattern extends StringComparator { - @Override - public boolean compare(@NotNull String s1, @NotNull String s2) { - return s1.matches(s2); - } -} diff --git a/expression/src/main/java/me/hsgamer/hscore/expression/string/package-info.java b/expression/src/main/java/me/hsgamer/hscore/expression/string/package-info.java deleted file mode 100644 index 14498f87f..000000000 --- a/expression/src/main/java/me/hsgamer/hscore/expression/string/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Contains the implementation of {@link me.hsgamer.hscore.expression.StringComparator} - */ -package me.hsgamer.hscore.expression.string; \ No newline at end of file diff --git a/pom.xml b/pom.xml index 3462d6426..87d4e9844 100644 --- a/pom.xml +++ b/pom.xml @@ -46,7 +46,6 @@ variable builder collections - expression web request serializer