Interface ItemRegistry

  • All Superinterfaces:
    Registry<Item,​String>
    All Known Subinterfaces:
    ItemUIRegistry

    @NonNullByDefault
    public interface ItemRegistry
    extends Registry<Item,​String>
    The ItemRegistry is the central place, where items are kept in memory and their state is permanently tracked. So any code that requires the current state of items should use this service (instead of trying to keep their own local copy of the items). Items are registered by ItemProviders, which can provision them from any source they like and also dynamically remove or add items.
    Author:
    Kai Kreuzer - Initial contribution
    • Method Detail

      • getItemByPattern

        Item getItemByPattern​(String name)
                       throws ItemNotFoundException,
                              ItemNotUniqueException
        This method retrieves a single item from the registry. Search patterns and shortened versions are supported, if they uniquely identify an item
        Parameters:
        name - the item name, a part of the item name or a search pattern
        Returns:
        the uniquely identified item
        Throws:
        ItemNotFoundException - if no item matches the input
        ItemNotUniqueException - if multiply items match the input
      • getItems

        Collection<Item> getItems()
        This method retrieves all items that are currently available in the registry
        Returns:
        a collection of all available items
      • getItemsOfType

        Collection<Item> getItemsOfType​(String type)
        This method retrieves all items with the given type
        Parameters:
        type - item type as defined by ItemFactorys
        Returns:
        a collection of all items of the given type
      • getItems

        Collection<Item> getItems​(String pattern)
        This method retrieves all items that match a given search pattern
        Returns:
        a collection of all items matching the search pattern
      • getItemsByTag

        Collection<Item> getItemsByTag​(String... tags)
        Returns list of items which contains all of the given tags.
        Parameters:
        tags - array of tags to be present on the returned items.
        Returns:
        list of items which contains all of the given tags.
      • getItemsByTagAndType

        Collection<Item> getItemsByTagAndType​(String type,
                                              String... tags)
        Returns list of items with a certain type containing all of the given tags.
        Parameters:
        type - item type as defined by ItemFactorys
        tags - array of tags to be present on the returned items.
        Returns:
        list of items which contains all of the given tags.
      • getItemsByTag

        <T extends ItemCollection<T> getItemsByTag​(Class<T> typeFilter,
                                                     String... tags)
        Returns list of items which contains all of the given tags.
        Parameters:
        typeFilter - subclass of GenericItem to filter the resulting list for.
        tags - array of tags to be present on the returned items.
        Returns:
        list of items which contains all of the given tags, which is filtered by the given type filter.
      • addRegistryHook

        void addRegistryHook​(RegistryHook<Item> hook)
        Add a hook to be informed before adding/after removing items.
        Parameters:
        hook -
      • removeRegistryHook

        void removeRegistryHook​(RegistryHook<Item> hook)
        Remove the hook again.
        Parameters:
        hook -
      • newItemBuilder

        @Deprecated
        default ItemBuilder newItemBuilder​(Item item)
        Deprecated.
        Use the ItemBuilderFactory service instead.
        Create a new ItemBuilder, which is initialized by the given item.
        Parameters:
        item - the template to initialize the builder with
        Returns:
        an ItemBuilder instance
      • newItemBuilder

        @Deprecated
        default ItemBuilder newItemBuilder​(String itemType,
                                           String itemName)
        Deprecated.
        Use the ItemBuilderFactory service instead.
        Create a new ItemBuilder, which is initialized by the given item.
        Parameters:
        itemType - the item type to create
        itemName - the name of the item to create
        Returns:
        an ItemBuilder instance