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 Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Object
    An empty DataComponentPatch instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    Create a DataComponentPatch builder to set values and then wrap into component patch.
    Get a DataComponentType key set from component patch.
    On versions older than 26.3 this method return a set of entries with Optional objects as values.
    static Object
    get(Object patch, Object type)
    Get a declared component type from provided component patch.
    static it.unimi.dsi.fastutil.objects.Reference2ObjectMap<Object,Object>
    Get the map value from component patch.
    On versions older than 26.3 this method return a map with Optional objects as values.
    static boolean
    isEmpty(Object patch)
    Check if the provided component patch is empty.
    static void
    setValue(Object patch, it.unimi.dsi.fastutil.objects.Reference2ObjectMap<Object,Object> value)
    Replace the map value into component patch.
    If server version is older than 26.3 the map values must be Optional objects.
    static int
    size(Object patch)
    Get the size of provided component patch.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • EMPTY

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

    • builder

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

      public static 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.
    • getValue

      public static it.unimi.dsi.fastutil.objects.Reference2ObjectMap<Object,Object> getValue(Object patch)
      Get the map value from component patch.
      On versions older than 26.3 this method return a map with Optional objects as values.
      Parameters:
      patch - the patch to get the value itself.
      Returns:
      a Reference2ObjectMap inside component patch.
    • entrySet

      public static Set<Map.Entry<Object,Object>> entrySet(Object patch)
      Get a DataComponentType key set from component patch.
      On versions older than 26.3 this method return a set of entries with Optional objects as values.
      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,Object> value)
      Replace the map value into component patch.
      If server version is older than 26.3 the map values must be Optional objects.
      Parameters:
      patch - the component patch to set the map value.
      value - a Reference2ObjectMap with DataComponentType as keys and wrapped declared objects has values.