org.simantics.databoard.reflection
Class ReflectionRecordBinding

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

public class ReflectionRecordBinding
extends RecordBinding

ReflectionRecordBinding binding of a Record Type and Java Class. If binds Record Values to Java Objects.

There are three types of classes supported: 1) record-like class - All fields are public - No-argument public constructor 2) immutable-like class - All fields are set in constructor 3) bean-like class - All fields are set with getter/setter


Nested Class Summary
 
Nested classes/interfaces inherited from class org.simantics.databoard.binding.Binding
Binding.Visitor<T>, Binding.Visitor1
 
Field Summary
 
Fields inherited from class org.simantics.databoard.binding.RecordBinding
componentBindings
 
Constructor Summary
ReflectionRecordBinding(java.lang.Class<?> clazz, RecordType type)
          Create a Reflection Record Bindings.
 
Method Summary
 java.lang.Object create(java.lang.Object... values)
          Create a record using values.
 java.lang.Object createPartial()
          Creates partial and most likely invalid instance.
 java.lang.Object getComponent(java.lang.Object obj, int index)
           
 java.lang.Class<?> getComponentClass(int index)
           
 boolean isImmutable()
          Return true if the value is immutable.
 boolean isInstance(java.lang.Object obj)
           
 void postConstruction(ReflectionBinding reflectionScheme, java.util.Map<org.simantics.databoard.reflection.ClassBinding,Binding> map)
          2nd Step of the construction.
 void setComponent(java.lang.Object obj, int index, java.lang.Object value)
           
 void setComponents(java.lang.Object obj, java.lang.Object... value)
           
 
Methods inherited from class org.simantics.databoard.binding.RecordBinding
accept, accept, assertInstaceIsValid, count, createUnchecked, deepCompare, deepHashValue, getComponentBinding, getComponentBinding, getComponentBindings, setComponentsUnchecked, setComponentUnchecked, 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, serializer, serializerUnchecked
 
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

ReflectionRecordBinding

public ReflectionRecordBinding(java.lang.Class<?> clazz,
                               RecordType type)
                        throws BindingConstructionException
Create a Reflection Record Bindings. There is a 2-phase construction.

Parameters:
clazz -
type -
Throws:
BindingConstructionException
Method Detail

postConstruction

public void postConstruction(ReflectionBinding reflectionScheme,
                             java.util.Map<org.simantics.databoard.reflection.ClassBinding,Binding> map)
                      throws BindingConstructionException
2nd Step of the construction. This step creates a binding for each field.

Parameters:
reflectionScheme -
map -
Throws:
BindingConstructionException

createPartial

public java.lang.Object createPartial()
                               throws BindingException
Description copied from class: RecordBinding
Creates partial and most likely invalid instance. This is used in two-phase construction of recursive instances.

Specified by:
createPartial in class RecordBinding
Returns:
instance.
Throws:
BindingException

create

public java.lang.Object create(java.lang.Object... values)
                        throws BindingException
Description copied from class: RecordBinding
Create a record using values. Note! values may be consumed (used in the result)

Specified by:
create in class RecordBinding
Returns:
new record
Throws:
BindingException

getComponent

public java.lang.Object getComponent(java.lang.Object obj,
                                     int index)
                              throws BindingException
Specified by:
getComponent in class RecordBinding
Throws:
BindingException

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

getComponentClass

public java.lang.Class<?> getComponentClass(int index)

setComponent

public void setComponent(java.lang.Object obj,
                         int index,
                         java.lang.Object value)
                  throws BindingException
Specified by:
setComponent in class RecordBinding
Throws:
BindingException

setComponents

public void setComponents(java.lang.Object obj,
                          java.lang.Object... value)
                   throws BindingException
Specified by:
setComponents in class RecordBinding
Throws:
BindingException