@SuppressWarnings("unchecked") public synchronized C findCounter(String scheme, FileSystemCounter key) { final String canonicalScheme = checkScheme(scheme); Object[] counters = map.get(canonicalScheme); int ord = key.ordinal(); if (counters == null) { counters = new Object[FileSystemCounter.values().length]; map.put(canonicalScheme, counters); counters[ord] = newCounter(canonicalScheme, key); } else if (counters[ord] == null) { counters[ord] = newCounter(canonicalScheme, key); } return (C) counters[ord]; }
@Override public C findCounter(String counterName, String displayName) { return findCounter(counterName); }
@Override public String getDisplayName() { if (displayName == null) { displayName = ResourceBundles.getCounterGroupName(getName(), "File System Counters"); } return displayName; }
@Override public C findCounter(String counterName, boolean create) { try { String[] pair = parseCounterName(counterName); return findCounter(pair[0], FileSystemCounter.valueOf(pair[1])); } catch (Exception e) { if (create) throw new IllegalArgumentException(e); LOG.warn(counterName + " is not a recognized counter."); return null; } }
@Override public int size() { int n = 0; for (Object[] counters : map.values()) { n += numSetCounters(counters); } return n; }
@Override public synchronized boolean equals(Object genericRight) { if (genericRight instanceof CounterGroupBase<?>) { @SuppressWarnings("unchecked") CounterGroupBase<C> right = (CounterGroupBase<C>) genericRight; return Iterators.elementsEqual(iterator(), right.iterator()); } return false; }
@Override public C findCounter(String counterName, boolean create) { try { String[] pair = parseCounterName(counterName); return findCounter(pair[0], FileSystemCounter.valueOf(pair[1])); } catch (Exception e) { if (create) throw new IllegalArgumentException(e); LOG.warn(counterName + " is not a recognized counter."); return null; } }
@Override public int size() { int n = 0; for (Object[] counters : map.values()) { n += numSetCounters(counters); } return n; }
@Override public synchronized boolean equals(Object genericRight) { if (genericRight instanceof CounterGroupBase<?>) { @SuppressWarnings("unchecked") CounterGroupBase<C> right = (CounterGroupBase<C>) genericRight; return Iterators.elementsEqual(iterator(), right.iterator()); } return false; }
@Override public C findCounter(String counterName) { return findCounter(counterName, false); }
@Override public C findCounter(String counterName, boolean create) { try { String[] pair = parseCounterName(counterName); return findCounter(pair[0], FileSystemCounter.valueOf(pair[1])); } catch (Exception e) { if (create) throw new IllegalArgumentException(e); LOG.warn(counterName + " is not a recognized counter."); return null; } }
@SuppressWarnings("unchecked") public synchronized C findCounter(String scheme, FileSystemCounter key) { final String canonicalScheme = checkScheme(scheme); Object[] counters = map.get(canonicalScheme); int ord = key.ordinal(); if (counters == null) { counters = new Object[FileSystemCounter.values().length]; map.put(canonicalScheme, counters); counters[ord] = newCounter(canonicalScheme, key); } else if (counters[ord] == null) { counters[ord] = newCounter(canonicalScheme, key); } return (C) counters[ord]; }
@Override public int size() { int n = 0; for (Object[] counters : map.values()) { n += numSetCounters(counters); } return n; }
@Override public synchronized boolean equals(Object genericRight) { if (genericRight instanceof CounterGroupBase<?>) { @SuppressWarnings("unchecked") CounterGroupBase<C> right = (CounterGroupBase<C>) genericRight; return Iterators.elementsEqual(iterator(), right.iterator()); } return false; }
@Override public String getDisplayName() { if (displayName == null) { displayName = ResourceBundles.getCounterGroupName(getName(), "File System Counters"); } return displayName; }
@Override public C findCounter(String counterName, String displayName) { return findCounter(counterName); }
@Override public C findCounter(String counterName, boolean create) { try { String[] pair = parseCounterName(counterName); return findCounter(pair[0], FileSystemCounter.valueOf(pair[1])); } catch (Exception e) { if (create) throw new IllegalArgumentException(e); LOG.warn(counterName + " is not a recognized counter."); return null; } }
@SuppressWarnings("unchecked") public synchronized C findCounter(String scheme, FileSystemCounter key) { final String canonicalScheme = checkScheme(scheme); Object[] counters = map.get(canonicalScheme); int ord = key.ordinal(); if (counters == null) { counters = new Object[FileSystemCounter.values().length]; map.put(canonicalScheme, counters); counters[ord] = newCounter(canonicalScheme, key); } else if (counters[ord] == null) { counters[ord] = newCounter(canonicalScheme, key); } return (C) counters[ord]; }
@Override public int size() { int n = 0; for (Object[] counters : map.values()) { n += numSetCounters(counters); } return n; }
@Override public synchronized boolean equals(Object genericRight) { if (genericRight instanceof CounterGroupBase<?>) { @SuppressWarnings("unchecked") CounterGroupBase<C> right = (CounterGroupBase<C>) genericRight; return Iterators.elementsEqual(iterator(), right.iterator()); } return false; }