Databoard Tutorials
This document contains a some Java coding snippets for Databoard.
- Object Deep-Copy
The binding class can be used for cloning objects. The copies are <syntaxHighlight lang="java"> // Binding can copy objects. All copies are deep. // Mutable objects are duplicated, immutable are referenced.
// For instance, in object array, the array is copied, but its // immutable literal instances (e.g. 1) is referenced.
Object[] original = new Object[] { new Object(), 1, "X", 123.456 }; Binding binding = Bindings.getBinding( original.getClass() ); Object[] copy = (Object[]) binding.cloneUnchecked( original );
// Print the objects System.out.println( "Original: "+binding.toString( original ) ); System.out.println( "Clone : "+binding.toString( copy ) ); </syntaxHighlight>
- Object Deep-Compare