Class DataComponent.Patch

java.lang.Object
com.saicone.rtag.data.DataComponent.Patch
Enclosing class:
DataComponent

@Experimental public static class DataComponent.Patch extends Object
Class to invoke methods from DataComponentPatch.
Instead of patched map, a component patch acts like a cloneable object that can be introduced into maps and also hold empty values to future deletion.
  • Field Details

    • EMPTY

      public static final Object EMPTY
      An empty DataComponentPatch instance.
  • Method Details

    • builder

      public static DataComponent.Builder<Optional<?>> builder()
      Create a DataComponentPatch builder to set values and then wrap into component patch.
      Returns:
      a newly generated builder to edit.
    • get

      public static Optional<Object> get(Object patch, Object type)
      Get a declared component type from provided component patch.
      Parameters:
      patch - the component patch to get component from.
      type - the DataComponentType instance that declares a component type.
      Returns:
      the component declared type from data component cache wrapped into optional object.
    • getValue

      public static it.unimi.dsi.fastutil.objects.Reference2ObjectMap<Object,Optional<?>> getValue(Object patch)
      Get the map value from component patch.
      Parameters:
      patch - the patch to get the value itself.
      Returns:
      a Reference2ObjectMap inside component patch.
    • entrySet

      public static Set<Map.Entry<Object,Optional<?>>> entrySet(Object patch)
      Get a DataComponentType key set from component patch.
      Parameters:
      patch - the patch to get the key set.
      Returns:
      set full of DataComponentType objects.
    • size

      public static int size(Object patch)
      Get the size of provided component patch.
      Parameters:
      patch - the component patch to get size.
      Returns:
      the number of data type elements in provided component patch.
    • isEmpty

      public static boolean isEmpty(Object patch)
      Check if the provided component patch is empty.
      Parameters:
      patch - the component patch to check.
      Returns:
      true if the component patch has no elements.
    • setValue

      public static void setValue(Object patch, it.unimi.dsi.fastutil.objects.Reference2ObjectMap<Object,Optional<?>> value)
      Replace the map value into component patch.
      Parameters:
      patch - the component patch to set the map value.
      value - a Reference2ObjectMap with DataComponentType as keys and wrapped declared objects has values.