]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.common/src/org/simantics/db/common/procedure/single/wrapper/SingleFunctionalOrNullProcedure.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.db.common / src / org / simantics / db / common / procedure / single / wrapper / SingleFunctionalOrNullProcedure.java
index e593dafb36d8380cae7e1a464b6c3c1ec4a1e3ef..3cff02ead2b3ff73e050e801b7e230147905a07c 100644 (file)
@@ -1,76 +1,76 @@
-/*******************************************************************************\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.db.common.procedure.single.wrapper;\r
-\r
-import java.util.concurrent.atomic.AtomicBoolean;\r
-\r
-import org.simantics.db.AsyncReadGraph;\r
-import org.simantics.db.common.procedure.adapter.AsyncMultiProcedureAdapter;\r
-import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;\r
-import org.simantics.db.procedure.AsyncProcedure;\r
-\r
-final public class SingleFunctionalOrNullProcedure<Result> extends AsyncMultiProcedureAdapter<Result> {\r
-    \r
-       final String location;\r
-       final AsyncProcedure<Result> procedure;\r
-    final AtomicBoolean found = new AtomicBoolean(false);\r
-    final AtomicBoolean guard = new AtomicBoolean(false);\r
-    final AtomicBoolean exception = new AtomicBoolean(false);\r
-    \r
-    public SingleFunctionalOrNullProcedure(String location, AsyncProcedure<Result> procedure) {\r
-        \r
-       this.location = location;\r
-        this.procedure = procedure;\r
-        \r
-    }\r
-    \r
-    @Override\r
-    public void execute(AsyncReadGraph graph, Result result) {\r
-        \r
-        assert(!guard.get());\r
-\r
-        if(found.compareAndSet(false, true)) {\r
-            procedure.execute(graph, result);\r
-        } else {\r
-            if(exception.compareAndSet(false, true)) {\r
-                procedure.exception(graph, new ManyObjectsForFunctionalRelationException(location + " -> " + procedure));\r
-            }\r
-        }\r
-        \r
-    }\r
-       \r
-    @Override\r
-    public void finished(AsyncReadGraph graph) {\r
-\r
-        assert(!guard.get());\r
-        \r
-        guard.set(true);\r
-        \r
-        if(found.compareAndSet(false, true)) {\r
-            procedure.execute(graph, null);\r
-        }\r
-        \r
-    }\r
-    \r
-    @Override\r
-    public void exception(AsyncReadGraph graph, Throwable t) {\r
-        \r
-        procedure.exception(graph, t);\r
-        \r
-    }\r
-    \r
-    @Override\r
-    public String toString() {\r
-        return "SingleFunctionalOrNullProcedure -> " + procedure;\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.db.common.procedure.single.wrapper;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.simantics.db.AsyncReadGraph;
+import org.simantics.db.common.procedure.adapter.AsyncMultiProcedureAdapter;
+import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;
+import org.simantics.db.procedure.AsyncProcedure;
+
+final public class SingleFunctionalOrNullProcedure<Result> extends AsyncMultiProcedureAdapter<Result> {
+    
+       final String location;
+       final AsyncProcedure<Result> procedure;
+    final AtomicBoolean found = new AtomicBoolean(false);
+    final AtomicBoolean guard = new AtomicBoolean(false);
+    final AtomicBoolean exception = new AtomicBoolean(false);
+    
+    public SingleFunctionalOrNullProcedure(String location, AsyncProcedure<Result> procedure) {
+        
+       this.location = location;
+        this.procedure = procedure;
+        
+    }
+    
+    @Override
+    public void execute(AsyncReadGraph graph, Result result) {
+        
+        assert(!guard.get());
+
+        if(found.compareAndSet(false, true)) {
+            procedure.execute(graph, result);
+        } else {
+            if(exception.compareAndSet(false, true)) {
+                procedure.exception(graph, new ManyObjectsForFunctionalRelationException(location + " -> " + procedure));
+            }
+        }
+        
+    }
+       
+    @Override
+    public void finished(AsyncReadGraph graph) {
+
+        assert(!guard.get());
+        
+        guard.set(true);
+        
+        if(found.compareAndSet(false, true)) {
+            procedure.execute(graph, null);
+        }
+        
+    }
+    
+    @Override
+    public void exception(AsyncReadGraph graph, Throwable t) {
+        
+        procedure.exception(graph, t);
+        
+    }
+    
+    @Override
+    public String toString() {
+        return "SingleFunctionalOrNullProcedure -> " + procedure;
+    }
+
+}