Interface IObjectReference

  • All Superinterfaces:
    Serializable
    All Known Subinterfaces:
    IEntityReference
    All Known Implementing Classes:
    ObjectReference, UuidEntityRef

    public interface IObjectReference
    extends Serializable
    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
    • Method Detail

      • getId

        String getId()
        Gets the ID of the identified object.
        Returns:
        The object ID.
      • getId

        default <T> Optional<T> getId​(Function<? super String,​? extends T> parser)
        Parses the identifier using the given parser function. Returns empty when not parseable.
        Type Parameters:
        T - The type of the parsed identifier.
        Parameters:
        parser - The parser function, such as a ::valueOf method of some class.
        Returns:
        An optional containing the parsed identifier, or an empty optional if parsing failed.
      • getTypeKnown

        default Optional<EntityType> getTypeKnown()
        Gets the type as one of the known entity types. Returns empty when not parseable.
        Returns:
        An optional containing the known type, or an empty optional if parsing failed.
      • getType

        String getType()
        Gets the type of the identified objects. This should be the type name of an EntityType, if available, but may be another string in case no such entity type exists. Prefer getTypeKnown() if applicable.
        Returns:
        The object type.