]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.layer0.utils/src/org/simantics/layer0/utils/binaryPredicates/InversePredicate.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.layer0.utils / src / org / simantics / layer0 / utils / binaryPredicates / InversePredicate.java
index c14456b8dffe71e646d89a0e9798b74a2e23ac1f..48f3b472cd340e505784226dacf6a9dc1564003a 100644 (file)
-/*******************************************************************************\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.layer0.utils.binaryPredicates;\r
-\r
-import java.util.Arrays;\r
-import java.util.Collection;\r
-\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.utils.datastructures.Pair;\r
-\r
-public class InversePredicate extends BinaryPredicate {\r
-\r
-       IBinaryPredicate base;\r
-       \r
-       public InversePredicate(IBinaryPredicate base) {\r
-               this.base = base;\r
-       }\r
-\r
-       @Override\r
-       public Collection<Resource> getObjects(ReadGraph g, Resource subject) throws DatabaseException {\r
-               return base.getSubjects(g, subject);\r
-       }\r
-\r
-       @SuppressWarnings("unchecked")\r
-    @Override\r
-       public Collection<Pair<Resource, Resource>> getStatements(ReadGraph g) throws DatabaseException {\r
-               Collection<Pair<Resource, Resource>> baseResult = base.getStatements(g);\r
-               Pair<Resource, Resource>[] result = new Pair[baseResult.size()];\r
-               int i=0;\r
-               for(Pair<Resource, Resource> p : baseResult)\r
-                       result[i++] = new Pair<Resource, Resource>(p.second, p.first);\r
-               return Arrays.asList(result);\r
-       }\r
-\r
-       @Override\r
-       public Collection<Resource> getSubjects(ReadGraph g, Resource object) throws DatabaseException {\r
-               return base.getObjects(g, object);\r
-       }\r
-\r
-       @Override\r
-       public boolean has(ReadGraph g, Resource subject, Resource object) {\r
-               return has(g, object, subject);\r
-       }\r
-\r
-       @Override\r
-       public boolean supportsGetObjects() {\r
-               return base.supportsGetSubjects();\r
-       }\r
-\r
-       @Override\r
-       public boolean supportsGetStatements() {\r
-               return base.supportsGetStatements();\r
-       }\r
-\r
-       @Override\r
-       public boolean supportsGetSubjects() {\r
-               return base.supportsGetObjects();\r
-       }\r
-\r
-       @Override\r
-       public void add(WriteGraph g, Resource subject, Resource object) throws DatabaseException {\r
-               base.add(g, object, subject);\r
-       }\r
-\r
-       @Override\r
-       public void remove(WriteGraph g, Resource subject, Resource object) throws DatabaseException {\r
-               base.remove(g, object, subject);\r
-       }\r
-\r
-       @Override\r
-       public boolean supportsAdditions() {\r
-               return base.supportsAdditions();\r
-       }\r
-\r
-       @Override\r
-       public boolean supportsRemovals() {\r
-               return base.supportsRemovals();\r
-       }\r
-\r
-       @Override\r
-       public int hashCode() {\r
-               final int prime = 31;\r
-               int result = 1;\r
-               result = prime * result + ((base == null) ? 0 : base.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
-               InversePredicate other = (InversePredicate) obj;\r
-               if (base == null) {\r
-                       if (other.base != null)\r
-                               return false;\r
-               } else if (!base.equals(other.base))\r
-                       return false;\r
-               return true;\r
-       }\r
-       \r
-       @Override\r
-       public IBinaryPredicate inverse(ReadGraph g) {\r
-               return base;\r
-       }\r
-       \r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.layer0.utils.binaryPredicates;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.simantics.db.Resource;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.utils.datastructures.Pair;
+
+public class InversePredicate extends BinaryPredicate {
+
+       IBinaryPredicate base;
+       
+       public InversePredicate(IBinaryPredicate base) {
+               this.base = base;
+       }
+
+       @Override
+       public Collection<Resource> getObjects(ReadGraph g, Resource subject) throws DatabaseException {
+               return base.getSubjects(g, subject);
+       }
+
+       @SuppressWarnings("unchecked")
+    @Override
+       public Collection<Pair<Resource, Resource>> getStatements(ReadGraph g) throws DatabaseException {
+               Collection<Pair<Resource, Resource>> baseResult = base.getStatements(g);
+               Pair<Resource, Resource>[] result = new Pair[baseResult.size()];
+               int i=0;
+               for(Pair<Resource, Resource> p : baseResult)
+                       result[i++] = new Pair<Resource, Resource>(p.second, p.first);
+               return Arrays.asList(result);
+       }
+
+       @Override
+       public Collection<Resource> getSubjects(ReadGraph g, Resource object) throws DatabaseException {
+               return base.getObjects(g, object);
+       }
+
+       @Override
+       public boolean has(ReadGraph g, Resource subject, Resource object) {
+               return has(g, object, subject);
+       }
+
+       @Override
+       public boolean supportsGetObjects() {
+               return base.supportsGetSubjects();
+       }
+
+       @Override
+       public boolean supportsGetStatements() {
+               return base.supportsGetStatements();
+       }
+
+       @Override
+       public boolean supportsGetSubjects() {
+               return base.supportsGetObjects();
+       }
+
+       @Override
+       public void add(WriteGraph g, Resource subject, Resource object) throws DatabaseException {
+               base.add(g, object, subject);
+       }
+
+       @Override
+       public void remove(WriteGraph g, Resource subject, Resource object) throws DatabaseException {
+               base.remove(g, object, subject);
+       }
+
+       @Override
+       public boolean supportsAdditions() {
+               return base.supportsAdditions();
+       }
+
+       @Override
+       public boolean supportsRemovals() {
+               return base.supportsRemovals();
+       }
+
+       @Override
+       public int hashCode() {
+               final int prime = 31;
+               int result = 1;
+               result = prime * result + ((base == null) ? 0 : base.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;
+               InversePredicate other = (InversePredicate) obj;
+               if (base == null) {
+                       if (other.base != null)
+                               return false;
+               } else if (!base.equals(other.base))
+                       return false;
+               return true;
+       }
+       
+       @Override
+       public IBinaryPredicate inverse(ReadGraph g) {
+               return base;
+       }
+       
+}