Class XMLUtil
java.lang.Object
com.github.stefvanschie.inventoryframework.util.XMLUtil
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
invokeMethod
(@NotNull Object instance, @NotNull String methodName, @NotNull Object argument, @NotNull Class<?> parameter) Invokes the method by the given name on the given instance with the provided argument.static void
loadFieldAttribute
(@NotNull Object instance, @NotNull Element element, @Nullable Object value) Sets a field from the given instance and element to the specified valueloadOnEventAttribute
(@NotNull Object instance, @NotNull Element element, @NotNull Class<T> eventType, @NotNull String name) Loads an event consumer from the given instance and element
-
Constructor Details
-
XMLUtil
public XMLUtil()
-
-
Method Details
-
loadOnEventAttribute
@Nullable @Contract(pure=true) public static <T extends Event> @Nullable Consumer<T> loadOnEventAttribute(@NotNull @NotNull Object instance, @NotNull @NotNull Element element, @NotNull @NotNull Class<T> eventType, @NotNull @NotNull String name) Loads an event consumer from the given instance and element- Type Parameters:
T
- the type of the event- Parameters:
instance
- the object instanceelement
- the elementeventType
- the type of the eventname
- the name of the attribute- Returns:
- the consumer to be called on click
-
invokeMethod
public static void invokeMethod(@NotNull @NotNull Object instance, @NotNull @NotNull String methodName, @NotNull @NotNull Object argument, @NotNull @NotNull Class<?> parameter) Invokes the method by the given name on the given instance with the provided argument. The method should have the exact name specified and the exact parameter as specified. If the method cannot be accessed or found, this will throw anXMLLoadException
.- Parameters:
instance
- the instance on which to call the methodmethodName
- the name of the method to invokeargument
- the argument to provide for the invocationparameter
- the parameter of the method- Throws:
XMLLoadException
- if the method cannot be accessed or found- Since:
- 0.10.3
-
loadFieldAttribute
public static void loadFieldAttribute(@NotNull @NotNull Object instance, @NotNull @NotNull Element element, @Nullable @Nullable Object value) Sets a field from the given instance and element to the specified value- Parameters:
instance
- the class instance the field is located inelement
- the element from which the field is specifiedvalue
- the field's new value
-