1 /*******************************************************************************
2 * Copyright (c) 2007, 2011 Association for Decentralized Information Management in
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.databoard.example;
14 import org.simantics.databoard.Bindings;
15 import org.simantics.databoard.annotations.Referable;
16 import org.simantics.databoard.binding.Binding;
17 import org.simantics.databoard.binding.error.BindingConstructionException;
18 import org.simantics.databoard.binding.error.BindingException;
20 public class RecursiveDeepClone {
22 // Recursive classes and classes that are referenced should be annotated with
24 static @Referable class X {
28 public static void main(String[] args) throws BindingConstructionException, BindingException {
30 // Create recursive instance
32 original.reference = original;
34 Binding binding = Bindings.getBinding( original.getClass() );
35 X copy = (X) binding.cloneUnchecked( original );
38 System.out.println( "Original: "+binding.toString( original ) );
39 System.out.println( "Clone : "+binding.toString( copy ) );