/** * Removes an element and returns the removed element. * * @param key key of the element that should be removed * @return element that was removed, or null if no element with the given * key exists */ E remove(@NonNull K key);
/** * Returns list of items with a certain type containing all of the given tags. * * @param type * - item type as defined by {@link ItemFactory}s * @param tags * - array of tags to be present on the returned items. * @return list of items which contains all of the given tags. */ public @NonNull Collection<Item> getItemsByTagAndType(@NonNull String type, @NonNull String... tags);
/** * Adds a {@link RegistryChangeListener} to the registry. * * @param listener registry change listener */ void addRegistryChangeListener(@NonNull RegistryChangeListener<E> listener);
/** * Removes a {@link RegistryChangeListener} from the registry. * * @param listener registry change listener */ void removeRegistryChangeListener(@NonNull RegistryChangeListener<E> listener);
/** * This method retrieves a single item from the registry. * * @param name the item name * @return the uniquely identified item * @throws ItemNotFoundException if no item matches the input */ public @NonNull Item getItem(String name) throws ItemNotFoundException;
/** * This method retrieves a single item from the registry. * Search patterns and shortened versions are supported, if they uniquely identify an item * * @param name the item name, a part of the item name or a search pattern * @return the uniquely identified item * @throws ItemNotFoundException if no item matches the input * @throws ItemNotUniqueException if multiply items match the input */ public @NonNull Item getItemByPattern(@NonNull String name) throws ItemNotFoundException, ItemNotUniqueException;
/** * Adds an element. * * @param element element to be added */ void add(@NonNull E element);
/** * Updates an element. * * @param element element to be updated * @return returns the old element or null if no element with the same key * exists */ E update(@NonNull E element);
/** * Adds the given element to the according {@link ManagedProvider}. * * @param element element to be added (must not be null) * @return the added element or newly created object of the same type * @throws IllegalStateException if no ManagedProvider is available */ public @NonNull E add(@NonNull E element);
/** * Removes the given element from the according {@link ManagedProvider}. * * @param key key of the element (must not be null) * @return element that was removed, or null if no element with the given * key exists * @throws IllegalStateException if no ManagedProvider is available */ public @Nullable E remove(@NonNull K key); }
private @NonNull State convertOrUndef(QuantityType<?> quantityState, Unit<?> targetUnit) { QuantityType<?> converted = quantityState.toUnit(targetUnit); if (converted != null) { return converted; } return UnDefType.UNDEF; }
/** * Translates the Items class simple name into a type name understandable by * the {@link ItemFactory}s. * * @param item the Item to translate the name * @return the translated ItemTypeName understandable by the {@link ItemFactory}s */ private @NonNull String toItemFactoryName(Item item) { return item.getType(); }
/** * Removes all metadata of a given item * * @param itemname the name of the item for which the metadata is to be removed. */ @Override public void removeItemMetadata(@NonNull String name) { logger.debug("Removing all metadata for item {}", name); getAll().stream().filter(MetadataPredicates.ofItem(name)).map(Metadata::getUID).forEach(this::remove); }
private List<@NonNull String> getMemberNamesRecursively(GroupItem groupItem, Collection<Item> allItems) { List<@NonNull String> memberNames = new ArrayList<>(); for (Item item : allItems) { if (item.getGroupNames().contains(groupItem.getName())) { memberNames.add(item.getName()); if (item instanceof GroupItem) { memberNames.addAll(getMemberNamesRecursively((GroupItem) item, allItems)); } } } return memberNames; }