]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/src/org/simantics/databoard/units/SynchronizationUtil.java
Merge commit 'ffdf837'
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / units / SynchronizationUtil.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
3  * Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.databoard.units;\r
13 \r
14 import java.util.HashMap;\r
15 import java.util.HashSet;\r
16 import java.util.Map;\r
17 import java.util.Set;\r
18 \r
19 import org.simantics.databoard.accessor.reference.ChildReference;\r
20 import org.simantics.databoard.binding.ArrayBinding;\r
21 import org.simantics.databoard.binding.Binding;\r
22 \r
23 /**\r
24  * This utility class contains a toolkit for synchronization of objects.\r
25  * \r
26  * @author toni.kalajainen\r
27  */\r
28 public class SynchronizationUtil {\r
29 \r
30         /**\r
31          * Compare arrays\r
32          * \r
33          * @param arrayBinding \r
34          * @param oldArray\r
35          * @param newArray\r
36          * @param idRef reference identifier in item\r
37          * @return Compare raport\r
38          */\r
39         public <T> CompareRaport<T> compareArrays(ArrayBinding arrayBinding, T oldArray, T newArray, ChildReference idRef)\r
40         {\r
41                 Binding cb = arrayBinding.componentBinding;\r
42                 \r
43                 CompareRaport<T> result = new CompareRaport<T>();\r
44                 \r
45                 //Set<T> oldIds = new HashSet<T>(  )\r
46                 \r
47                 return result;\r
48         }\r
49         \r
50 //      public <T> CompareRaport<T> compareMaps(MapBinding mapBinding, T oldMap, T newMap, ChildReference idRef)\r
51 //      {\r
52 //              \r
53 //      }\r
54         \r
55         static class CompareRaport<T> {\r
56                 \r
57                 public Set<T> addedItems = new HashSet<T>();\r
58                 public Set<T> removedItems = new HashSet<T>();\r
59                 public Map<T, T> correspondences = new HashMap<T, T>();\r
60                 \r
61                 public T[] addedIndices;\r
62                 public T[] removedIndices;\r
63                 public Map<Integer, Integer> indiceCorrespondence;\r
64                 \r
65         }\r
66         \r
67 }\r