1 package org.simantics.interop.mapping.data;
\r
3 import java.util.ArrayList;
\r
4 import java.util.Collection;
\r
5 import java.util.HashSet;
\r
6 import java.util.Set;
\r
9 public class ObjectSetIdentifiable implements Identifiable {
\r
11 private Set<Object> objs;
\r
13 public ObjectSetIdentifiable(Object obj) {
\r
14 objs = new HashSet<Object>();
\r
18 public ObjectSetIdentifiable(Object... obj) {
\r
19 this.objs = new HashSet<Object>();
\r
20 for (Object r : obj)
\r
24 public ObjectSetIdentifiable(Collection<Object> obj) {
\r
25 this.objs = new HashSet<Object>();
\r
26 for (Object r : obj)
\r
30 public Set<Object> getObjects() {
\r
34 @SuppressWarnings("unchecked")
\r
36 public <T> T getAdapter(Class<T> clazz) {
\r
37 if (clazz.equals(String.class)) {
\r
39 for (Object o : objs)
\r
40 s += o.toString() + " ";
\r
47 public int hashCode() {
\r
48 return objs.hashCode();
\r
52 public boolean equals(Object arg0) {
\r
55 if (this.getClass() != arg0.getClass())
\r
57 ObjectSetIdentifiable other = (ObjectSetIdentifiable)arg0;
\r
58 return objs.equals(other.objs);
\r
62 public Identifiable merge(Identifiable other) {
\r
63 if (other instanceof ObjectIdentifiable) {
\r
64 Collection<Object> coll = new ArrayList<Object>();
\r
65 coll.addAll(this.objs);
\r
66 coll.add(((ObjectIdentifiable)other).getObject());
\r
67 ObjectSetIdentifiable i = new ObjectSetIdentifiable(coll);
\r
69 } else if (other instanceof ObjectSetIdentifiable) {
\r
70 Collection<Object> coll = new ArrayList<Object>();
\r
71 coll.addAll(this.objs);
\r
72 coll.addAll(((ObjectSetIdentifiable)other).getObjects());
\r
73 ObjectSetIdentifiable i = new ObjectSetIdentifiable(coll);
\r