]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.mapping/src/org/simantics/mapping/constraint/BinaryPredicateConstraint.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.mapping / src / org / simantics / mapping / constraint / BinaryPredicateConstraint.java
index 1e4f1defe44e2af3e7a542683f9062c93a35f5a8..f979698f78a2bc6ac42c6fcc5a1d35ab0d00cc00 100644 (file)
@@ -1,80 +1,80 @@
-/*******************************************************************************\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.mapping.constraint;\r
-\r
-import gnu.trove.map.hash.TObjectIntHashMap;\r
-\r
-import org.simantics.db.Resource;\r
-import org.simantics.layer0.utils.binaryPredicates.IBinaryPredicate;\r
-import org.simantics.mapping.constraint.instructions.BinaryPredicateInstruction;\r
-import org.simantics.mapping.constraint.instructions.BinaryPredicateObjectQuery;\r
-import org.simantics.mapping.constraint.instructions.BinaryPredicateSubjectQuery;\r
-import org.simantics.mapping.constraint.instructions.IInstruction;\r
-import org.simantics.utils.datastructures.persistent.ImmutableSet;\r
-\r
-public class BinaryPredicateConstraint implements IConstraint {\r
-\r
-       Resource variable0;\r
-       Resource variable1;\r
-       IBinaryPredicate predicate;             \r
-\r
-       public BinaryPredicateConstraint(IBinaryPredicate predicate,\r
-                       Resource variable0, Resource variable1) {\r
-               this.predicate = predicate;\r
-               this.variable0 = variable0;\r
-               this.variable1 = variable1;\r
-       }\r
-\r
-       @Override\r
-       public ImmutableSet<Resource> binds() {\r
-               return ImmutableSet.of(variable0, variable1);\r
-       }\r
-\r
-       @Override\r
-       public IInstruction createInstruction(\r
-                       TObjectIntHashMap<Resource> variableIds,\r
-                       ImmutableSet<Resource> bound) throws TooManyUnboundVariablesException {\r
-               int id0 = variableIds.get(variable0);\r
-               int id1 = variableIds.get(variable1);\r
-               if(bound.contains(variable0)) {\r
-                       if(bound.contains(variable1))\r
-                               return new BinaryPredicateInstruction(id0, id1, predicate);\r
-                       else\r
-                               return new BinaryPredicateObjectQuery(id0, id1, predicate);\r
-               }\r
-               else {\r
-                       if(bound.contains(variable1))\r
-                               return new BinaryPredicateSubjectQuery(id0, id1, predicate);\r
-                       else\r
-                               throw new TooManyUnboundVariablesException();                   \r
-               }\r
-       }\r
-\r
-       @Override\r
-       public int isApplicable(ImmutableSet<Resource> bound) {\r
-               if(bound.contains(variable0)) {\r
-                       if(bound.contains(variable1))\r
-                               return Integer.MAX_VALUE;\r
-                       else if(predicate.supportsGetObjects())\r
-                               return Integer.MAX_VALUE;\r
-                       else\r
-                               return 0;\r
-               }\r
-               else {\r
-                       if(bound.contains(variable1) && predicate.supportsGetSubjects())\r
-                               return Integer.MAX_VALUE;\r
-                       else \r
-                               return 0;\r
-               }\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.mapping.constraint;
+
+import gnu.trove.map.hash.TObjectIntHashMap;
+
+import org.simantics.db.Resource;
+import org.simantics.layer0.utils.binaryPredicates.IBinaryPredicate;
+import org.simantics.mapping.constraint.instructions.BinaryPredicateInstruction;
+import org.simantics.mapping.constraint.instructions.BinaryPredicateObjectQuery;
+import org.simantics.mapping.constraint.instructions.BinaryPredicateSubjectQuery;
+import org.simantics.mapping.constraint.instructions.IInstruction;
+import org.simantics.utils.datastructures.persistent.ImmutableSet;
+
+public class BinaryPredicateConstraint implements IConstraint {
+
+       Resource variable0;
+       Resource variable1;
+       IBinaryPredicate predicate;             
+
+       public BinaryPredicateConstraint(IBinaryPredicate predicate,
+                       Resource variable0, Resource variable1) {
+               this.predicate = predicate;
+               this.variable0 = variable0;
+               this.variable1 = variable1;
+       }
+
+       @Override
+       public ImmutableSet<Resource> binds() {
+               return ImmutableSet.of(variable0, variable1);
+       }
+
+       @Override
+       public IInstruction createInstruction(
+                       TObjectIntHashMap<Resource> variableIds,
+                       ImmutableSet<Resource> bound) throws TooManyUnboundVariablesException {
+               int id0 = variableIds.get(variable0);
+               int id1 = variableIds.get(variable1);
+               if(bound.contains(variable0)) {
+                       if(bound.contains(variable1))
+                               return new BinaryPredicateInstruction(id0, id1, predicate);
+                       else
+                               return new BinaryPredicateObjectQuery(id0, id1, predicate);
+               }
+               else {
+                       if(bound.contains(variable1))
+                               return new BinaryPredicateSubjectQuery(id0, id1, predicate);
+                       else
+                               throw new TooManyUnboundVariablesException();                   
+               }
+       }
+
+       @Override
+       public int isApplicable(ImmutableSet<Resource> bound) {
+               if(bound.contains(variable0)) {
+                       if(bound.contains(variable1))
+                               return Integer.MAX_VALUE;
+                       else if(predicate.supportsGetObjects())
+                               return Integer.MAX_VALUE;
+                       else
+                               return 0;
+               }
+               else {
+                       if(bound.contains(variable1) && predicate.supportsGetSubjects())
+                               return Integer.MAX_VALUE;
+                       else 
+                               return 0;
+               }
+       }
+
+}