/** * ***************************************************************************************************************** * * <p>Adds a tag to this <code>Directory</code>. * * @param tag the tag to add * <p>**************************************************************************************************************** */ public void addTag(@Nonnull final AbstractTag tag) { if (tag != null) { final int key = tag.getCode(); tagMapByKey.put(tagRegistry.getKey(key), tag); keyList.add(tagRegistry.getKey(key)); } }
/** * ***************************************************************************************************************** * * <p>Removes a given tag from this </code>Directory</code> * * @param key the tag key * @return the remove tag * <p>**************************************************************************************************************** */ @CheckForNull public AbstractTag removeTag(@Nonnull final Object key) { keyList.remove(tagRegistry.getKey(key)); return tagMapByKey.remove(tagRegistry.getKey(key)); }
/** * ***************************************************************************************************************** * * <p>Checks if this <code>Directory</code> contains a given tag. * * @param key the tag key * @return true if this <code>Directory</code> contains the tag * <p>**************************************************************************************************************** */ public boolean containsTag(@Nonnull final Object key) { return (tagRegistry != null) && tagMapByKey.containsKey(tagRegistry.getKey(key)); }
/** * ***************************************************************************************************************** * * <p>Retrieves a contained tag given its key. * * @param key the tag key * <p>**************************************************************************************************************** */ @CheckForNull public AbstractTag getTag(@Nonnull final Object key) { return tagMapByKey.get(tagRegistry.getKey(key)); }