1 package org.simantics.interop.mapping.data;
\r
3 import java.util.ArrayList;
\r
4 import java.util.Collection;
\r
7 public class ObjectIdentifiable implements Identifiable {
\r
11 public ObjectIdentifiable(Object obj) {
\r
15 public Object getObject() {
\r
19 @SuppressWarnings("unchecked")
\r
21 public <T> T getAdapter(Class<T> clazz) {
\r
22 if (clazz == String.class)
\r
23 return (T)obj.toString();
\r
28 public int hashCode() {
\r
29 return obj.hashCode();
\r
33 public boolean equals(Object arg0) {
\r
36 if (this.getClass() != arg0.getClass())
\r
38 ObjectIdentifiable other = (ObjectIdentifiable)arg0;
\r
39 return obj.equals(other.obj);
\r
43 public Identifiable merge(Identifiable other) {
\r
44 if (other instanceof ObjectIdentifiable) {
\r
45 ObjectSetIdentifiable i = new ObjectSetIdentifiable(this.obj,((ObjectIdentifiable)other).obj);
\r
47 } else if (other instanceof ObjectSetIdentifiable) {
\r
48 Collection<Object> coll = new ArrayList<Object>();
\r
50 coll.addAll(((ObjectSetIdentifiable)other).getObjects());
\r
51 ObjectSetIdentifiable i = new ObjectSetIdentifiable(coll);
\r