]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/TransferableGraphConfiguration2.java
Allow external customization fo TG Root type URIs.
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / util / TransferableGraphConfiguration2.java
index 94c6084f294417efaa8b6232c2625e78c014e951..2203ecaeb6bd792635aa1648495f20c3b5f03956 100644 (file)
@@ -24,8 +24,16 @@ public class TransferableGraphConfiguration2 {
                public final Resource resource;
                public final String name;
                public final boolean internal;
+               /**
+                * Optional, may be null.
+                */
+               public final String type;
 
                public RootSpec(Resource resource, String name, boolean internal) {
+                       this(resource, name, internal, null);
+               }
+
+               public RootSpec(Resource resource, String name, boolean internal, String type) {
                        if (resource == null)
                                throw new NullPointerException("null resource");
                        if (name == null)
@@ -33,11 +41,12 @@ public class TransferableGraphConfiguration2 {
                        this.resource = resource;
                        this.name = name;
                        this.internal = internal;
+                       this.type = type;
                }
 
                @Override
                public String toString() {
-                       return "RootSpec[" + name + ", " + resource + ", " + internal + "]"; 
+                       return "RootSpec[" + name + ", " + resource + ", " + internal + ", " + type + "]"; 
                }
 
                @Override
@@ -47,6 +56,7 @@ public class TransferableGraphConfiguration2 {
                        result = prime * result + (internal ? 1231 : 1237);
                        result = prime * result + resource.hashCode();
                        result = prime * result + name.hashCode();
+                       result = prime * result + (type != null ? type.hashCode() : 0);
                        return result;
                }
 
@@ -59,10 +69,18 @@ public class TransferableGraphConfiguration2 {
                        if (getClass() != obj.getClass())
                                return false;
                        RootSpec other = (RootSpec) obj;
-                       return internal == other.internal && resource.equals(other.resource) && name.equals(other.name);
+                       return internal == other.internal && resource.equals(other.resource) && name.equals(other.name)
+                                       && objectEquals(type, other.type);
+               }
+
+               private boolean objectEquals(Object o1, Object o2) {
+                       if (o1 == o2) return true;
+                       if (o1 == null && o2 == null) return true;
+                       if (o1 == null || o2 == null) return false;
+                       return o1.equals(o2);
                }
        }
-       
+
        final public TreeMap<String, Variant> baseExtensions = new TreeMap<String,Variant>();
        final public Resource indexRoot;
        final public Collection<RootSpec> roots;