]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.layer0.utils/src/org/simantics/layer0/utils/binaryPredicates/OrderedSetElementsPredicate.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.layer0.utils / src / org / simantics / layer0 / utils / binaryPredicates / OrderedSetElementsPredicate.java
index 2a094ed00f1a0a463ce5c5857b3de71fbaaa5813..c6a3fd94dd1b4bffda6996ebe2214930216c1bef 100644 (file)
@@ -1,99 +1,99 @@
-/*******************************************************************************\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.ArrayList;\r
-import java.util.Collection;\r
-import java.util.Collections;\r
-\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.Statement;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.utils.OrderedSetUtils;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.layer0.Layer0;\r
-import org.simantics.utils.datastructures.Pair;\r
-\r
-public class OrderedSetElementsPredicate extends BinaryPredicate {\r
-\r
-       public static final OrderedSetElementsPredicate INSTANCE = \r
-               new OrderedSetElementsPredicate(); \r
-       \r
-       @Override\r
-       public Collection<Resource> getObjects(ReadGraph g, Resource subject) throws DatabaseException {\r
-               Layer0 l0 = Layer0.getInstance(g);\r
-               if(g.isInstanceOf(subject, l0.OrderedSet))\r
-                       return OrderedSetUtils.toList(g, subject);\r
-               else\r
-                       return Collections.emptyList();\r
-       }\r
-\r
-       @Override\r
-       public Collection<Pair<Resource, Resource>> getStatements(ReadGraph g) {\r
-               throw new UnsupportedOperationException();\r
-       }\r
-\r
-       @Override\r
-       public Collection<Resource> getSubjects(ReadGraph g, Resource object) throws DatabaseException {\r
-               Collection<Resource> result = new ArrayList<Resource>(1);\r
-               Layer0 l0 = Layer0.getInstance(g);\r
-               for(Statement stat : g.getStatements(object, l0.IsWeaklyRelatedTo)) {\r
-                       Resource pred = stat.getPredicate();\r
-                       if(g.isInstanceOf(pred, l0.OrderedSet) && !pred.equals(object))\r
-                               result.add(pred);\r
-               }\r
-               return result;\r
-       }\r
-\r
-       @Override\r
-       public boolean has(ReadGraph g, Resource subject, Resource object) throws DatabaseException {\r
-               return OrderedSetUtils.contains(g, subject, object) &&\r
-                       g.isInstanceOf(subject, Layer0.getInstance(g).OrderedSet);\r
-       }\r
-\r
-       @Override\r
-       public boolean supportsGetObjects() {\r
-               return true;\r
-       }\r
-\r
-       @Override\r
-       public boolean supportsGetStatements() {                \r
-               return false;\r
-       }\r
-\r
-       @Override\r
-       public boolean supportsGetSubjects() {\r
-               return true;\r
-       }\r
-\r
-       @Override\r
-       public void add(WriteGraph g, Resource subject, Resource object) throws DatabaseException {\r
-               OrderedSetUtils.add(g, subject, object);\r
-       }\r
-\r
-       @Override\r
-       public void remove(WriteGraph g, Resource subject, Resource object) throws DatabaseException {\r
-               OrderedSetUtils.remove(g, subject, object);\r
-       }\r
-\r
-       @Override\r
-       public boolean supportsAdditions() {\r
-               return true;\r
-       }\r
-\r
-       @Override\r
-       public boolean supportsRemovals() {\r
-               return true;\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.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.Statement;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.common.utils.OrderedSetUtils;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.layer0.Layer0;
+import org.simantics.utils.datastructures.Pair;
+
+public class OrderedSetElementsPredicate extends BinaryPredicate {
+
+       public static final OrderedSetElementsPredicate INSTANCE = 
+               new OrderedSetElementsPredicate(); 
+       
+       @Override
+       public Collection<Resource> getObjects(ReadGraph g, Resource subject) throws DatabaseException {
+               Layer0 l0 = Layer0.getInstance(g);
+               if(g.isInstanceOf(subject, l0.OrderedSet))
+                       return OrderedSetUtils.toList(g, subject);
+               else
+                       return Collections.emptyList();
+       }
+
+       @Override
+       public Collection<Pair<Resource, Resource>> getStatements(ReadGraph g) {
+               throw new UnsupportedOperationException();
+       }
+
+       @Override
+       public Collection<Resource> getSubjects(ReadGraph g, Resource object) throws DatabaseException {
+               Collection<Resource> result = new ArrayList<Resource>(1);
+               Layer0 l0 = Layer0.getInstance(g);
+               for(Statement stat : g.getStatements(object, l0.IsWeaklyRelatedTo)) {
+                       Resource pred = stat.getPredicate();
+                       if(g.isInstanceOf(pred, l0.OrderedSet) && !pred.equals(object))
+                               result.add(pred);
+               }
+               return result;
+       }
+
+       @Override
+       public boolean has(ReadGraph g, Resource subject, Resource object) throws DatabaseException {
+               return OrderedSetUtils.contains(g, subject, object) &&
+                       g.isInstanceOf(subject, Layer0.getInstance(g).OrderedSet);
+       }
+
+       @Override
+       public boolean supportsGetObjects() {
+               return true;
+       }
+
+       @Override
+       public boolean supportsGetStatements() {                
+               return false;
+       }
+
+       @Override
+       public boolean supportsGetSubjects() {
+               return true;
+       }
+
+       @Override
+       public void add(WriteGraph g, Resource subject, Resource object) throws DatabaseException {
+               OrderedSetUtils.add(g, subject, object);
+       }
+
+       @Override
+       public void remove(WriteGraph g, Resource subject, Resource object) throws DatabaseException {
+               OrderedSetUtils.remove(g, subject, object);
+       }
+
+       @Override
+       public boolean supportsAdditions() {
+               return true;
+       }
+
+       @Override
+       public boolean supportsRemovals() {
+               return true;
+       }
+       
+}