/** * Tests to see if a metadata attribute has been set on an object. * * @param subject the object upon which the has-metadata test is * performed. * @param metadataKey the unique metadata key being queried. * @return the existence of the metadataKey within subject. */ public synchronized boolean hasMetadata(T subject, String metadataKey) { String key = disambiguate(subject, metadataKey); return metadataMap.containsKey(key); }
/** * Returns all metadata values attached to an object. If multiple * have attached metadata, each will value will be included. * * @param subject the object being interrogated. * @param metadataKey the unique metadata key being sought. * @return A list of values, one for each plugin that has set the * requested value. * @see MetadataStore#getMetadata(Object, String) */ public synchronized List<MetadataValue> getMetadata(T subject, String metadataKey) { String key = disambiguate(subject, metadataKey); if (metadataMap.containsKey(key)) { Collection<MetadataValue> values = metadataMap.get(key).values(); return Collections.unmodifiableList(new ArrayList<MetadataValue>(values)); } else { return Collections.emptyList(); } }
/** * Removes a metadata item owned by a plugin from a subject. * * @param subject the object to remove the metadata from. * @param metadataKey the unique metadata key identifying the metadata to * remove. * @param owningPlugin the plugin attempting to remove a metadata item. * @see MetadataStore#removeMetadata(Object, String, * org.bukkit.plugin.Plugin) * @throws IllegalArgumentException If plugin is null */ public synchronized void removeMetadata(T subject, String metadataKey, Plugin owningPlugin) { Validate.notNull(owningPlugin, "Plugin cannot be null"); String key = disambiguate(subject, metadataKey); Map<Plugin, MetadataValue> entry = metadataMap.get(key); if (entry == null) { return; } entry.remove(owningPlugin); if (entry.isEmpty()) { metadataMap.remove(key); } }
Plugin owningPlugin = newMetadataValue.getOwningPlugin(); Validate.notNull(owningPlugin, "Plugin cannot be null"); String key = disambiguate(subject, metadataKey); Map<Plugin, MetadataValue> entry = metadataMap.get(key); if (entry == null) {
/** * Tests to see if a metadata attribute has been set on an object. * * @param subject the object upon which the has-metadata test is * performed. * @param metadataKey the unique metadata key being queried. * @return the existence of the metadataKey within subject. */ public synchronized boolean hasMetadata(T subject, String metadataKey) { String key = disambiguate(subject, metadataKey); return metadataMap.containsKey(key); }
/** * Returns all metadata values attached to an object. If multiple * have attached metadata, each will value will be included. * * @param subject the object being interrogated. * @param metadataKey the unique metadata key being sought. * @return A list of values, one for each plugin that has set the * requested value. * @see MetadataStore#getMetadata(Object, String) */ public synchronized List<MetadataValue> getMetadata(T subject, String metadataKey) { String key = disambiguate(subject, metadataKey); if (metadataMap.containsKey(key)) { Collection<MetadataValue> values = metadataMap.get(key).values(); return Collections.unmodifiableList(new ArrayList<MetadataValue>(values)); } else { return Collections.emptyList(); } }
/** * Removes a metadata item owned by a plugin from a subject. * * @param subject the object to remove the metadata from. * @param metadataKey the unique metadata key identifying the metadata to * remove. * @param owningPlugin the plugin attempting to remove a metadata item. * @see MetadataStore#removeMetadata(Object, String, * org.bukkit.plugin.Plugin) * @throws IllegalArgumentException If plugin is null */ public synchronized void removeMetadata(T subject, String metadataKey, Plugin owningPlugin) { Validate.notNull(owningPlugin, "Plugin cannot be null"); String key = disambiguate(subject, metadataKey); Map<Plugin, MetadataValue> entry = metadataMap.get(key); if (entry == null) { return; } entry.remove(owningPlugin); if (entry.isEmpty()) { metadataMap.remove(key); } }
Plugin owningPlugin = newMetadataValue.getOwningPlugin(); Validate.notNull(owningPlugin, "Plugin cannot be null"); String key = disambiguate(subject, metadataKey); Map<Plugin, MetadataValue> entry = metadataMap.get(key); if (entry == null) {