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 java.util.ArrayList;
16 import org.simantics.databoard.Bindings;
17 import org.simantics.databoard.binding.Binding;
18 import org.simantics.databoard.binding.error.BindingException;
20 public class DeepCompare {
22 public static void main(String[] args) throws BindingException {
24 // Binding can compare any two instances. The compare function is deep.
25 Binding binding = Bindings.getBindingUnchecked( int[].class );
27 int[] array1 = new int[] { 1, 2, 3 };
28 int[] array2 = new int[] { 1, 2, 3 };
29 int[] array3 = new int[] { 2, 3, 4 };
31 if ( binding.compare(array1, array2) == 0 ) {
32 System.out.println( "array1 is equal to array2" );
34 System.out.println( "array1 is not equal to array2" );
37 if ( binding.compare(array1, array3) == 0 ) {
38 System.out.println( "array1 is equal to array3" );
40 System.out.println( "array1 is not equal to array3" );
47 // Two bindings can compare instances of same datatype, even if they are of
49 ArrayList<Integer> array4 = new ArrayList<Integer>();
50 Binding binding2 = Bindings.getBindingUnchecked( ArrayList.class, Integer.class );
55 if ( Bindings.compare(binding, array1, binding2, array4) == 0 ) {
56 System.out.println( "array1 is equal to array4" );
58 System.out.println( "array1 is not equal to array4" );