X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.databoard%2Fexamples%2Forg%2Fsimantics%2Fdataboard%2Fexample%2FRecursiveDeepClone.java;h=fa38bfb3cd24273eca1cd9a9ed19e01b2137da9d;hp=86d718319982efc888a4aad18ba6cb01f07e83f4;hb=refs%2Fchanges%2F38%2F238%2F2;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.databoard/examples/org/simantics/databoard/example/RecursiveDeepClone.java b/bundles/org.simantics.databoard/examples/org/simantics/databoard/example/RecursiveDeepClone.java index 86d718319..fa38bfb3c 100644 --- a/bundles/org.simantics.databoard/examples/org/simantics/databoard/example/RecursiveDeepClone.java +++ b/bundles/org.simantics.databoard/examples/org/simantics/databoard/example/RecursiveDeepClone.java @@ -1,42 +1,42 @@ -/******************************************************************************* - * Copyright (c) 2007, 2011 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.databoard.example; - -import org.simantics.databoard.Bindings; -import org.simantics.databoard.annotations.Referable; -import org.simantics.databoard.binding.Binding; -import org.simantics.databoard.binding.error.BindingConstructionException; -import org.simantics.databoard.binding.error.BindingException; - -public class RecursiveDeepClone { - - // Recursive classes and classes that are referenced should be annotated with - // @Referable - static @Referable class X { - public X reference; - } - - public static void main(String[] args) throws BindingConstructionException, BindingException { - - // Create recursive instance - X original = new X(); - original.reference = original; - - Binding binding = Bindings.getBinding( original.getClass() ); - X copy = (X) binding.cloneUnchecked( original ); - - // Print the objects - System.out.println( "Original: "+binding.toString( original ) ); - System.out.println( "Clone : "+binding.toString( copy ) ); - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2011 Association for Decentralized Information Management in + * Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.databoard.example; + +import org.simantics.databoard.Bindings; +import org.simantics.databoard.annotations.Referable; +import org.simantics.databoard.binding.Binding; +import org.simantics.databoard.binding.error.BindingConstructionException; +import org.simantics.databoard.binding.error.BindingException; + +public class RecursiveDeepClone { + + // Recursive classes and classes that are referenced should be annotated with + // @Referable + static @Referable class X { + public X reference; + } + + public static void main(String[] args) throws BindingConstructionException, BindingException { + + // Create recursive instance + X original = new X(); + original.reference = original; + + Binding binding = Bindings.getBinding( original.getClass() ); + X copy = (X) binding.cloneUnchecked( original ); + + // Print the objects + System.out.println( "Original: "+binding.toString( original ) ); + System.out.println( "Clone : "+binding.toString( copy ) ); + } + +}