]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Use java.util.Consumer instead of os.utils.datastructures.Callback 76/1276/3
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 1 Dec 2017 09:38:23 +0000 (11:38 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 1 Dec 2017 10:47:37 +0000 (12:47 +0200)
This removes lots of deprecation warnings from the DB codebase.

refs #7655

Change-Id: Ibdfbac83c69d5af3823a28447256176183ab335a

26 files changed:
bundles/org.simantics.acorn/src/org/simantics/acorn/Persistable.java
bundles/org.simantics.acorn/src/org/simantics/acorn/cluster/ClusterBig.java
bundles/org.simantics.acorn/src/org/simantics/acorn/cluster/ClusterSmall.java
bundles/org.simantics.acorn/src/org/simantics/acorn/internal/ClusterStream.java
bundles/org.simantics.db.common/src/org/simantics/db/common/processor/MergingGraphRequestProcessor.java
bundles/org.simantics.db.common/src/org/simantics/db/common/processor/ProcessorBase.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/ClusterI.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/TransientGraph.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/VirtualGraphImpl.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/ReadGraphImpl.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/WriteGraphImpl.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/support/WriteRequestScheduleSupport.java
bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterWriteOnly.java
bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/DirectQuerySupportImpl.java
bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/NewStatementImpl.java
bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/QueryDebugImpl.java
bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/QuerySupportImpl.java
bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/SessionImplSocket.java
bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/TransactionToken.java
bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/WriteSupportImpl.java
bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ClusterBig.java
bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ClusterSmall.java
bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/PredicateTable.java
bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ValueTable.java
bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ValueTableSmall.java
bundles/org.simantics.db/src/org/simantics/db/AsyncRequestProcessorSpecific.java

index 86dfdd435122036d6aaf5b5c45042d7bed7f14f1..89574faabe445f70efd4aff3e51c1b15fde40ab4 100644 (file)
@@ -5,7 +5,6 @@ import java.nio.file.Path;
 
 import org.simantics.acorn.exception.AcornAccessVerificationException;
 import org.simantics.acorn.exception.IllegalAcornStateException;
-import org.simantics.db.exception.SDBException;
 
 public interface Persistable {
        
index 51241728d16438278f1be4808404a0bc5c2754ef..1de4006a72e630482a22dd5390c39b2e411fb15b 100644 (file)
@@ -15,6 +15,7 @@ import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Arrays;
+import java.util.function.Consumer;
 
 import org.simantics.acorn.exception.AcornAccessVerificationException;
 import org.simantics.acorn.exception.IllegalAcornStateException;
@@ -52,7 +53,6 @@ import org.simantics.db.procore.cluster.PredicateTable;
 import org.simantics.db.procore.cluster.ResourceTable;
 import org.simantics.db.procore.cluster.ValueTable;
 import org.simantics.db.service.ClusterUID;
-import org.simantics.utils.datastructures.Callback;
 
 final public class ClusterBig extends ClusterImpl {
     private static final int TABLE_HEADER_SIZE = TableHeader.HEADER_SIZE + TableHeader.EXTRA_SIZE;
@@ -864,7 +864,7 @@ final public class ClusterBig extends ClusterImpl {
     }
 
     @Override
-    public void load(Callback<DatabaseException> r) {
+    public void load(Consumer<DatabaseException> r) {
         throw new Error("Not supported.");
     }
 
index b84d4d51fe84fef82e1dc1f8a63fdb817cf3c82b..117ab75a3fc723b66660cd48c6db6231b496a3d1 100644 (file)
@@ -15,6 +15,7 @@ import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Arrays;
+import java.util.function.Consumer;
 
 import org.simantics.acorn.exception.IllegalAcornStateException;
 import org.simantics.acorn.internal.ClusterChange;
@@ -52,7 +53,6 @@ import org.simantics.db.procore.cluster.ValueTableSmall;
 import org.simantics.db.service.Bytes;
 import org.simantics.db.service.ClusterUID;
 import org.simantics.db.service.ResourceUID;
-import org.simantics.utils.datastructures.Callback;
 
 import gnu.trove.map.hash.TIntShortHashMap;
 import gnu.trove.procedure.TIntProcedure;
@@ -1018,7 +1018,7 @@ final public class ClusterSmall extends ClusterImpl {
     }
 
     @Override
-    public void load(Callback<DatabaseException> r) {
+    public void load(Consumer<DatabaseException> r) {
         throw new Error("Not supported.");
     }
 
@@ -1275,7 +1275,7 @@ final public class ClusterSmall extends ClusterImpl {
     }
 
     @Override
-    public Table getForeignTable() {
+    public Table<?> getForeignTable() {
         return foreignTable;
     }
 
index 2b1ae1979b1de072faf8c19bc7dc37faa3ac87db..078a4dabbde7d5a4e235f141f248453ca6473497 100644 (file)
  *******************************************************************************/
 package org.simantics.acorn.internal;
 
-import java.util.ArrayList;
-
-import org.simantics.db.exception.DatabaseException;
-import org.simantics.db.service.ClusterUID;
-
 final public class ClusterStream {
 
 //    // public static long duration2 = 0;
index 5e07bb034ecb924adc8567f99f09990e141e69ed..bf72e041648e4d11c4e0e4b1de8506b8e8397cf2 100644 (file)
@@ -19,6 +19,7 @@ import java.util.LinkedList;
 import java.util.Set;
 import java.util.UUID;
 import java.util.concurrent.Semaphore;
+import java.util.function.Consumer;
 
 import org.simantics.db.AsyncReadGraph;
 import org.simantics.db.AsyncRequestProcessor;
@@ -61,7 +62,6 @@ import org.simantics.db.request.WriteOnly;
 import org.simantics.db.request.WriteOnlyResult;
 import org.simantics.db.request.WriteResult;
 import org.simantics.utils.DataContainer;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.datastructures.Pair;
 
 public class MergingGraphRequestProcessor implements RequestProcessor {
@@ -374,7 +374,7 @@ public class MergingGraphRequestProcessor implements RequestProcessor {
                 }
 
                 @SuppressWarnings("unchecked")
-                Callback<Throwable> callback = (Callback<Throwable>)currentRequest.second;
+                Consumer<Throwable> callback = (Consumer<Throwable>)currentRequest.second;
 
                 if (currentRequest.first.getClass().equals(SyncWriteRequestAdapter.class)) {
 
@@ -383,10 +383,10 @@ public class MergingGraphRequestProcessor implements RequestProcessor {
                     try {
 //                        System.out.println("merg.sync " + adapter);
                         graph.syncRequest(adapter);
-                        if(callback != null) callback.run(null);
+                        if(callback != null) callback.accept(null);
                     } catch(Throwable t) {
                                Logger.defaultLogError(t);
-                        if(callback != null) callback.run(t);
+                        if(callback != null) callback.accept(t);
                     }
 
                     adapter.release();
@@ -397,10 +397,10 @@ public class MergingGraphRequestProcessor implements RequestProcessor {
                     try {
                         if(currentRequest.first instanceof Write) graph.syncRequest((Write)currentRequest.first); 
                         else if(currentRequest.first instanceof DelayedWrite) graph.syncRequest((DelayedWrite)currentRequest.first); 
-                        if(callback != null) callback.run(null);
+                        if(callback != null) callback.accept(null);
                     } catch(Throwable t) {
                                Logger.defaultLogError(t);
-                        if(callback != null) callback.run(t);
+                        if(callback != null) callback.accept(t);
                     }
 
                 }
@@ -482,7 +482,7 @@ public class MergingGraphRequestProcessor implements RequestProcessor {
     }
 
     @Override
-    public synchronized void asyncRequest(Write request, Callback<DatabaseException> callback) {
+    public synchronized void asyncRequest(Write request, Consumer<DatabaseException> callback) {
 
 //        System.out.println(this + " asyncRequest(WriteGraphRequest request)");
 
@@ -505,7 +505,7 @@ public class MergingGraphRequestProcessor implements RequestProcessor {
     }
 
     @Override
-    public synchronized void asyncRequest(DelayedWrite request, Callback<DatabaseException> callback) {
+    public synchronized void asyncRequest(DelayedWrite request, Consumer<DatabaseException> callback) {
 
 //        System.out.println(this + " asyncRequest(WriteGraphRequest request)");
 
@@ -528,7 +528,7 @@ public class MergingGraphRequestProcessor implements RequestProcessor {
     }
 
     @Override
-    public synchronized void asyncRequest(WriteOnly request, Callback<DatabaseException> callback) {
+    public synchronized void asyncRequest(WriteOnly request, Consumer<DatabaseException> callback) {
 
 //        System.out.println(this + " asyncRequest(WriteGraphRequest request)");
 
index d8d3cdbf1049f3853f14bf5b6236684afc872126..6e1aeabaae4d3b47a8a3624e73c2e64a366c8854 100644 (file)
@@ -12,6 +12,7 @@
 package org.simantics.db.common.processor;
 
 import java.util.Collection;
+import java.util.function.Consumer;
 
 import org.simantics.db.RequestProcessor;
 import org.simantics.db.Resource;
@@ -42,7 +43,6 @@ import org.simantics.db.request.WriteInterface;
 import org.simantics.db.request.WriteOnly;
 import org.simantics.db.request.WriteOnlyResult;
 import org.simantics.db.request.WriteResult;
-import org.simantics.utils.datastructures.Callback;
 
 public class ProcessorBase implements RequestProcessor {
 
@@ -57,17 +57,17 @@ public class ProcessorBase implements RequestProcessor {
     }
 
     @Override
-    public void asyncRequest(Write request, Callback<DatabaseException> callback) {
+    public void asyncRequest(Write request, Consumer<DatabaseException> callback) {
         throw new UnsupportedOperationException();
     }
 
     @Override
-    public void asyncRequest(DelayedWrite request, Callback<DatabaseException> callback) {
+    public void asyncRequest(DelayedWrite request, Consumer<DatabaseException> callback) {
         throw new UnsupportedOperationException();
     }
 
     @Override
-    public void asyncRequest(WriteOnly request, Callback<DatabaseException> callback) {
+    public void asyncRequest(WriteOnly request, Consumer<DatabaseException> callback) {
         throw new UnsupportedOperationException();
     }
 
index d3b24eb3e42c0f0a355847c68a954e0beda5eb14..87acea43d4801c388154f5738b08f0b2428ed55d 100644 (file)
 package org.simantics.db.impl;
 
 import java.io.InputStream;
+import java.util.function.Consumer;
 
 import org.simantics.db.Resource;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.impl.graph.ReadGraphImpl;
 import org.simantics.db.procedure.AsyncMultiProcedure;
 import org.simantics.db.service.ClusterUID;
-import org.simantics.utils.datastructures.Callback;
 
 public interface ClusterI {
     public enum TypeEnum {
@@ -210,7 +210,7 @@ public interface ClusterI {
     public void load()
     throws DatabaseException;
 
-    public void load(Callback<DatabaseException> callback);
+    public void load(Consumer<DatabaseException> callback);
     public void load(ClusterSupport session, Runnable callback);
 
 
index 3a552ed194a44877ce20f9e4e5e37fb7668df1f3..f4e722fe5adea864496e4a7864197ae7fb6e877d 100644 (file)
@@ -19,6 +19,7 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.LinkedList;
+import java.util.function.Consumer;
 
 import org.simantics.databoard.Bindings;
 import org.simantics.databoard.binding.Binding;
@@ -48,7 +49,6 @@ import org.simantics.db.procedure.AsyncProcedure;
 import org.simantics.db.request.Write;
 import org.simantics.db.request.WriteOnly;
 import org.simantics.db.service.SerialisationSupport;
-import org.simantics.utils.datastructures.Callback;
 
 import gnu.trove.list.array.TIntArrayList;
 import gnu.trove.map.hash.TIntObjectHashMap;
@@ -867,34 +867,34 @@ public class TransientGraph implements VirtualGraphImpl, VirtualGraphContext {
     }
     
     @Override
-    public void load(ReadGraphImpl graph, int resource, int predicate, final Callback<ReadGraphImpl> callback) throws DatabaseException {
+    public void load(ReadGraphImpl graph, int resource, int predicate, final Consumer<ReadGraphImpl> callback) throws DatabaseException {
         producePartialStatements(graph, resource, predicate, new AsyncProcedure<Object>() {
 
             @Override
             public void execute(AsyncReadGraph graph, Object result) {
-                callback.run((ReadGraphImpl)graph);
+                callback.accept((ReadGraphImpl)graph);
             }
 
             @Override
             public void exception(AsyncReadGraph graph, Throwable throwable) {
-                callback.run((ReadGraphImpl)graph);
+                callback.accept((ReadGraphImpl)graph);
             }
             
         });
     }
 
     @Override
-    public void load(ReadGraphImpl graph, int resource, final Callback<ReadGraphImpl> callback) throws DatabaseException {
+    public void load(ReadGraphImpl graph, int resource, final Consumer<ReadGraphImpl> callback) throws DatabaseException {
         produceAllStatements(graph, resource, new AsyncProcedure<Object>() {
 
             @Override
             public void execute(AsyncReadGraph graph, Object result) {
-                callback.run((ReadGraphImpl)graph);
+                callback.accept((ReadGraphImpl)graph);
             }
 
             @Override
             public void exception(AsyncReadGraph graph, Throwable throwable) {
-                callback.run((ReadGraphImpl)graph);
+                callback.accept((ReadGraphImpl)graph);
             }
             
         });
index 4fd4e9a45e9b852801ec08b3a5eb146eddf9e8bc..17503977ec7ab77ba804af74731936d77baf68a9 100644 (file)
  *******************************************************************************/
 package org.simantics.db.impl;
 
+import java.util.function.Consumer;
+
 import org.simantics.db.VirtualGraph;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.impl.graph.ReadGraphImpl;
-import org.simantics.utils.datastructures.Callback;
 
 public interface VirtualGraphImpl extends VirtualGraph {
 
@@ -31,8 +32,8 @@ public interface VirtualGraphImpl extends VirtualGraph {
     public boolean isPending(int resource);
     public boolean isPending(int resource, int predicate);
     
-    public void load(ReadGraphImpl graph, int resource, int predicate, Callback<ReadGraphImpl> callback) throws DatabaseException;
-    public void load(ReadGraphImpl graph, int resource, Callback<ReadGraphImpl> callback) throws DatabaseException;
+    public void load(ReadGraphImpl graph, int resource, int predicate, Consumer<ReadGraphImpl> callback) throws DatabaseException;
+    public void load(ReadGraphImpl graph, int resource, Consumer<ReadGraphImpl> callback) throws DatabaseException;
 
 }
 
index 9b6d74044ccacc0d27e0039d3646ed0b9d5fabe7..b853ed5191e3654f5cfbddea240b33c48b77bff1 100644 (file)
@@ -11,8 +11,6 @@
  *******************************************************************************/
 package org.simantics.db.impl.graph;
 
-import gnu.trove.map.hash.TObjectIntHashMap;
-
 import java.io.BufferedOutputStream;
 import java.io.File;
 import java.io.FileOutputStream;
@@ -29,6 +27,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.ListIterator;
 import java.util.Set;
+import java.util.function.Consumer;
 
 import org.eclipse.core.runtime.Platform;
 import org.simantics.databoard.Accessors;
@@ -181,10 +180,11 @@ import org.simantics.scl.reflection.ValueNotFoundException;
 import org.simantics.scl.runtime.function.Function3;
 import org.simantics.utils.DataContainer;
 import org.simantics.utils.Development;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.datastructures.Pair;
 import org.simantics.utils.datastructures.collections.CollectionUtils;
 
+import gnu.trove.map.hash.TObjectIntHashMap;
+
 public class ReadGraphImpl implements ReadGraph {
 
     final static boolean EMPTY_RESOURCE_CHECK = false;
@@ -5912,7 +5912,7 @@ public class ReadGraphImpl implements ReadGraph {
        }
        
        @Override
-       public void asyncRequest(Write request, Callback<DatabaseException> callback) {
+       public void asyncRequest(Write request, Consumer<DatabaseException> callback) {
                
                assert (request != null);
                
@@ -5936,7 +5936,7 @@ public class ReadGraphImpl implements ReadGraph {
        
        @Override
        public void asyncRequest(DelayedWrite r,
-                       Callback<DatabaseException> callback) {
+                       Consumer<DatabaseException> callback) {
                throw new Error("Not implemented.");
        }
 
@@ -5955,7 +5955,7 @@ public class ReadGraphImpl implements ReadGraph {
        }
        
        @Override
-       public void asyncRequest(WriteOnly r, Callback<DatabaseException> callback) {
+       public void asyncRequest(WriteOnly r, Consumer<DatabaseException> callback) {
                throw new Error("Not implemented.");
        }
 
index f640513c62b1ec74ee3eed8dd4f42c7f070cef3c..ca485f9893957ff784075f686b87221e843fce50 100644 (file)
@@ -15,6 +15,7 @@ import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.util.TreeMap;
+import java.util.function.Consumer;
 
 import org.simantics.databoard.Bindings;
 import org.simantics.databoard.accessor.Accessor;
@@ -66,7 +67,6 @@ import org.simantics.db.request.WriteResult;
 import org.simantics.db.request.WriteTraits;
 import org.simantics.layer0.Layer0;
 import org.simantics.utils.Development;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.datastructures.Pair;
 
 import gnu.trove.map.hash.THashMap;
@@ -243,19 +243,14 @@ final public class WriteGraphImpl extends ReadGraphImpl implements WriteGraph {
     @Override
     public void asyncRequest(DelayedWrite request) {
         assert (request != null);
-        getWriteRequestScheduler().scheduleRequest(request, new Callback<DatabaseException>() {
-
-                       @Override
-                       public void run(DatabaseException parameter) {
-                               if(parameter != null)
-                                       Logger.defaultLogError(parameter);
-                       }
-               
+        getWriteRequestScheduler().scheduleRequest(request, e -> {
+            if(e != null)
+                Logger.defaultLogError(e);
         }, null, Boolean.TRUE);
     }
 
     @Override
-    public void asyncRequest(DelayedWrite request, Callback<DatabaseException> callback) {
+    public void asyncRequest(DelayedWrite request, Consumer<DatabaseException> callback) {
         assert (request != null);
         getWriteRequestScheduler().scheduleRequest(request, callback, null, Boolean.TRUE);
     }
@@ -269,19 +264,14 @@ final public class WriteGraphImpl extends ReadGraphImpl implements WriteGraph {
     @Override
     public void asyncRequest(final Write r) {
         assert (r != null);
-        getWriteRequestScheduler().scheduleRequest(r, new Callback<DatabaseException>() {
-
-                       @Override
-                       public void run(DatabaseException parameter) {
-                               if(parameter != null)
-                                       Logger.defaultLogError(parameter);
-                       }
-               
+        getWriteRequestScheduler().scheduleRequest(r, e -> {
+            if(e != null)
+                Logger.defaultLogError(e);
         }, null, Boolean.TRUE);
     }
 
     @Override
-    public void asyncRequest(Write request, Callback<DatabaseException> callback) {
+    public void asyncRequest(Write request, Consumer<DatabaseException> callback) {
         assert (request != null);
         getWriteRequestScheduler().scheduleRequest(request, callback, null, Boolean.TRUE);
     }
@@ -289,19 +279,14 @@ final public class WriteGraphImpl extends ReadGraphImpl implements WriteGraph {
     @Override
     public void asyncRequest(WriteOnly request) {
         assert (request != null);
-        getWriteRequestScheduler().scheduleRequest(request, new Callback<DatabaseException>() {
-
-                       @Override
-                       public void run(DatabaseException parameter) {
-                               if(parameter != null)
-                                       Logger.defaultLogError(parameter);
-                       }
-               
+        getWriteRequestScheduler().scheduleRequest(request, e -> {
+            if(e != null)
+                Logger.defaultLogError(e);
         }, null, Boolean.TRUE);
     }
     
     @Override
-    public void asyncRequest(WriteOnly request, Callback<DatabaseException> callback) {
+    public void asyncRequest(WriteOnly request, Consumer<DatabaseException> callback) {
         assert (request != null);
         getWriteRequestScheduler().scheduleRequest(request, callback, null, Boolean.TRUE);
     }
index 30fa049d9bc8a8ee6c4cf35e0f3fe9a70e0f1568..c44c2b91dd590c4aa18d6e24b13f2a5643b1bddd 100644 (file)
@@ -1,6 +1,7 @@
 package org.simantics.db.impl.support;
 
 import java.util.concurrent.Semaphore;
+import java.util.function.Consumer;
 
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.procedure.Procedure;
@@ -10,21 +11,20 @@ import org.simantics.db.request.Write;
 import org.simantics.db.request.WriteOnly;
 import org.simantics.db.request.WriteOnlyResult;
 import org.simantics.db.request.WriteResult;
-import org.simantics.utils.datastructures.Callback;
 
 /**
  * @author Tuukka Lehtonen
  */
 public interface WriteRequestScheduleSupport {
 
-    <T> void scheduleRequest(DelayedWrite request, Callback<DatabaseException> callback, Semaphore notify,
+    <T> void scheduleRequest(DelayedWrite request, Consumer<DatabaseException> callback, Semaphore notify,
             Boolean combine);
 
     <T> void scheduleRequest(DelayedWriteResult<T> request, Procedure<T> procedure, Semaphore notify, Boolean combine);
 
-    <T> void scheduleRequest(Write request, Callback<DatabaseException> callback, Semaphore notify, Boolean combine);
+    <T> void scheduleRequest(Write request, Consumer<DatabaseException> callback, Semaphore notify, Boolean combine);
 
-    <T> void scheduleRequest(WriteOnly request, Callback<DatabaseException> callback, Semaphore notify, Boolean combine);
+    <T> void scheduleRequest(WriteOnly request, Consumer<DatabaseException> callback, Semaphore notify, Boolean combine);
 
     <T> void scheduleRequest(WriteOnlyResult<T> request, Procedure<T> callback, Semaphore notify, Boolean combine);
 
index 17008c963bd53ac39c4e30559e0b45dca45b7cf5..f7e3a20cf4a9311e1cef6c7e3efe7b77757f5aea 100644 (file)
@@ -12,6 +12,7 @@
 package fi.vtt.simantics.procore.internal;
 
 import java.io.InputStream;
+import java.util.function.Consumer;
 
 import org.simantics.db.Resource;
 import org.simantics.db.exception.DatabaseException;
@@ -29,7 +30,6 @@ import org.simantics.db.procore.cluster.ClusterBig;
 import org.simantics.db.procore.cluster.ClusterImpl;
 import org.simantics.db.procore.cluster.ClusterTraits;
 import org.simantics.db.service.ClusterUID;
-import org.simantics.utils.datastructures.Callback;
 
 import fi.vtt.simantics.procore.DebugPolicy;
 
@@ -205,7 +205,7 @@ final public class ClusterWriteOnly extends ClusterImpl {
     public void load() {
     }
     @Override
-    public void load(Callback<DatabaseException> r) {
+    public void load(Consumer<DatabaseException> r) {
     }
 
     @Override
index 9d6b019e4a2d22de5a3954f77f125abde174a468..a0f6c1d1eb3cd437a65a340083c4d1ed1f6c241b 100644 (file)
@@ -30,7 +30,6 @@ import org.simantics.db.procore.cluster.ResourceTableSmall;
 import org.simantics.db.procore.cluster.ValueTableSmall;
 import org.simantics.db.request.AsyncRead;
 import org.simantics.db.service.DirectQuerySupport;
-import org.simantics.utils.datastructures.Callback;
 
 public class DirectQuerySupportImpl implements DirectQuerySupport {
 
@@ -484,14 +483,9 @@ public class DirectQuerySupportImpl implements DirectQuerySupport {
                if(subject < 0) {
 
                        if(!SessionImplSocket.areVirtualStatementsLoaded(session.virtualGraphServerSupport, subject, predicate)) {
-                           SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject, predicate, new Callback<ReadGraphImpl>()  {
-
-                                       @Override
-                                       public void run(ReadGraphImpl graph) {
-                                               getRelatedValue4(graph, subject, context, procedure);
-                                       }
-                                       
-                               });
+                           SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject, predicate,
+                                   g -> getRelatedValue4(g, subject, context, procedure)
+                               );
                                return;
                        }
                        
@@ -524,28 +518,16 @@ public class DirectQuerySupportImpl implements DirectQuerySupport {
                
         final org.simantics.db.procore.cluster.ClusterImpl cluster = session.clusterTable.getClusterByResourceKey(subject);
         if(!cluster.isLoaded()) {
-               cluster.load(session.clusterTranslator, new Runnable() {
-
-                               @Override
-                               public void run() {
-                                       getRelatedValue4(graph, subject, context, procedure);
-                               }
-                       
-               });
+               cluster.load(session.clusterTranslator, () -> getRelatedValue4(graph, subject, context, procedure));
                return;
         }
         
         if(cluster.hasVirtual() && session.virtualGraphServerSupport.virtuals.contains(subject)) {
                        
                        if(!SessionImplSocket.areVirtualStatementsLoaded(session.virtualGraphServerSupport, subject, predicate)) {
-                           SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject, predicate, new Callback<ReadGraphImpl>()  {
-
-                                       @Override
-                                       public void run(ReadGraphImpl graph) {
-                                               getRelatedValue4(graph, subject, context, procedure);
-                                       }
-                                       
-                               });
+                           SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject, predicate,
+                                   g -> getRelatedValue4(g, subject, context, procedure)
+                               );
                                return;
                        }
                
@@ -578,14 +560,9 @@ public class DirectQuerySupportImpl implements DirectQuerySupport {
                if(subject < 0) {
 
                        if(!SessionImplSocket.areVirtualStatementsLoaded(session.virtualGraphServerSupport, subject)) {
-                           SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject, new Callback<ReadGraphImpl>()  {
-
-                                       @Override
-                                       public void run(ReadGraphImpl graph) {
-                                               getValue4(graph, containerCluster, subject, procedure);
-                                       }
-                                       
-                               });
+                           SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject, 
+                                   g -> getValue4(g, containerCluster, subject, procedure)
+                           );
                                return;
                        }
                        
@@ -627,14 +604,9 @@ public class DirectQuerySupportImpl implements DirectQuerySupport {
         if(cluster.hasVirtual() && session.virtualGraphServerSupport.virtuals.contains(subject)) {
 
                        if(!SessionImplSocket.areVirtualStatementsLoaded(session.virtualGraphServerSupport, subject)) {
-                           SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject, new Callback<ReadGraphImpl>()  {
-
-                                       @Override
-                                       public void run(ReadGraphImpl graph) {
-                                               getValue4(graph, containerCluster, subject, procedure);
-                                       }
-                                       
-                               });
+                           SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject,
+                           g -> getValue4(g, containerCluster, subject, procedure)
+                           );
                                return;
                        }
                
@@ -682,14 +654,9 @@ public class DirectQuerySupportImpl implements DirectQuerySupport {
                if(subject < 0) {
 
                        if(!SessionImplSocket.areVirtualStatementsLoaded(session.virtualGraphServerSupport, subject)) {
-                           SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject, new Callback<ReadGraphImpl>()  {
-
-                                       @Override
-                                       public void run(ReadGraphImpl graph) {
-                                               getValue4(graph, containerCluster, subject, context, procedure);
-                                       }
-                                       
-                               });
+                           SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject,
+                                   g -> getValue4(g, containerCluster, subject, context, procedure)
+                           );
                                return;
                        }
                        
@@ -731,14 +698,9 @@ public class DirectQuerySupportImpl implements DirectQuerySupport {
         if(cluster.hasVirtual() && session.virtualGraphServerSupport.virtuals.contains(subject)) {
 
                        if(!SessionImplSocket.areVirtualStatementsLoaded(session.virtualGraphServerSupport, subject)) {
-                           SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject, new Callback<ReadGraphImpl>()  {
-
-                                       @Override
-                                       public void run(ReadGraphImpl graph) {
-                                               getValue4(graph, containerCluster, subject, context, procedure);
-                                       }
-                                       
-                               });
+                           SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject,
+                                    g -> getValue4(g, containerCluster, subject, context, procedure)
+                           );
                                return;
                        }
                
@@ -842,14 +804,9 @@ public class DirectQuerySupportImpl implements DirectQuerySupport {
                if(subject < 0) {
 
                        if(!SessionImplSocket.areVirtualStatementsLoaded(session.virtualGraphServerSupport, subject, predicate)) {
-                           SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject, predicate, new Callback<ReadGraphImpl>()  {
-
-                                       @Override
-                                       public void run(ReadGraphImpl graph) {
-                                               getRelatedValue4(graph, subject, procedure);
-                                       }
-                                       
-                               });
+                           SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject, predicate,
+                                   g -> getRelatedValue4(g, subject, procedure)
+                           );
                                return;
                        }
                        
@@ -896,14 +853,9 @@ public class DirectQuerySupportImpl implements DirectQuerySupport {
         if(cluster.hasVirtual() && session.virtualGraphServerSupport.virtuals.contains(subject)) {
                        
                        if(!SessionImplSocket.areVirtualStatementsLoaded(session.virtualGraphServerSupport, subject, predicate)) {
-                           SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject, predicate, new Callback<ReadGraphImpl>()  {
-
-                                       @Override
-                                       public void run(ReadGraphImpl graph) {
-                                               getRelatedValue4(graph, subject, procedure);
-                                       }
-                                       
-                               });
+                           SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject, predicate,
+                                   g -> getRelatedValue4(graph, subject, procedure)
+                           );
                                return;
                        }
                
index 77cda628a26f1c17d19768f466d0166394ae7e5a..518be61d42e73a2467f1a2835e507b61088dbaf5 100644 (file)
@@ -26,7 +26,7 @@ public class NewStatementImpl implements Statement {
             throw new IllegalArgumentException();
         if(null == predicate)
             throw new IllegalArgumentException();
-        if(null == predicate)
+        if(null == object)
             throw new IllegalArgumentException();
         this.subject = (ResourceImpl)subject;
         this.predicate = (ResourceImpl)predicate;
index 7a642176841cf22ea9856df879811da90bf31224..e3f73833941dcc7b7d9835c9bfd9e9079da20885 100644 (file)
@@ -20,7 +20,7 @@ public class QueryDebugImpl implements QueryDebug {
        }
 
     @Override
-    public Set<CacheEntry> getParents(AsyncRead request) {
+    public Set<CacheEntry> getParents(AsyncRead<?> request) {
         HashSet<CacheEntry> result = new HashSet<CacheEntry>();
         CacheEntryBase entry = session.queryProvider2.asyncReadMap.get(request);
         if(entry != null) {
@@ -30,7 +30,7 @@ public class QueryDebugImpl implements QueryDebug {
     }
 
     @Override
-    public Set<CacheEntry> getParents(AsyncMultiRead request) {
+    public Set<CacheEntry> getParents(AsyncMultiRead<?> request) {
         HashSet<CacheEntry> result = new HashSet<CacheEntry>();
         CacheEntryBase entry = session.queryProvider2.asyncMultiReadMap.get(request);
         if(entry != null) {
@@ -40,7 +40,7 @@ public class QueryDebugImpl implements QueryDebug {
     }
 
     @Override
-    public Set<CacheEntry> getParents(Read request) {
+    public Set<CacheEntry> getParents(Read<?> request) {
         HashSet<CacheEntry> result = new HashSet<CacheEntry>();
         CacheEntryBase entry = session.queryProvider2.readMap.get(request);
         if(entry != null) {
@@ -50,7 +50,7 @@ public class QueryDebugImpl implements QueryDebug {
     }
 
     @Override
-    public Set<CacheEntry> getParents(MultiRead request) {
+    public Set<CacheEntry> getParents(MultiRead<?> request) {
         HashSet<CacheEntry> result = new HashSet<CacheEntry>();
         CacheEntryBase entry = session.queryProvider2.multiReadMap.get(request);
         if(entry != null) {
index 1d3563fc1a3b5fca63688dca04a52c4805bdee50..190db364cbdf8bda86c56cc2c4f427990200c352 100644 (file)
@@ -5,6 +5,7 @@ import gnu.trove.set.hash.TIntHashSet;
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.util.Collection;
+import java.util.function.Consumer;
 
 import org.simantics.db.Resource;
 import org.simantics.db.Session;
@@ -34,7 +35,6 @@ import org.simantics.db.procore.cluster.ClusterImpl;
 import org.simantics.db.procore.cluster.ClusterSmall;
 import org.simantics.db.service.SerialisationSupport;
 import org.simantics.utils.DataContainer;
-import org.simantics.utils.datastructures.Callback;
 
 public class QuerySupportImpl implements QuerySupport {
        
@@ -1336,13 +1336,13 @@ public class QuerySupportImpl implements QuerySupport {
     @Override
     public void requestCluster(ReadGraphImpl graph, final long clusterId, final Runnable r) {
 
-        class CallbackAdapter implements Callback<DatabaseException> {
+        class CallbackAdapter implements Consumer<DatabaseException> {
                final Runnable r;
                CallbackAdapter(final Runnable r) {
                        this.r = r;
                }
                @Override
-               public void run(DatabaseException e) {
+               public void accept(DatabaseException e) {
                        if (null != e)
                                e.printStackTrace();
                        else
@@ -1515,13 +1515,7 @@ public class QuerySupportImpl implements QuerySupport {
                
                if(subject < 0) {
                        
-                       SessionImplSocket.loadVirtualStatements(virtualGraphServerSupport, graph, subject, predicate, new Callback<ReadGraphImpl>() {
-
-                               @Override
-                               public void run(ReadGraphImpl parameter) {
-                               }
-                               
-                       });
+                       SessionImplSocket.loadVirtualStatements(virtualGraphServerSupport, graph, subject, predicate, g -> {});
                        
                } else {
                        
@@ -1531,13 +1525,7 @@ public class QuerySupportImpl implements QuerySupport {
                        
                        if(cluster.hasVirtual() && virtualGraphServerSupport.virtuals.contains(subject) && !SessionImplSocket.areVirtualStatementsLoaded(virtualGraphServerSupport, subject, predicate)) {
 
-                                       SessionImplSocket.loadVirtualStatements(virtualGraphServerSupport, graph, subject, predicate, new Callback<ReadGraphImpl>() {
-
-                                               @Override
-                                               public void run(ReadGraphImpl parameter) {
-                                               }
-                                               
-                                       });
+                                       SessionImplSocket.loadVirtualStatements(virtualGraphServerSupport, graph, subject, predicate, g -> {});
                                
                                } else {
                                        
@@ -1554,13 +1542,7 @@ public class QuerySupportImpl implements QuerySupport {
                                                
                                        if(cluster.hasVirtual() && virtualGraphServerSupport.virtuals.contains(subject) && !SessionImplSocket.areVirtualStatementsLoaded(virtualGraphServerSupport, subject, predicate)) {
 
-                                                       SessionImplSocket.loadVirtualStatements(virtualGraphServerSupport, graph, subject, predicate, new Callback<ReadGraphImpl>() {
-
-                                                               @Override
-                                                               public void run(ReadGraphImpl parameter) {
-                                                               }
-                                                               
-                                                       });
+                                                       SessionImplSocket.loadVirtualStatements(virtualGraphServerSupport, graph, subject, predicate, g -> {});
                                                
                                                } else {
                                                        
@@ -1582,13 +1564,7 @@ public class QuerySupportImpl implements QuerySupport {
                
                if(subject < 0) {
                        
-                       SessionImplSocket.loadVirtualStatements(virtualGraphServerSupport, graph, subject, new Callback<ReadGraphImpl>() {
-
-                               @Override
-                               public void run(ReadGraphImpl parameter) {
-                               }
-                               
-                       });
+                       SessionImplSocket.loadVirtualStatements(virtualGraphServerSupport, graph, subject, g -> {});
                        
                } else {
                        
@@ -1598,13 +1574,7 @@ public class QuerySupportImpl implements QuerySupport {
                        
                        if(cluster.hasVirtual() && virtualGraphServerSupport.virtuals.contains(subject) && !SessionImplSocket.areVirtualStatementsLoaded(virtualGraphServerSupport, subject)) {
 
-                                       SessionImplSocket.loadVirtualStatements(virtualGraphServerSupport, graph, subject, new Callback<ReadGraphImpl>() {
-
-                                               @Override
-                                               public void run(ReadGraphImpl parameter) {
-                                               }
-                                               
-                                       });
+                                       SessionImplSocket.loadVirtualStatements(virtualGraphServerSupport, graph, subject, g -> {});
                                
                                } else {
                                        
@@ -1622,13 +1592,7 @@ public class QuerySupportImpl implements QuerySupport {
                                                
                                        if(cluster.hasVirtual() && virtualGraphServerSupport.virtuals.contains(subject) && !SessionImplSocket.areVirtualStatementsLoaded(virtualGraphServerSupport, subject)) {
 
-                                                       SessionImplSocket.loadVirtualStatements(virtualGraphServerSupport, graph, subject, new Callback<ReadGraphImpl>() {
-
-                                                               @Override
-                                                               public void run(ReadGraphImpl parameter) {
-                                                               }
-                                                               
-                                                       });
+                                                       SessionImplSocket.loadVirtualStatements(virtualGraphServerSupport, graph, subject, g -> {});
                                                
                                                } else {
                                                        
index 2ff47c29266912afa68ee0515fd5c47d1b809b89..9a86dc1fa2ae813b0b3a137b51a9063546af27af 100644 (file)
@@ -27,6 +27,7 @@ import java.util.TreeMap;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Consumer;
 
 import org.eclipse.core.runtime.Platform;
 import org.simantics.databoard.Bindings;
@@ -155,7 +156,6 @@ import org.simantics.db.service.XSupport;
 import org.simantics.layer0.Layer0;
 import org.simantics.utils.DataContainer;
 import org.simantics.utils.Development;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.threads.logger.ITask;
 import org.simantics.utils.threads.logger.ThreadLogger;
 
@@ -324,31 +324,29 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule
         private Object result;
         final Semaphore sema = new Semaphore(0);
         private Throwable throwable = null;
-        final Callback<DatabaseException> callback = new Callback<DatabaseException>() {
-            @Override
-            public void run(DatabaseException e) {
-                synchronized (TaskHelper.this) {
-                    throwable = e;
-                }
+        final Consumer<DatabaseException> callback = e -> {
+            synchronized (TaskHelper.this) {
+                throwable = e;
             }
         };
         final Procedure<Object> proc = new Procedure<Object>() {
             @Override
             public void execute(Object result) {
-                callback.run(null);
+                callback.accept(null);
             }
             @Override
             public void exception(Throwable t) {
                 if (t instanceof DatabaseException)
-                    callback.run((DatabaseException)t);
+                    callback.accept((DatabaseException)t);
                 else
-                    callback.run(new DatabaseException("" + name + "operation failed.", t));
+                    callback.accept(new DatabaseException("" + name + "operation failed.", t));
             }
         };
         final WriteTraits writeTraits = new WriteTraits() {};
         TaskHelper(String name) {
             this.name = name;
         }
+        @SuppressWarnings("unchecked")
         <T> T getResult() {
             return (T)result;
         }
@@ -387,7 +385,7 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule
             return null;
     }
 
-    public <T> void scheduleRequest(final Write request, final Callback<DatabaseException> callback, final Semaphore notify) {
+    public <T> void scheduleRequest(final Write request, final Consumer<DatabaseException> callback, final Semaphore notify) {
         scheduleRequest(request, callback, notify, null);
     }
 
@@ -395,7 +393,7 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule
      * @see fi.vtt.simantics.procore.internal.WriteRequestScheduler#scheduleRequest(org.simantics.db.request.Write, org.simantics.utils.datastructures.Callback, java.util.concurrent.Semaphore, java.lang.Boolean)
      */
     @Override
-    public <T> void scheduleRequest(final Write request, final Callback<DatabaseException> callback, final Semaphore notify, Boolean combine) {
+    public <T> void scheduleRequest(final Write request, final Consumer<DatabaseException> callback, final Semaphore notify, Boolean combine) {
 
         assert (request != null);
 
@@ -440,12 +438,12 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule
 
                         @Override
                         public void execute(Object result) {
-                            if(callback != null) callback.run(null);
+                            if(callback != null) callback.accept(null);
                         }
 
                         @Override
                         public void exception(Throwable t) {
-                            if(callback != null) callback.run((DatabaseException)t);
+                            if(callback != null) callback.accept((DatabaseException)t);
                         }
 
                     });
@@ -616,7 +614,7 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule
 
     }
 
-    public <T> void scheduleRequest(final DelayedWrite request, final Callback<DatabaseException> callback, final Semaphore notify) {
+    public <T> void scheduleRequest(final DelayedWrite request, final Consumer<DatabaseException> callback, final Semaphore notify) {
         scheduleRequest(request, callback, notify, null);
     }
 
@@ -624,7 +622,7 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule
      * @see fi.vtt.simantics.procore.internal.WriteRequestScheduler#scheduleRequest(org.simantics.db.request.DelayedWrite, org.simantics.utils.datastructures.Callback, java.util.concurrent.Semaphore, java.lang.Boolean)
      */
     @Override
-    public <T> void scheduleRequest(final DelayedWrite request, final Callback<DatabaseException> callback, final Semaphore notify, Boolean combine) {
+    public <T> void scheduleRequest(final DelayedWrite request, final Consumer<DatabaseException> callback, final Semaphore notify, Boolean combine) {
 
         final ITask total = ThreadLogger.getInstance().begin("ScheduleDelayedWrite");
 
@@ -642,13 +640,13 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule
                     @Override
                     public void execute(Object result) {
                         if (callback != null)
-                            callback.run(null);
+                            callback.accept(null);
                     }
                     @Override
                     public void exception(Throwable t) {
                         if (callback != null) {
-                            if (t instanceof DatabaseException) callback.run((DatabaseException) t);
-                            else callback.run(new DatabaseException(t));
+                            if (t instanceof DatabaseException) callback.accept((DatabaseException) t);
+                            else callback.accept(new DatabaseException(t));
                         } else
                             Logger.defaultLogError("Unhandled exception", t);
                     }
@@ -1293,7 +1291,7 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule
 
         try {
 
-            int thread = request.hashCode() & queryProvider2.THREAD_MASK;
+            //int thread = request.hashCode() & queryProvider2.THREAD_MASK;
 
             fireSessionVariableChange(SessionVariables.QUEUED_WRITES);
 
@@ -1358,12 +1356,12 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule
 
     }
 
-    public <T> void scheduleRequest(final WriteOnly request, final Callback<DatabaseException> callback, final Semaphore notify) {
+    public <T> void scheduleRequest(final WriteOnly request, final Consumer<DatabaseException> callback, final Semaphore notify) {
         scheduleRequest(request, callback, notify, null);
     }
 
     @Override
-    public <T> void scheduleRequest(final WriteOnly request, final Callback<DatabaseException> callback, final Semaphore notify, Boolean combine) {
+    public <T> void scheduleRequest(final WriteOnly request, final Consumer<DatabaseException> callback, final Semaphore notify, Boolean combine) {
 
         assertAlive();
 
@@ -1396,12 +1394,12 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule
 
                             @Override
                             public void execute(Object result) {
-                                if(callback != null) callback.run(null);
+                                if(callback != null) callback.accept(null);
                             }
 
                             @Override
                             public void exception(Throwable t) {
-                                if(callback != null) callback.run((DatabaseException)t);
+                                if(callback != null) callback.accept((DatabaseException)t);
                             }
 
                         });
@@ -1424,7 +1422,7 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule
 
                             if(!(e instanceof CancelTransactionException)) {
                                 if (callback != null)
-                                    callback.run(new DatabaseException(e));
+                                    callback.accept(new DatabaseException(e));
                             }
 
                             writeState.except(e);
@@ -1963,14 +1961,7 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule
         assertAlive();
         Semaphore notify = new Semaphore(0);
         final DataContainer<DatabaseException> exception = new DataContainer<DatabaseException>();
-        scheduleRequest(request, new Callback<DatabaseException>() {
-
-            @Override
-            public void run(DatabaseException e) {
-              exception.set(e);
-            }
-
-        }, notify);
+        scheduleRequest(request, e -> exception.set(e), notify);
         acquire(notify, request);
         if(exception.get() != null) throw exception.get();
     }
@@ -2064,12 +2055,7 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule
         assertNotSession();
         Semaphore notify = new Semaphore(0);
         final DataContainer<DatabaseException> exception = new DataContainer<DatabaseException>();
-        scheduleRequest(request, new Callback<DatabaseException>() {
-            @Override
-            public void run(DatabaseException e) {
-                exception.set(e);
-            }
-        }, notify);
+        scheduleRequest(request, e -> exception.set(e), notify);
         acquire(notify, request);
         if(exception.get() != null) throw exception.get();
     }
@@ -2080,12 +2066,7 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule
         assertAlive();
         Semaphore notify = new Semaphore(0);
         final DataContainer<DatabaseException> exception = new DataContainer<DatabaseException>();
-        scheduleRequest(request, new Callback<DatabaseException>() {
-            @Override
-            public void run(DatabaseException e) {
-                exception.set(e);
-            }
-        }, notify);
+        scheduleRequest(request, e -> exception.set(e), notify);
         acquire(notify, request);
         if(exception.get() != null) throw exception.get();
     }
@@ -2117,7 +2098,7 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule
     }
 
     @Override
-    public void asyncRequest(final Write request, final Callback<DatabaseException> callback) {
+    public void asyncRequest(final Write request, final Consumer<DatabaseException> callback) {
 
         scheduleRequest(request, callback, null);
 
@@ -2145,7 +2126,7 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule
     }
 
     @Override
-    public void asyncRequest(final DelayedWrite request, final Callback<DatabaseException> callback) {
+    public void asyncRequest(final DelayedWrite request, final Consumer<DatabaseException> callback) {
 
         scheduleRequest(request, callback, null);
 
@@ -2162,7 +2143,7 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule
     }
 
     @Override
-    public void asyncRequest(final WriteOnly request, final Callback<DatabaseException> callback) {
+    public void asyncRequest(final WriteOnly request, final Consumer<DatabaseException> callback) {
 
         scheduleRequest(request, callback, null);
 
@@ -2286,16 +2267,16 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule
         return true;
     }
 
-    static void loadVirtualStatements(final VirtualGraphServerSupportImpl support, ReadGraphImpl graph, int subject, final Callback<ReadGraphImpl> runnable) {
+    static void loadVirtualStatements(final VirtualGraphServerSupportImpl support, ReadGraphImpl graph, int subject, final Consumer<ReadGraphImpl> runnable) {
 
-        Callback<ReadGraphImpl> composite = new Callback<ReadGraphImpl>() {
+        Consumer<ReadGraphImpl> composite = new Consumer<ReadGraphImpl>() {
 
             AtomicInteger ready = new AtomicInteger(support.providers.size() + 1);
 
             @Override
-            public void run(ReadGraphImpl graph) {
+            public void accept(ReadGraphImpl graph) {
                 if(ready.decrementAndGet() == 0) {
-                    runnable.run(graph);
+                    runnable.accept(graph);
                 }
             }
 
@@ -2309,24 +2290,24 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule
                     e.printStackTrace();
                 }
             } else {
-                composite.run(graph);
+                composite.accept(graph);
             }
         }
 
-        composite.run(graph);
+        composite.accept(graph);
 
     }
 
-    static  void loadVirtualStatements(final VirtualGraphServerSupportImpl support, ReadGraphImpl graph, int subject, int predicate, final Callback<ReadGraphImpl> runnable) {
+    static  void loadVirtualStatements(final VirtualGraphServerSupportImpl support, ReadGraphImpl graph, int subject, int predicate, final Consumer<ReadGraphImpl> runnable) {
 
-        Callback<ReadGraphImpl> composite = new Callback<ReadGraphImpl>() {
+        Consumer<ReadGraphImpl> composite = new Consumer<ReadGraphImpl>() {
 
             AtomicInteger ready = new AtomicInteger(support.providers.size() + 1);
 
             @Override
-            public void run(ReadGraphImpl graph) {
+            public void accept(ReadGraphImpl graph) {
                 if(ready.decrementAndGet() == 0) {
-                    runnable.run(graph);
+                    runnable.accept(graph);
                 }
             }
 
@@ -2340,11 +2321,11 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule
                     e.printStackTrace();
                 }
             } else {
-                composite.run(graph);
+                composite.accept(graph);
             }
         }
 
-        composite.run(graph);
+        composite.accept(graph);
 
     }
 
index d5f5c4308903cdd6aee7d0a5c3dbed5ffe1f40a2..003301e6dfbbed2b3f92b9fb7fc0a457c3442b89 100644 (file)
@@ -31,7 +31,6 @@ import org.simantics.db.exception.ValidationException;
 import org.simantics.db.impl.graph.WriteSupport;
 import org.simantics.db.procore.protocol.Constants;
 import org.simantics.db.request.WriteTraits;
-import org.simantics.db.service.ClusterSetsSupport;
 import org.simantics.db.service.ClusterUID;
 import org.simantics.db.service.ExternalOperation;
 import org.simantics.db.service.TransactionPolicySupport;
index 4b3bf37a5789831d494d490f6cb0b4ca6d55d1fa..aff7e17acf261bee201300c07eb4a656301cc82c 100644 (file)
@@ -3,7 +3,6 @@ package fi.vtt.simantics.procore.internal;
 import java.util.TreeMap;
 
 import org.simantics.db.Metadata;
-import org.simantics.db.Operation;
 import org.simantics.db.Resource;
 import org.simantics.db.VirtualGraph;
 import org.simantics.db.WriteGraph;
@@ -388,7 +387,6 @@ public class WriteSupportImpl implements WriteSupport {
        MetadataUtils.addMetadata(session, metadata, data);
     }
 
-    @SuppressWarnings("unchecked")
     @Override
     public <T extends Metadata> T getMetadata(Class<T> clazz) throws ServiceException {
        return MetadataUtils.getMetadata(session, metadata, clazz);
index 0520ec3e67a709b746b208c507e60a320d790dcb..2d5e462d6d7c692bf2b37cd313fd1d14bb41fd22 100644 (file)
@@ -13,6 +13,7 @@ package org.simantics.db.procore.cluster;
 
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
+import java.util.function.Consumer;
 
 import org.simantics.db.Resource;
 import org.simantics.db.exception.DatabaseException;
@@ -33,7 +34,6 @@ import org.simantics.db.impl.query.QueryProcessor;
 import org.simantics.db.procedure.AsyncContextMultiProcedure;
 import org.simantics.db.procedure.AsyncMultiProcedure;
 import org.simantics.db.service.ClusterUID;
-import org.simantics.utils.datastructures.Callback;
 
 import fi.vtt.simantics.procore.DebugPolicy;
 import fi.vtt.simantics.procore.internal.ClusterChange;
@@ -812,7 +812,7 @@ final public class ClusterBig extends ClusterImpl {
     }
 
     @Override
-    public void load(Callback<DatabaseException> r) {
+    public void load(Consumer<DatabaseException> r) {
         throw new Error("Not supported.");
     }
 
index 4b963f38f9946bc0308f98ca3055056cec991bbe..1b7dc0d32598374fb1b062c26987a580f0ab7964 100644 (file)
@@ -13,6 +13,7 @@ package org.simantics.db.procore.cluster;
 
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
+import java.util.function.Consumer;
 
 import org.simantics.db.Resource;
 import org.simantics.db.exception.DatabaseException;
@@ -32,7 +33,6 @@ import org.simantics.db.procedure.AsyncContextMultiProcedure;
 import org.simantics.db.procedure.AsyncMultiProcedure;
 import org.simantics.db.service.ClusterUID;
 import org.simantics.db.service.ResourceUID;
-import org.simantics.utils.datastructures.Callback;
 
 import fi.vtt.simantics.procore.DebugPolicy;
 import fi.vtt.simantics.procore.internal.ClusterChange;
@@ -940,7 +940,7 @@ final public class ClusterSmall extends ClusterImpl {
     }
 
     @Override
-    public void load(Callback<DatabaseException> r) {
+    public void load(Consumer<DatabaseException> r) {
         if (deleted) return;
         throw new Error("Not supported.");
     }
index cfd7bcc55bfb41b44361e1ecfe28f981579aed6c..46ce55507a1c4e8254cfe1a31e7a760e55a0c84d 100644 (file)
  *******************************************************************************/
 package org.simantics.db.procore.cluster;
 
-import gnu.trove.map.hash.TIntIntHashMap;
-import gnu.trove.procedure.TIntIntProcedure;
-import gnu.trove.set.hash.TIntHashSet;
-
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.exception.ValidationException;
 import org.simantics.db.impl.ClusterBase;
 import org.simantics.db.impl.ClusterI;
-import org.simantics.db.impl.ClusterI.ObjectProcedure;
 import org.simantics.db.impl.ClusterI.PredicateProcedure;
 import org.simantics.db.impl.ClusterI.Procedure;
 import org.simantics.db.impl.ClusterSupport;
@@ -30,6 +25,10 @@ import org.simantics.db.impl.TableIntAllocatorAdapter;
 import org.simantics.db.impl.TableSizeListener;
 import org.simantics.db.procore.cluster.TableIntArraySet2.Tables;
 
+import gnu.trove.map.hash.TIntIntHashMap;
+import gnu.trove.procedure.TIntIntProcedure;
+import gnu.trove.set.hash.TIntHashSet;
+
 public final class PredicateTable extends Table<int[]> {
        
        final TableIntAllocatorAdapter allocator;
index 5ddcca89305e1d1f72f800e12e3fc12995a886ad..440421fc307eac902b0277bd15b056bdc392bb2c 100644 (file)
@@ -16,7 +16,6 @@ import java.util.TreeMap;
 
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.exception.ValidationException;
-import org.simantics.db.impl.ClusterI.ObjectProcedure;
 import org.simantics.db.impl.ClusterI.Procedure;
 import org.simantics.db.impl.ClusterSupport;
 import org.simantics.db.impl.Modifier;
index 814b8637a264d3044a68f7570b609a698b56c0e4..6b57fb9b42c32fd2aef3fa8e5083128e3ff4d36b 100644 (file)
@@ -17,7 +17,6 @@ import java.util.TreeMap;
 
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.exception.ValidationException;
-import org.simantics.db.impl.ClusterI.ObjectProcedure;
 import org.simantics.db.impl.ClusterI.Procedure;
 import org.simantics.db.impl.ClusterSupport;
 import org.simantics.db.impl.Modifier;
index 182d5686268a862044f209bfd89f454e3bd6adc1..429696cda867a078c72ade8baef22733b2786be5 100644 (file)
@@ -11,6 +11,8 @@
  *******************************************************************************/
 package org.simantics.db;
 
+import java.util.function.Consumer;
+
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.procedure.AsyncListener;
 import org.simantics.db.procedure.AsyncMultiListener;
@@ -35,7 +37,6 @@ import org.simantics.db.request.Write;
 import org.simantics.db.request.WriteOnly;
 import org.simantics.db.request.WriteOnlyResult;
 import org.simantics.db.request.WriteResult;
-import org.simantics.utils.datastructures.Callback;
 
 /**
  * 
@@ -472,13 +473,13 @@ public interface AsyncRequestProcessorSpecific extends ServiceLocator {
 
     /**
      * Asynchronously performs the given {@link Write}. The outcome of the
-     * request will be reported to given {@link Callback} in the form of a
+     * request will be reported to given {@link Consumer} in the form of a
      * DatabaseException raised during request processing or null upon success.
      * 
      * @param request an instance of {@link Write}.
-     * @param request an instance of {@link Callback}.
+     * @param request an instance of {@link Consumer}.
      */
-    void asyncRequest(Write request, Callback<DatabaseException> callback);
+    void asyncRequest(Write request, Consumer<DatabaseException> callback);
     
     <T> void asyncRequest(WriteResult<T> r, Procedure<T> procedure);
     
@@ -493,13 +494,13 @@ public interface AsyncRequestProcessorSpecific extends ServiceLocator {
 
     /**
      * Asynchronously performs the given {@link WriteOnly}. The outcome of the
-     * request will be reported to given {@link Callback} in the form of a
+     * request will be reported to given {@link Consumer} in the form of a
      * DatabaseException raised during request processing or null upon success.
      * 
      * @param request an instance of {@link WriteOnly}.
-     * @param request an instance of {@link Callback}.
+     * @param request an instance of {@link Consumer}.
      */
-    void asyncRequest(DelayedWrite request, Callback<DatabaseException> callback);
+    void asyncRequest(DelayedWrite request, Consumer<DatabaseException> callback);
 
     <T> void asyncRequest(DelayedWriteResult<T> r, Procedure<T> procedure);
 
@@ -513,13 +514,13 @@ public interface AsyncRequestProcessorSpecific extends ServiceLocator {
 
     /**
      * Asynchronously performs the given {@link WriteOnly}. The outcome of the
-     * request will be reported to given {@link Callback} in the form of a
+     * request will be reported to given {@link Consumer} in the form of a
      * DatabaseException raised during request processing or null upon success.
      * 
      * @param request an instance of {@link WriteOnly}.
-     * @param request an instance of {@link Callback}.
+     * @param request an instance of {@link Consumer}.
      */
-    void asyncRequest(WriteOnly r, Callback<DatabaseException> callback);
+    void asyncRequest(WriteOnly r, Consumer<DatabaseException> callback);
     
     <T> void asyncRequest(WriteOnlyResult<T> r, Procedure<T> procedure);