-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.databoard.example;\r
-\r
-import java.util.ArrayList;\r
-\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.databoard.binding.Binding;\r
-import org.simantics.databoard.binding.error.BindingException;\r
-\r
-public class DeepCompare {\r
-\r
- public static void main(String[] args) throws BindingException {\r
- \r
- // Binding can compare any two instances. The compare function is deep. \r
- Binding binding = Bindings.getBindingUnchecked( int[].class );\r
- \r
- int[] array1 = new int[] { 1, 2, 3 };\r
- int[] array2 = new int[] { 1, 2, 3 };\r
- int[] array3 = new int[] { 2, 3, 4 };\r
- \r
- if ( binding.compare(array1, array2) == 0 ) {\r
- System.out.println( "array1 is equal to array2" );\r
- } else {\r
- System.out.println( "array1 is not equal to array2" );\r
- }\r
- \r
- if ( binding.compare(array1, array3) == 0 ) {\r
- System.out.println( "array1 is equal to array3" );\r
- } else {\r
- System.out.println( "array1 is not equal to array3" );\r
- }\r
- \r
- \r
- \r
- \r
- \r
- // Two bindings can compare instances of same datatype, even if they are of\r
- // different classes \r
- ArrayList<Integer> array4 = new ArrayList<Integer>();\r
- Binding binding2 = Bindings.getBindingUnchecked( ArrayList.class, Integer.class );\r
- array4.add( 1 );\r
- array4.add( 2 );\r
- array4.add( 3 );\r
- \r
- if ( Bindings.compare(binding, array1, binding2, array4) == 0 ) {\r
- System.out.println( "array1 is equal to array4" );\r
- } else {\r
- System.out.println( "array1 is not equal to array4" );\r
- }\r
- \r
- }\r
- \r
-}\r
+/*******************************************************************************
+ * 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 java.util.ArrayList;
+
+import org.simantics.databoard.Bindings;
+import org.simantics.databoard.binding.Binding;
+import org.simantics.databoard.binding.error.BindingException;
+
+public class DeepCompare {
+
+ public static void main(String[] args) throws BindingException {
+
+ // Binding can compare any two instances. The compare function is deep.
+ Binding binding = Bindings.getBindingUnchecked( int[].class );
+
+ int[] array1 = new int[] { 1, 2, 3 };
+ int[] array2 = new int[] { 1, 2, 3 };
+ int[] array3 = new int[] { 2, 3, 4 };
+
+ if ( binding.compare(array1, array2) == 0 ) {
+ System.out.println( "array1 is equal to array2" );
+ } else {
+ System.out.println( "array1 is not equal to array2" );
+ }
+
+ if ( binding.compare(array1, array3) == 0 ) {
+ System.out.println( "array1 is equal to array3" );
+ } else {
+ System.out.println( "array1 is not equal to array3" );
+ }
+
+
+
+
+
+ // Two bindings can compare instances of same datatype, even if they are of
+ // different classes
+ ArrayList<Integer> array4 = new ArrayList<Integer>();
+ Binding binding2 = Bindings.getBindingUnchecked( ArrayList.class, Integer.class );
+ array4.add( 1 );
+ array4.add( 2 );
+ array4.add( 3 );
+
+ if ( Bindings.compare(binding, array1, binding2, array4) == 0 ) {
+ System.out.println( "array1 is equal to array4" );
+ } else {
+ System.out.println( "array1 is not equal to array4" );
+ }
+
+ }
+
+}