Class ObjectReference

  • All Implemented Interfaces:
    IObjectReference, Serializable

    public final class ObjectReference
    extends Object
    implements IObjectReference
    A reference to an object (a concrete instance of a certain type of objects), consisting of the type of the objects and the unique identifier of the object within that type.
    Since:
    8.5.0
    See Also:
    Serialized Form
    • Method Detail

      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • copyOf

        public static ObjectReference copyOf​(IObjectReference value)
        Creates a copy of the given object reference with the same type and id.
        Parameters:
        value - The object reference to copy.
        Returns:
        The copied object reference.
      • of

        public static ObjectReference of​(String type,
                                         String id)
        Creates a new object reference of the given type and id.
        Parameters:
        type - The type of the object. Must have a toString() method that returns a unique string representation.
        id - The identifier for the object of that type. Must have a toString() method that returns a unique string representation.
        Returns:
        The object reference.
      • ofKnown

        public static ObjectReference ofKnown​(EntityType type,
                                              String id)
        Creates a new object reference of the given type and id.
        Parameters:
        type - The type of the object. Must have a toString() method that returns a unique string representation.
        id - The identifier for the object of that type. Must have a toString() method that returns a unique string representation.
        Returns:
        The object reference.
      • valueOf

        public static ObjectReference valueOf​(String value)
        Parses an object reference from its string representation, as returned by toString().
        Parameters:
        value - The string representation.
        Returns:
        The object reference, or null if the string is null or blank.
        Throws:
        IllegalArgumentException - If the string is not in the correct format.