]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/ResourceArrayProperty.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.browsing.ui.graph.impl / src / org / simantics / browsing / ui / graph / impl / ResourceArrayProperty.java
diff --git a/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/ResourceArrayProperty.java b/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/ResourceArrayProperty.java
new file mode 100644 (file)
index 0000000..7e8435e
--- /dev/null
@@ -0,0 +1,95 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.browsing.ui.graph.impl;\r
+\r
+import org.simantics.browsing.ui.common.property.IArrayProperty;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.ResourceArray;\r
+import org.simantics.utils.datastructures.slice.ValueRange;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class ResourceArrayProperty extends ResourceProperty implements IArrayProperty {\r
+\r
+    protected final ValueRange range;\r
+\r
+    public ResourceArrayProperty(Type type, ValueRange range, Resource subject, Resource predicate, Resource value,\r
+            ResourceArray path) {\r
+        super(type, subject, predicate, value, path);\r
+        if (range == null)\r
+            throw new IllegalArgumentException("null value range");\r
+        this.range = range;\r
+    }\r
+\r
+    @Override\r
+    public ValueRange getRange() {\r
+        return range;\r
+    }\r
+\r
+    @Override\r
+    public String toString() {\r
+        return super.toString() + "[range=" + range + "]";\r
+    }\r
+\r
+    @Override\r
+    public int propertyHashCode() {\r
+        return super.propertyHashCode() * 31 + range.hashCode();\r
+    }\r
+\r
+    @Override\r
+    public boolean propertyEquals(Object obj) {\r
+        if (this == obj)\r
+            return true;\r
+        if (!super.propertyEquals(obj))\r
+            return false;\r
+        ResourceArrayProperty other = (ResourceArrayProperty) obj;\r
+        return range.equals(other.range);\r
+    }\r
+\r
+    @Override\r
+    public int hashCode() {\r
+        return range.hashCode() + 31 * super.hashCode();\r
+    }\r
+\r
+    @Override\r
+    public boolean equals(Object obj) {\r
+        if (this == obj)\r
+            return true;\r
+        if (!super.equals(obj))\r
+            return false;\r
+        ResourceArrayProperty other = (ResourceArrayProperty) obj;\r
+        return range.equals(other.range);\r
+    }\r
+\r
+    @Override\r
+    public IArrayProperty slice(ValueRange range) {\r
+        return new SlicedResourceArrayProperty(type, range, subject, predicate, value, path);\r
+    }\r
+\r
+    @Override\r
+    public boolean isSlice() {\r
+        return false;\r
+    }\r
+\r
+    private static class SlicedResourceArrayProperty extends ResourceArrayProperty {\r
+        public SlicedResourceArrayProperty(Type type, ValueRange range, Resource subject, Resource predicate,\r
+                Resource value, ResourceArray path) {\r
+            super(type, range, subject, predicate, value, path);\r
+        }\r
+        @Override\r
+        public boolean isSlice() {\r
+            return true;\r
+        }\r
+    }\r
+\r
+}\r