org.simantics.databoard.binding.reflection
Class EnumClassBinding

java.lang.Object
  extended by org.simantics.databoard.binding.Binding
      extended by org.simantics.databoard.binding.UnionBinding
          extended by org.simantics.databoard.binding.reflection.EnumClassBinding
All Implemented Interfaces:
java.util.Comparator<java.lang.Object>

public class EnumClassBinding
extends UnionBinding

This class binds a java Enum-class with DataBoard's UnionType.

Author:
Toni Kalajainen

Nested Class Summary
 
Nested classes/interfaces inherited from class org.simantics.databoard.binding.Binding
Binding.Visitor<T>, Binding.Visitor1
 
Constructor Summary
EnumClassBinding(UnionType type, java.lang.Class<java.lang.Enum<?>> clazz)
           
 
Method Summary
 java.lang.Object create(int tag, java.lang.Object value)
           
 int getTag(java.lang.Object obj)
          Get tag number of an instance.
 java.lang.Object getValue(java.lang.Object obj)
           
 boolean isImmutable()
          Return true if the value is immutable.
 boolean isInstance(java.lang.Object obj)
           
 void setValue(java.lang.Object union, int tag, java.lang.Object value)
          Set value to an union.
 
Methods inherited from class org.simantics.databoard.binding.UnionBinding
accept, accept, assertInstaceIsValid, count, create, createDefault, createUnchecked, deepCompare, deepHashValue, getComponentBinding, getComponentBindings, readFrom, setComponentBindings, setTag, type
 
Methods inherited from class org.simantics.databoard.binding.Binding
assertInstaceIsValid, clone, cloneUnchecked, compare, createDefault, createDefaultUnchecked, createRandom, createRandomUnchecked, equals, hashValue, parseValue, parseValue, parseValueDefinition, printValue, printValueDefinition, serializer, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

EnumClassBinding

public EnumClassBinding(UnionType type,
                        java.lang.Class<java.lang.Enum<?>> clazz)
Method Detail

create

public java.lang.Object create(int tag,
                               java.lang.Object value)
Specified by:
create in class UnionBinding

setValue

public void setValue(java.lang.Object union,
                     int tag,
                     java.lang.Object value)
              throws BindingException
Description copied from class: UnionBinding
Set value to an union. Throws BindingException if value cannot be written.

Specified by:
setValue in class UnionBinding
Throws:
BindingException

getTag

public int getTag(java.lang.Object obj)
           throws BindingException
Description copied from class: UnionBinding
Get tag number of an instance.

Specified by:
getTag in class UnionBinding
Returns:
the tag number
Throws:
BindingException - is thrown if the instance is not a tag of this union

getValue

public java.lang.Object getValue(java.lang.Object obj)
Specified by:
getValue in class UnionBinding

isInstance

public boolean isInstance(java.lang.Object obj)
Specified by:
isInstance in class Binding

isImmutable

public boolean isImmutable()
Description copied from class: Binding
Return true if the value is immutable. This question excludes the immutability of the component types.

Overrides:
isImmutable in class Binding
Returns:
true value if immutable