java.lang.Object
com.github.stefvanschie.inventoryframework.util.XMLUtil

public class XMLUtil extends Object
  • 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 instance
      element - the element
      eventType - the type of the event
      name - 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 an XMLLoadException.
      Parameters:
      instance - the instance on which to call the method
      methodName - the name of the method to invoke
      argument - the argument to provide for the invocation
      parameter - 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 in
      element - the element from which the field is specified
      value - the field's new value