org.simantics.databoard.binding.mutable
Class Variant

java.lang.Object
  extended by org.simantics.databoard.binding.mutable.Variant
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable<Variant>
Direct Known Subclasses:
MutableVariant

public class Variant
extends java.lang.Object
implements java.lang.Comparable<Variant>, java.lang.Cloneable

Variant is a container to a data value of any type. This very class is immutable, the value and type cannot be changed, but the sub-class MutableVariant is not.

Variant is hash-equals-comparable, even variants of bindings (and types). The hash function and comparison rules are defined in the manual.

Author:
Toni Kalajainen
See Also:
is binding for Variant-class

Constructor Summary
Variant()
          Constract a variant with a default value of empty record {}
Variant(Binding binding, java.lang.Object value)
           
Variant(Variant v)
           
 
Method Summary
 Variant clone()
           
 int compareTo(Variant o)
           
 boolean equals(java.lang.Object obj)
           
 VariantAccessor getAccessor()
           
 Binding getBinding()
           
 java.lang.Object getValue()
           
 java.lang.Object getValue(Binding binding)
          Get and if necessary and possible, type-adapt the value.
 int hashCode()
           
static Variant ofInstance(java.lang.Object instance)
           
 java.lang.String toString()
           
 Datatype type()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Variant

public Variant()
Constract a variant with a default value of empty record {}


Variant

public Variant(Variant v)

Variant

public Variant(Binding binding,
               java.lang.Object value)
Method Detail

ofInstance

public static Variant ofInstance(java.lang.Object instance)

getValue

public java.lang.Object getValue()

getValue

public java.lang.Object getValue(Binding binding)
                          throws AdaptException
Get and if necessary and possible, type-adapt the value.

Parameters:
binding -
Returns:
the value in given binding
Throws:
AdaptException

getAccessor

public VariantAccessor getAccessor()

type

public Datatype type()

getBinding

public Binding getBinding()

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

compareTo

public int compareTo(Variant o)
Specified by:
compareTo in interface java.lang.Comparable<Variant>

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

clone

public Variant clone()
Overrides:
clone in class java.lang.Object