org.apache.hadoop.io
Class EnumSetWritable<E extends Enum<E>>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by org.apache.hadoop.io.EnumSetWritable<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, Configurable, Writable

@InterfaceAudience.Public
@InterfaceStability.Stable
public class EnumSetWritable<E extends Enum<E>>
extends AbstractCollection<E>
implements Writable, Configurable

A Writable wrapper for EnumSet.


Constructor Summary
EnumSetWritable(EnumSet<E> value)
          Construct a new EnumSetWritable.
EnumSetWritable(EnumSet<E> value, Class<E> elementType)
          Construct a new EnumSetWritable.
 
Method Summary
 boolean add(E e)
           
 boolean equals(Object o)
          Returns true if o is an EnumSetWritable with the same value, or both are null.
 EnumSet<E> get()
          Return the value of this EnumSetWritable.
 Configuration getConf()
          Return the configuration used by this object.
 Class<E> getElementType()
          Returns the class of all the elements of the underlying EnumSetWriable.
 int hashCode()
           
 Iterator<E> iterator()
           
 void readFields(DataInput in)
          Deserialize the fields of this object from in.
 void set(EnumSet<E> value, Class<E> elementType)
          reset the EnumSetWritable with specified value and elementType.
 void setConf(Configuration conf)
          Set the configuration to be used by this object.
 int size()
           
 String toString()
           
 void write(DataOutput out)
          Serialize the fields of this object to out.
 
Methods inherited from class java.util.AbstractCollection
addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EnumSetWritable

public EnumSetWritable(EnumSet<E> value,
                       Class<E> elementType)
Construct a new EnumSetWritable. If the value argument is null or its size is zero, the elementType argument must not be null. If the argument value's size is bigger than zero, the argument elementType is not be used.

Parameters:
value -
elementType -

EnumSetWritable

public EnumSetWritable(EnumSet<E> value)
Construct a new EnumSetWritable. Argument value should not be null or empty.

Parameters:
value -
Method Detail

iterator

public Iterator<E> iterator()
Specified by:
iterator in interface Iterable<E extends Enum<E>>
Specified by:
iterator in interface Collection<E extends Enum<E>>
Specified by:
iterator in class AbstractCollection<E extends Enum<E>>

size

public int size()
Specified by:
size in interface Collection<E extends Enum<E>>
Specified by:
size in class AbstractCollection<E extends Enum<E>>

add

public boolean add(E e)
Specified by:
add in interface Collection<E extends Enum<E>>
Overrides:
add in class AbstractCollection<E extends Enum<E>>

set

public void set(EnumSet<E> value,
                Class<E> elementType)
reset the EnumSetWritable with specified value and elementType. If the value argument is null or its size is zero, the elementType argument must not be null. If the argument value's size is bigger than zero, the argument elementType is not be used.

Parameters:
value -
elementType -

get

public EnumSet<E> get()
Return the value of this EnumSetWritable.


readFields

public void readFields(DataInput in)
                throws IOException
Description copied from interface: Writable
Deserialize the fields of this object from in.

For efficiency, implementations should attempt to re-use storage in the existing object where possible.

Specified by:
readFields in interface Writable
Parameters:
in - DataInput to deseriablize this object from.
Throws:
IOException

write

public void write(DataOutput out)
           throws IOException
Description copied from interface: Writable
Serialize the fields of this object to out.

Specified by:
write in interface Writable
Parameters:
out - DataOuput to serialize this object into.
Throws:
IOException

equals

public boolean equals(Object o)
Returns true if o is an EnumSetWritable with the same value, or both are null.

Specified by:
equals in interface Collection<E extends Enum<E>>
Overrides:
equals in class Object

getElementType

public Class<E> getElementType()
Returns the class of all the elements of the underlying EnumSetWriable. It may return null.

Returns:
the element class

hashCode

public int hashCode()
Specified by:
hashCode in interface Collection<E extends Enum<E>>
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class AbstractCollection<E extends Enum<E>>

getConf

public Configuration getConf()
Description copied from interface: Configurable
Return the configuration used by this object.

Specified by:
getConf in interface Configurable

setConf

public void setConf(Configuration conf)
Description copied from interface: Configurable
Set the configuration to be used by this object.

Specified by:
setConf in interface Configurable


Copyright © 2014 Apache Software Foundation. All Rights Reserved.