static Metadata create(Metadata metadata) { return new MapMetadata(metadata); }
@Override public Entry getEntry(String key, Visibility visibility) { getFetchHints().assertMetadataIncluded(key); getEntriesLock().readLock().lock(); try { return entries.get(toMapKey(key, visibility)); } finally { getEntriesLock().readLock().unlock(); } }
@Override public void remove(String key, Visibility visibility) { getEntriesLock().writeLock().lock(); try { entries.remove(toMapKey(key, visibility)); } finally { getEntriesLock().writeLock().unlock(); } }
@Override public boolean containsKey(String key) { getFetchHints().assertMetadataIncluded(key); getEntriesLock().readLock().lock(); try { for (Map.Entry<String, Entry> e : entries.entrySet()) { if (e.getValue().getKey().equals(key)) { return true; } } return false; } finally { getEntriesLock().readLock().unlock(); } }
@Override public void clear() { getEntriesLock().writeLock().lock(); try { entries.clear(); } finally { getEntriesLock().writeLock().unlock(); } }
public MapMetadata(Metadata copyFromMetadata, FetchHints fetchHints) { this(fetchHints); if (copyFromMetadata != null) { for (Metadata.Entry entry : copyFromMetadata.entrySet()) { add(entry.getKey(), entry.getValue(), entry.getVisibility()); } } }
@Override public boolean containsKey(String key) { getFetchHints().assertMetadataIncluded(key); getEntriesLock().readLock().lock(); try { for (Map.Entry<String, Entry> e : entries.entrySet()) { if (e.getValue().getKey().equals(key)) { return true; } } return false; } finally { getEntriesLock().readLock().unlock(); } }
@Override public void remove(String key, Visibility visibility) { getEntriesLock().writeLock().lock(); try { entries.remove(toMapKey(key, visibility)); } finally { getEntriesLock().writeLock().unlock(); } }
@Override public void clear() { getEntriesLock().writeLock().lock(); try { entries.clear(); } finally { getEntriesLock().writeLock().unlock(); } }
public MapMetadata(Metadata copyFromMetadata, FetchHints fetchHints) { this(fetchHints); if (copyFromMetadata != null) { for (Metadata.Entry entry : copyFromMetadata.entrySet()) { add(entry.getKey(), entry.getValue(), entry.getVisibility()); } } }
@Override public Collection<Metadata.Entry> getEntries(String key) { getFetchHints().assertMetadataIncluded(key); getEntriesLock().readLock().lock(); try { Collection<Metadata.Entry> results = new ArrayList<>(); for (Map.Entry<String, Entry> e : entries.entrySet()) { if (e.getValue().getKey().equals(key)) { Entry entry = e.getValue(); results.add(entry); } } return results; } finally { getEntriesLock().readLock().unlock(); } }
@Override public Entry getEntry(String key, Visibility visibility) { getFetchHints().assertMetadataIncluded(key); getEntriesLock().readLock().lock(); try { return entries.get(toMapKey(key, visibility)); } finally { getEntriesLock().readLock().unlock(); } }
@Override public Metadata add(String key, Object value, Visibility visibility) { getEntriesLock().writeLock().lock(); try { entries.put(toMapKey(key, visibility), new Entry(key, value, visibility)); return this; } finally { getEntriesLock().writeLock().unlock(); } }
static Metadata create() { return new MapMetadata(); }
@Override public Collection<Metadata.Entry> entrySet() { getEntriesLock().readLock().lock(); try { return new ArrayList<>(entries.values()); } finally { getEntriesLock().readLock().unlock(); } }
@Override public Collection<Metadata.Entry> getEntries(String key) { getFetchHints().assertMetadataIncluded(key); getEntriesLock().readLock().lock(); try { Collection<Metadata.Entry> results = new ArrayList<>(); for (Map.Entry<String, Entry> e : entries.entrySet()) { if (e.getValue().getKey().equals(key)) { Entry entry = e.getValue(); results.add(entry); } } return results; } finally { getEntriesLock().readLock().unlock(); } }
@Override public Metadata add(String key, Object value, Visibility visibility) { getEntriesLock().writeLock().lock(); try { entries.put(toMapKey(key, visibility), new Entry(key, value, visibility)); return this; } finally { getEntriesLock().writeLock().unlock(); } }
static Metadata create(FetchHints fetchHints) { return new MapMetadata(fetchHints); }
@Override public Collection<Metadata.Entry> entrySet() { getEntriesLock().readLock().lock(); try { return new ArrayList<>(entries.values()); } finally { getEntriesLock().readLock().unlock(); } }
@Override public Entry getEntry(String key) { getFetchHints().assertMetadataIncluded(key); getEntriesLock().readLock().lock(); try { Entry entry = null; for (Map.Entry<String, Entry> e : entries.entrySet()) { if (e.getValue().getKey().equals(key)) { if (entry != null) { throw new VertexiumException("Multiple matching entries for key: " + key); } entry = e.getValue(); } } return entry; } finally { getEntriesLock().readLock().unlock(); } }