org.simantics.databoard.binding.impl
Class FloatBindingDefault

java.lang.Object
  extended by org.simantics.databoard.binding.Binding
      extended by org.simantics.databoard.binding.NumberBinding
          extended by org.simantics.databoard.binding.FloatBinding
              extended by org.simantics.databoard.binding.impl.FloatBindingDefault
All Implemented Interfaces:
java.util.Comparator<java.lang.Object>

public class FloatBindingDefault
extends FloatBinding

Binds FloatType to java.lang.Float-class.

Author:
Toni Kalajainen

Nested Class Summary
 
Nested classes/interfaces inherited from class org.simantics.databoard.binding.Binding
Binding.Visitor<T>, Binding.Visitor1
 
Constructor Summary
FloatBindingDefault(FloatType type)
           
 
Method Summary
 int compare(java.lang.Object o1, java.lang.Object o2)
          Compares its two data values for order.
 java.lang.Object create(float value)
           
 java.lang.Object create(java.lang.Float value)
           
 java.lang.Object create(java.lang.Number value)
          Create value by converting it from any Number instance to a Number instance of this Binding type.
 java.lang.Object create(java.lang.String value)
          Creates a value from its string representation
 float getValue_(java.lang.Object o)
           
 java.lang.Float getValue(java.lang.Object o)
          Get numeric value of an object
 boolean isImmutable()
          Return true if the value is immutable.
 boolean isInstance(java.lang.Object obj)
           
 void setValue(java.lang.Object obj, float value)
           
 void setValue(java.lang.Object obj, java.lang.Number value)
           
 
Methods inherited from class org.simantics.databoard.binding.FloatBinding
accept, accept, createUnchecked, createUnchecked, deepCompare, deepHashValue, type
 
Methods inherited from class org.simantics.databoard.binding.NumberBinding
assertInstaceIsValid, createUnchecked, createUnchecked, getComponentBinding, getComponentBinding, getComponentCount, readFrom
 
Methods inherited from class org.simantics.databoard.binding.Binding
assertInstaceIsValid, clone, cloneUnchecked, createDefault, createDefaultUnchecked, createRandom, createRandom, createRandom, createRandomUnchecked, equals, hashValue, parseValue, parseValue, parseValueDefinition, printValue, printValueDefinition, readFromTry, readFromTryUnchecked, readFromUnchecked, serializer, toString, 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

FloatBindingDefault

public FloatBindingDefault(FloatType type)
Method Detail

create

public java.lang.Object create(java.lang.Float value)
Specified by:
create in class FloatBinding

create

public java.lang.Object create(float value)
Specified by:
create in class FloatBinding

create

public java.lang.Object create(java.lang.Number value)
Description copied from class: NumberBinding
Create value by converting it from any Number instance to a Number instance of this Binding type. NOTE WARNING! Using this method may lose precision or value in the conversion. E.g. Double to Integer, or Long to Byte

Specified by:
create in class FloatBinding
Returns:
the value in the format of the binding type

create

public java.lang.Object create(java.lang.String value)
Description copied from class: NumberBinding
Creates a value from its string representation

Specified by:
create in class FloatBinding
Returns:
number

isInstance

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

getValue

public java.lang.Float getValue(java.lang.Object o)
                         throws BindingException
Description copied from class: NumberBinding
Get numeric value of an object

Specified by:
getValue in class FloatBinding
Parameters:
o - object
Returns:
Number
Throws:
BindingException - thrown if obj is incorrect class

getValue_

public float getValue_(java.lang.Object o)
                throws BindingException
Specified by:
getValue_ in class FloatBinding
Throws:
BindingException

setValue

public void setValue(java.lang.Object obj,
                     java.lang.Number value)
              throws BindingException
Specified by:
setValue in class FloatBinding
Throws:
BindingException

setValue

public void setValue(java.lang.Object obj,
                     float value)
              throws BindingException
Specified by:
setValue in class FloatBinding
Throws:
BindingException

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

compare

public int compare(java.lang.Object o1,
                   java.lang.Object o2)
Description copied from class: Binding
Compares its two data values for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.

Finally, the implementor must ensure that compare(x, y)==0 implies that sgn(compare(x, z))==sgn(compare(y, z)) for all z.

The comparison function is defined at http://dev.simantics.org/index.php/Org.simantics.databoard_Manual#CompareTo_and_Equals

Note, comparing 2 different number types will not result a value comparison. Instead values have the following type precedence ByteType, IntegerType, LongType, FloatType, and the highest DoubleType.

Specified by:
compare in interface java.util.Comparator<java.lang.Object>
Overrides:
compare in class Binding
Parameters:
o1 - the first object to be compared.
o2 - the second object to be compared.
Returns:
a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.