]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/src/org/simantics/databoard/units/SynchronizationUtil.java
Improved Bindings.getBinding(Class) caching for Datatype.class
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / units / SynchronizationUtil.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2011 Association for Decentralized Information Management in
3  * Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.databoard.units;
13
14 import java.util.HashMap;
15 import java.util.HashSet;
16 import java.util.Map;
17 import java.util.Set;
18
19 import org.simantics.databoard.accessor.reference.ChildReference;
20 import org.simantics.databoard.binding.ArrayBinding;
21 import org.simantics.databoard.binding.Binding;
22
23 /**
24  * This utility class contains a toolkit for synchronization of objects.
25  * 
26  * @author toni.kalajainen
27  */
28 public class SynchronizationUtil {
29
30         /**
31          * Compare arrays
32          * 
33          * @param arrayBinding 
34          * @param oldArray
35          * @param newArray
36          * @param idRef reference identifier in item
37          * @return Compare raport
38          */
39         public <T> CompareRaport<T> compareArrays(ArrayBinding arrayBinding, T oldArray, T newArray, ChildReference idRef)
40         {
41                 Binding cb = arrayBinding.componentBinding;
42                 
43                 CompareRaport<T> result = new CompareRaport<T>();
44                 
45                 //Set<T> oldIds = new HashSet<T>(  )
46                 
47                 return result;
48         }
49         
50 //      public <T> CompareRaport<T> compareMaps(MapBinding mapBinding, T oldMap, T newMap, ChildReference idRef)
51 //      {
52 //              
53 //      }
54         
55         static class CompareRaport<T> {
56                 
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>();
60                 
61                 public T[] addedIndices;
62                 public T[] removedIndices;
63                 public Map<Integer, Integer> indiceCorrespondence;
64                 
65         }
66         
67 }