Class Ref<T>

java.lang.Object
alexiil.mc.lib.attributes.misc.Ref<T>
All Implemented Interfaces:
Reference<T>

public final class Ref<T> extends Object implements Reference<T>
A simple Reference that holds the value directly in the field obj, and accepts any new value.
  • Field Details

    • obj

      public T obj
  • Constructor Details

    • Ref

      public Ref(T obj)
  • Method Details

    • get

      public T get()
      Specified by:
      get in interface Reference<T>
      Returns:
      The object referenced. Note that you should generally not modify the returned value directly - instead copy it before passing it to Reference.set(Object) or Reference.isValid(Object) to see if your modifications are permitted.
    • set

      public boolean set(T value)
      Specified by:
      set in interface Reference<T>
      Returns:
      True if the new value was accepted, false otherwise.
    • isValid

      public boolean isValid(T value)
      Specified by:
      isValid in interface Reference<T>
      Returns:
      True if Reference.set(Object) was called with the same value.