]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.structural2/src/org/simantics/structural2/variables/MutablePropertyVariable.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.structural2 / src / org / simantics / structural2 / variables / MutablePropertyVariable.java
index 90e66d2b1cee7bc7e9c7758f0773162784a47370..f69662ef999a89e69086a9ee8e9f44c193bbe886 100644 (file)
-package org.simantics.structural2.variables;\r
-\r
-import java.util.Collections;\r
-import java.util.Map;\r
-import java.util.Set;\r
-\r
-import org.simantics.databoard.binding.Binding;\r
-import org.simantics.databoard.type.Datatype;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.variable.AbstractPropertyVariable;\r
-import org.simantics.db.layer0.variable.Variable;\r
-import org.simantics.db.layer0.variable.Variables;\r
-import org.simantics.utils.ObjectUtils;\r
-\r
-/**\r
- * TODO: consider removing this, doesn't seem to be used\r
- */\r
-public class MutablePropertyVariable extends AbstractPropertyVariable {\r
-\r
-    final protected Variable parent;\r
-    final String name;\r
-\r
-    public Object value;\r
-    public Binding binding;\r
-    \r
-    public MutablePropertyVariable(Variable parent, String name) {\r
-        assert parent != null;\r
-        assert name != null;\r
-        this.parent = parent;\r
-        this.name = name;\r
-    }\r
-\r
-    @SuppressWarnings("unchecked")\r
-    @Override\r
-    public <T> T getValue(ReadGraph graph) throws DatabaseException {\r
-        return (T)value;\r
-    }\r
-\r
-    @SuppressWarnings("unchecked")\r
-    @Override\r
-    public <T> T getValue(ReadGraph graph, Binding binding)\r
-            throws DatabaseException {\r
-        return (T)value;\r
-    }\r
-\r
-    @Override\r
-    public void setValue(WriteGraph graph, Object value, Binding binding)\r
-            throws DatabaseException {\r
-        throw new DatabaseException("Value is constant.");\r
-    }\r
-\r
-    @Override\r
-    public String getName(ReadGraph graph) throws DatabaseException {\r
-        return name;\r
-    }\r
-\r
-    @Override\r
-    public Resource getType(ReadGraph graph) throws DatabaseException {\r
-        return null;\r
-    }\r
-\r
-    @Override\r
-    public Resource getPossibleType(ReadGraph graph) throws DatabaseException {\r
-        return null;\r
-    }\r
-\r
-    @Override\r
-    public Resource getType(ReadGraph graph, Resource baseType)throws DatabaseException {\r
-        return null;\r
-    }\r
-\r
-    @Override\r
-    public Resource getPossibleType(ReadGraph graph, Resource baseType) throws DatabaseException {\r
-       return null;\r
-    }\r
-\r
-//    @Override\r
-//    public Object getSerialized(ReadGraph graph) throws DatabaseException {\r
-//        return name;\r
-//    }\r
-\r
-    @Override\r
-    public Variable getParent(ReadGraph graph) throws DatabaseException {\r
-        return parent;\r
-    }\r
-\r
-    @Override\r
-    public Resource getRepresents(ReadGraph graph) throws DatabaseException {\r
-        return null;\r
-    }\r
-    \r
-    @Override\r
-    public Datatype getDatatype(ReadGraph graph) throws DatabaseException {\r
-        return binding != null ? binding.type() : null;\r
-    }\r
-    \r
-    @Override\r
-    public Resource getPropertyResource(ReadGraph graph) throws DatabaseException {\r
-       return null;\r
-    }\r
-\r
-    @Override\r
-    public Resource getContainerResource(ReadGraph graph) throws DatabaseException {\r
-       return null;\r
-    }\r
-    \r
-    @Override\r
-    public Variable getPredicate(ReadGraph graph) throws DatabaseException {\r
-       return null;\r
-    }\r
-    \r
-    @Override\r
-    protected Variable getPossibleDomainProperty(ReadGraph graph, String name)\r
-               throws DatabaseException {\r
-       return null;\r
-    }\r
-\r
-    @Override\r
-    public Map<String, Variable> collectDomainProperties(ReadGraph graph,\r
-               Map<String, Variable> properties) throws DatabaseException {\r
-       return properties;\r
-    }\r
-    \r
-    @Override\r
-    public Set<String> getClassifications(ReadGraph graph) throws DatabaseException {\r
-       Variable property = getPossibleDomainProperty(graph, Variables.CLASSIFICATIONS);\r
-       if(property != null) return property.getValue(graph);\r
-       else return Collections.emptySet();\r
-    }\r
-    \r
-    @Override\r
-    public int hashCode() {\r
-        final int prime = 31;\r
-        int result = 1;\r
-        result = prime * result + name.hashCode();\r
-        result = prime * result + parent.hashCode();\r
-        result = prime * result + ((value == null) ? 0 : value.hashCode());\r
-        result = prime * result + ((binding == null) ? 0 : binding.hashCode());\r
-        return result;\r
-    }\r
-\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (this == obj)\r
-            return true;\r
-        if (obj == null)\r
-            return false;\r
-        if (getClass() != obj.getClass())\r
-            return false;\r
-        MutablePropertyVariable other = (MutablePropertyVariable) obj;\r
-        if (!name.equals(other.name))\r
-            return false;\r
-        if (!parent.equals(other.parent))\r
-            return false;\r
-        if (!ObjectUtils.objectEquals(value, other.value))\r
-            return false;\r
-        return ObjectUtils.objectEquals(binding, other.binding);\r
-    }\r
-\r
-}\r
+package org.simantics.structural2.variables;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+
+import org.simantics.databoard.binding.Binding;
+import org.simantics.databoard.type.Datatype;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.variable.AbstractPropertyVariable;
+import org.simantics.db.layer0.variable.Variable;
+import org.simantics.db.layer0.variable.Variables;
+import org.simantics.utils.ObjectUtils;
+
+/**
+ * TODO: consider removing this, doesn't seem to be used
+ */
+public class MutablePropertyVariable extends AbstractPropertyVariable {
+
+    final protected Variable parent;
+    final String name;
+
+    public Object value;
+    public Binding binding;
+    
+    public MutablePropertyVariable(Variable parent, String name) {
+        assert parent != null;
+        assert name != null;
+        this.parent = parent;
+        this.name = name;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public <T> T getValue(ReadGraph graph) throws DatabaseException {
+        return (T)value;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public <T> T getValue(ReadGraph graph, Binding binding)
+            throws DatabaseException {
+        return (T)value;
+    }
+
+    @Override
+    public void setValue(WriteGraph graph, Object value, Binding binding)
+            throws DatabaseException {
+        throw new DatabaseException("Value is constant.");
+    }
+
+    @Override
+    public String getName(ReadGraph graph) throws DatabaseException {
+        return name;
+    }
+
+    @Override
+    public Resource getType(ReadGraph graph) throws DatabaseException {
+        return null;
+    }
+
+    @Override
+    public Resource getPossibleType(ReadGraph graph) throws DatabaseException {
+        return null;
+    }
+
+    @Override
+    public Resource getType(ReadGraph graph, Resource baseType)throws DatabaseException {
+        return null;
+    }
+
+    @Override
+    public Resource getPossibleType(ReadGraph graph, Resource baseType) throws DatabaseException {
+       return null;
+    }
+
+//    @Override
+//    public Object getSerialized(ReadGraph graph) throws DatabaseException {
+//        return name;
+//    }
+
+    @Override
+    public Variable getParent(ReadGraph graph) throws DatabaseException {
+        return parent;
+    }
+
+    @Override
+    public Resource getRepresents(ReadGraph graph) throws DatabaseException {
+        return null;
+    }
+    
+    @Override
+    public Datatype getDatatype(ReadGraph graph) throws DatabaseException {
+        return binding != null ? binding.type() : null;
+    }
+    
+    @Override
+    public Resource getPropertyResource(ReadGraph graph) throws DatabaseException {
+       return null;
+    }
+
+    @Override
+    public Resource getContainerResource(ReadGraph graph) throws DatabaseException {
+       return null;
+    }
+    
+    @Override
+    public Variable getPredicate(ReadGraph graph) throws DatabaseException {
+       return null;
+    }
+    
+    @Override
+    protected Variable getPossibleDomainProperty(ReadGraph graph, String name)
+               throws DatabaseException {
+       return null;
+    }
+
+    @Override
+    public Map<String, Variable> collectDomainProperties(ReadGraph graph,
+               Map<String, Variable> properties) throws DatabaseException {
+       return properties;
+    }
+    
+    @Override
+    public Set<String> getClassifications(ReadGraph graph) throws DatabaseException {
+       Variable property = getPossibleDomainProperty(graph, Variables.CLASSIFICATIONS);
+       if(property != null) return property.getValue(graph);
+       else return Collections.emptySet();
+    }
+    
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + name.hashCode();
+        result = prime * result + parent.hashCode();
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((binding == null) ? 0 : binding.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        MutablePropertyVariable other = (MutablePropertyVariable) obj;
+        if (!name.equals(other.name))
+            return false;
+        if (!parent.equals(other.parent))
+            return false;
+        if (!ObjectUtils.objectEquals(value, other.value))
+            return false;
+        return ObjectUtils.objectEquals(binding, other.binding);
+    }
+
+}