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.units;
14 import java.util.HashMap;
15 import java.util.HashSet;
19 import org.simantics.databoard.accessor.reference.ChildReference;
20 import org.simantics.databoard.binding.ArrayBinding;
21 import org.simantics.databoard.binding.Binding;
24 * This utility class contains a toolkit for synchronization of objects.
26 * @author toni.kalajainen
28 public class SynchronizationUtil {
36 * @param idRef reference identifier in item
37 * @return Compare raport
39 public <T> CompareRaport<T> compareArrays(ArrayBinding arrayBinding, T oldArray, T newArray, ChildReference idRef)
41 Binding cb = arrayBinding.componentBinding;
43 CompareRaport<T> result = new CompareRaport<T>();
45 //Set<T> oldIds = new HashSet<T>( )
50 // public <T> CompareRaport<T> compareMaps(MapBinding mapBinding, T oldMap, T newMap, ChildReference idRef)
55 static class CompareRaport<T> {
57 public Set<T> addedItems = new HashSet<T>();
58 public Set<T> removedItems = new HashSet<T>();
59 public Map<T, T> correspondences = new HashMap<T, T>();
61 public T[] addedIndices;
62 public T[] removedIndices;
63 public Map<Integer, Integer> indiceCorrespondence;