Class DataComponent.Builder<V>

java.lang.Object
com.saicone.rtag.data.DataComponent.Builder<V>
Enclosing class:
DataComponent

@Experimental public static class DataComponent.Builder<V> extends Object
Class wrapper to invoke methods from map and patch data component types builder.
This is not the real class, it's just a bridge between to set and get values before build.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Builder(Object builder, it.unimi.dsi.fastutil.objects.Reference2ObjectMap<Object,V> map)
    Constructs a builder with provided real builder, and it's map inside.
  • Method Summary

    Modifier and Type
    Method
    Description
    Build the required instance of data component.
    By default, this method throws an exception, so should be overridden.
    get(Object type)
    Get a declared component type from builder.
    Return the real data component builder that is wrapped inside this class.
    it.unimi.dsi.fastutil.objects.Reference2ObjectMap<Object,V>
    Return the map inside real component builder.
    boolean
    has(Object type)
    Check if the current builder contains a DataComponentType.
    On a component patch builder this method may not work to check the availability of provided type due the map can contain empty values.
    remove(Object type)
    Remove the provided DataComponentType mapping from builder and return this instance.
    set(Object type, V value)
    Set provided object type by a DataComponentType declaration of object itself as value type into builder and return this instance.

    Methods inherited from class Object

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

    • Builder

      public Builder(Object builder, it.unimi.dsi.fastutil.objects.Reference2ObjectMap<Object,V> map)
      Constructs a builder with provided real builder, and it's map inside.
      Parameters:
      builder - the real data component builder.
      map - the map inside provided builder.
  • Method Details

    • getBuilder

      public Object getBuilder()
      Return the real data component builder that is wrapped inside this class.
      Returns:
      a map or patch data component builder.
    • getMap

      public it.unimi.dsi.fastutil.objects.Reference2ObjectMap<Object,V> getMap()
      Return the map inside real component builder.
      Returns:
      a Reference2ObjectMap with DataComponentType as keys and declared objects type in this wrapper as values.
    • has

      public boolean has(Object type)
      Check if the current builder contains a DataComponentType.
      On a component patch builder this method may not work to check the availability of provided type due the map can contain empty values.
      Parameters:
      type - the DataComponentType to check if exist inside.
      Returns:
      true if component type exists.
    • get

      public V get(Object type)
      Get a declared component type from builder.
      Parameters:
      type - the DataComponentType instance that declares a component type.
      Returns:
      the component declared type from data component cache as value type.
    • set

      @Contract("_, _ -> this") public DataComponent.Builder<V> set(Object type, V value)
      Set provided object type by a DataComponentType declaration of object itself as value type into builder and return this instance.
      Parameters:
      type - the DataComponentType instance.
      value - the object value declared by component type as value type.
      Returns:
      the builder itself.
    • remove

      @Contract("_ -> this") public DataComponent.Builder<V> remove(Object type)
      Remove the provided DataComponentType mapping from builder and return this instance.
      Parameters:
      type - the DataComponentType instance to remove.
      Returns:
      the builder itself.
    • build

      public Object build()
      Build the required instance of data component.
      By default, this method throws an exception, so should be overridden.
      Returns:
      an object instance that was building this builder.