org.apache.hadoop.hdfs.util
Class EnumCounters<E extends Enum<E>>

java.lang.Object
  extended by org.apache.hadoop.hdfs.util.EnumCounters<E>
Type Parameters:
E - the enum type
Direct Known Subclasses:
Content.Counts, Quota.Counts

public class EnumCounters<E extends Enum<E>>
extends Object

Counters for an enum type. For example, suppose there is an enum type

 enum Fruit { APPLE, ORANGE, GRAPE }
 
An EnumCounters object can be created for counting the numbers of APPLE, ORANGLE and GRAPE.


Nested Class Summary
static interface EnumCounters.Factory<E extends Enum<E>,C extends EnumCounters<E>>
          A factory for creating counters.
static class EnumCounters.Map<K,E extends Enum<E>,C extends EnumCounters<E>>
          A key-value map which maps the keys to EnumCounters.
 
Constructor Summary
EnumCounters(Class<E> enumClass)
          Construct counters for the given enum constants.
 
Method Summary
 void add(E e, long value)
          Add the given value to counter e.
 void add(EnumCounters<E> that)
          Add that counters to this counters.
 boolean equals(Object obj)
           
 long get(E e)
           
 int hashCode()
           
 void negation()
          Negate all counters.
 void set(E e, long value)
          Set counter e to the given value.
 void set(EnumCounters<E> that)
          Set this counters to that counters.
 void subtract(E e, long value)
          Subtract the given value from counter e.
 void subtract(EnumCounters<E> that)
          Subtract this counters from that counters.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EnumCounters

public EnumCounters(Class<E> enumClass)
Construct counters for the given enum constants.

Parameters:
enumClass - the enum class of the counters.
Method Detail

get

public final long get(E e)
Returns:
the value of counter e.

negation

public final void negation()
Negate all counters.


set

public final void set(E e,
                      long value)
Set counter e to the given value.


set

public final void set(EnumCounters<E> that)
Set this counters to that counters.


add

public final void add(E e,
                      long value)
Add the given value to counter e.


add

public final void add(EnumCounters<E> that)
Add that counters to this counters.


subtract

public final void subtract(E e,
                           long value)
Subtract the given value from counter e.


subtract

public final void subtract(EnumCounters<E> that)
Subtract this counters from that counters.


equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2014 Apache Software Foundation. All Rights Reserved.