1 package org.simantics.interop.mapping.data;
\r
4 import java.util.ArrayList;
\r
5 import java.util.Collection;
\r
6 import java.util.List;
\r
8 import org.simantics.db.Resource;
\r
10 public class ResourceSetSplitIdentifiable extends ResourceSetIdentifiable {
\r
12 private static int counter = 0;
\r
14 private int identifier;
\r
18 ResourceSetSplitIdentifiable(Resource resource, int index, int identifier) {
\r
21 this.identifier = identifier;
\r
24 public ResourceSetSplitIdentifiable(int index, int identifier, Resource primary, Resource... resource) {
\r
25 super(primary,resource);
\r
27 this.identifier = identifier;
\r
30 public ResourceSetSplitIdentifiable(Resource primary, Collection<Resource> resources,int index, int identifier) {
\r
31 super(primary,resources);
\r
33 this.identifier = identifier;
\r
36 public static List<Identifiable> createIdentifiables(ResourceSetIdentifiable identifiable, int count) {
\r
37 List<Identifiable> result = new ArrayList<Identifiable>(count);
\r
38 int identifier = counter++;
\r
39 for (int i = 0; i < count; i++) {
\r
40 result.add(new ResourceSetSplitIdentifiable(identifiable.getPrimary(),identifiable.getResources(), i, identifier));
\r
45 public static List<Identifiable> createIdentifiables(Identifiable identifiable, int count) {
\r
46 Resource res = identifiable.getAdapter(Resource.class);
\r
50 Resource resources[] = identifiable.getAdapter(Resource[].class);
\r
51 if (resources.length > 1) {
\r
52 List<Identifiable> result = new ArrayList<Identifiable>(count);
\r
53 int identifier = counter++;
\r
54 for (int i = 0; i < count; i++) {
\r
55 result.add(new ResourceSetSplitIdentifiable(i, identifier, res, resources));
\r
59 return ResourceSplitIdentifiable.createIdentifiables(identifiable, count);
\r
66 public boolean equals(Object arg0) {
\r
69 if (this.getClass() != arg0.getClass())
\r
71 ResourceSetSplitIdentifiable other = (ResourceSetSplitIdentifiable)arg0;
\r
72 if (identifier != other.identifier)
\r
74 if (index != other.index)
\r
76 return super.equals(arg0);
\r
80 public Identifiable merge(Identifiable other) {
\r
81 throw new RuntimeException("Cannot be merged");
\r