1 package org.simantics.interop.mapping.data;
\r
4 import java.util.ArrayList;
\r
5 import java.util.List;
\r
7 import org.simantics.db.Resource;
\r
9 public class ResourceSplitIdentifiable extends ResourceIdentifiable {
\r
11 private static int counter = 0;
\r
13 //private Resource resource;
\r
14 private int identifier;
\r
18 ResourceSplitIdentifiable(Resource resource, int index, int identifier) {
\r
21 this.identifier = identifier;
\r
24 public static List<Identifiable> createIdentifiables(ResourceIdentifiable identifiable, int count) {
\r
25 List<Identifiable> result = new ArrayList<Identifiable>(count);
\r
26 int identifier = counter++;
\r
27 for (int i = 0; i < count; i++) {
\r
28 result.add(new ResourceSplitIdentifiable(identifiable.getResource(), i, identifier));
\r
33 public static List<Identifiable> createIdentifiables(Identifiable identifiable, int count) {
\r
34 Resource res = identifiable.getAdapter(Resource.class);
\r
38 Resource resources[] = identifiable.getAdapter(Resource[].class);
\r
40 if (resources.length > 1) {
\r
41 return ResourceSetSplitIdentifiable.createIdentifiables(identifiable, count);
\r
43 List<Identifiable> result = new ArrayList<Identifiable>(count);
\r
44 int identifier = counter++;
\r
45 for (int i = 0; i < count; i++) {
\r
46 result.add(new ResourceSplitIdentifiable(res, i, identifier));
\r
54 public boolean equals(Object arg0) {
\r
57 if (this.getClass() != arg0.getClass())
\r
59 ResourceSplitIdentifiable other = (ResourceSplitIdentifiable)arg0;
\r
60 if (identifier != other.identifier)
\r
62 if (index != other.index)
\r
64 return resource.equals(other.resource);
\r
68 public Identifiable merge(Identifiable other) {
\r
69 throw new RuntimeException("Cannot be merged");
\r