Class FunctionProcessor
java.lang.Object
io.github.toberocat.guiengine.function.FunctionProcessor
Utility class for processing and handling GUI functions.
Created: 29.04.2023 Author: Tobias Madlberger (Tobias)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Set<ComputeFunction>
static final Map<String,
Class<? extends GuiFunction>> static final com.fasterxml.jackson.databind.ObjectMapper
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull String
applyFunctions
(@NotNull GuiEngineApi api, @NotNull GuiContext context, @NotNull String value) Applies to compute functions to the provided value, replacing placeholders with their computed values.static void
callFunctions
(@NotNull Collection<GuiFunction> functions, @NotNull GuiEngineApi api, @NotNull GuiContext context) Calls a collection of GUI functions with the specified API and context.static @Nullable GuiFunction
createFunction
(@NotNull com.fasterxml.jackson.databind.JsonNode node) Creates a GUI function from a JSON node.static void
registerComputeFunction
(@NotNull ComputeFunction computeFunction) Registers a custom compute function.static void
registerFunction
(@NotNull String id, @NotNull Class<? extends GuiFunction> clazz) Registers a custom GUI function.
-
Field Details
-
FUNCTIONS
-
COMPUTE_FUNCTIONS
-
OBJECT_MAPPER
public static final com.fasterxml.jackson.databind.ObjectMapper OBJECT_MAPPER
-
-
Constructor Details
-
FunctionProcessor
public FunctionProcessor()
-
-
Method Details
-
registerFunction
public static void registerFunction(@NotNull @NotNull String id, @NotNull @NotNull Class<? extends GuiFunction> clazz) Registers a custom GUI function.- Parameters:
id
- The ID of the function.clazz
- The class implementing the custom GUI function.
-
registerComputeFunction
Registers a custom compute function.- Parameters:
computeFunction
- The custom compute function to register.
-
createFunction
@Nullable public static @Nullable GuiFunction createFunction(@NotNull @NotNull com.fasterxml.jackson.databind.JsonNode node) throws com.fasterxml.jackson.core.JsonProcessingException Creates a GUI function from a JSON node.- Parameters:
node
- The JSON node containing the function information.- Returns:
- The created `GuiFunction` instance, or null if the function could not be created.
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
- If there is an issue with processing the JSON node.
-
callFunctions
public static void callFunctions(@NotNull @NotNull Collection<GuiFunction> functions, @NotNull @NotNull GuiEngineApi api, @NotNull @NotNull GuiContext context) Calls a collection of GUI functions with the specified API and context.- Parameters:
functions
- The collection of GUI functions to call.api
- The `GuiEngineApi` instance used to interact with the GUI engine.context
- The `GuiContext` instance representing the GUI context on which the functions are called.
-
applyFunctions
@NotNull public static @NotNull String applyFunctions(@NotNull @NotNull GuiEngineApi api, @NotNull @NotNull GuiContext context, @NotNull @NotNull String value) Applies to compute functions to the provided value, replacing placeholders with their computed values.- Parameters:
api
- The `GuiEngineApi` instance used to interact with the GUI engine.context
- The `GuiContext` instance representing the GUI context for which the computation is performed.value
- The input value containing placeholders to compute.- Returns:
- The computed value with placeholders replaced by their computed values.
-