From: Tuukka Lehtonen Date: Fri, 1 Dec 2017 09:38:23 +0000 (+0200) Subject: Use java.util.Consumer instead of os.utils.datastructures.Callback X-Git-Tag: v1.31.0~12 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=56a799c9b7d395cefb59e101cd0f7ce8d68f88e6;p=simantics%2Fplatform.git Use java.util.Consumer instead of os.utils.datastructures.Callback This removes lots of deprecation warnings from the DB codebase. refs #7655 Change-Id: Ibdfbac83c69d5af3823a28447256176183ab335a --- diff --git a/bundles/org.simantics.acorn/src/org/simantics/acorn/Persistable.java b/bundles/org.simantics.acorn/src/org/simantics/acorn/Persistable.java index 86dfdd435..89574faab 100644 --- a/bundles/org.simantics.acorn/src/org/simantics/acorn/Persistable.java +++ b/bundles/org.simantics.acorn/src/org/simantics/acorn/Persistable.java @@ -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 { diff --git a/bundles/org.simantics.acorn/src/org/simantics/acorn/cluster/ClusterBig.java b/bundles/org.simantics.acorn/src/org/simantics/acorn/cluster/ClusterBig.java index 51241728d..1de4006a7 100644 --- a/bundles/org.simantics.acorn/src/org/simantics/acorn/cluster/ClusterBig.java +++ b/bundles/org.simantics.acorn/src/org/simantics/acorn/cluster/ClusterBig.java @@ -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 r) { + public void load(Consumer r) { throw new Error("Not supported."); } diff --git a/bundles/org.simantics.acorn/src/org/simantics/acorn/cluster/ClusterSmall.java b/bundles/org.simantics.acorn/src/org/simantics/acorn/cluster/ClusterSmall.java index b84d4d51f..117ab75a3 100644 --- a/bundles/org.simantics.acorn/src/org/simantics/acorn/cluster/ClusterSmall.java +++ b/bundles/org.simantics.acorn/src/org/simantics/acorn/cluster/ClusterSmall.java @@ -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 r) { + public void load(Consumer 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; } diff --git a/bundles/org.simantics.acorn/src/org/simantics/acorn/internal/ClusterStream.java b/bundles/org.simantics.acorn/src/org/simantics/acorn/internal/ClusterStream.java index 2b1ae1979..078a4dabb 100644 --- a/bundles/org.simantics.acorn/src/org/simantics/acorn/internal/ClusterStream.java +++ b/bundles/org.simantics.acorn/src/org/simantics/acorn/internal/ClusterStream.java @@ -11,11 +11,6 @@ *******************************************************************************/ 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; diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/processor/MergingGraphRequestProcessor.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/processor/MergingGraphRequestProcessor.java index 5e07bb034..bf72e0416 100644 --- a/bundles/org.simantics.db.common/src/org/simantics/db/common/processor/MergingGraphRequestProcessor.java +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/processor/MergingGraphRequestProcessor.java @@ -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 callback = (Callback)currentRequest.second; + Consumer callback = (Consumer)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 callback) { + public synchronized void asyncRequest(Write request, Consumer 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 callback) { + public synchronized void asyncRequest(DelayedWrite request, Consumer 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 callback) { + public synchronized void asyncRequest(WriteOnly request, Consumer callback) { // System.out.println(this + " asyncRequest(WriteGraphRequest request)"); diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/processor/ProcessorBase.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/processor/ProcessorBase.java index d8d3cdbf1..6e1aeabaa 100644 --- a/bundles/org.simantics.db.common/src/org/simantics/db/common/processor/ProcessorBase.java +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/processor/ProcessorBase.java @@ -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 callback) { + public void asyncRequest(Write request, Consumer callback) { throw new UnsupportedOperationException(); } @Override - public void asyncRequest(DelayedWrite request, Callback callback) { + public void asyncRequest(DelayedWrite request, Consumer callback) { throw new UnsupportedOperationException(); } @Override - public void asyncRequest(WriteOnly request, Callback callback) { + public void asyncRequest(WriteOnly request, Consumer callback) { throw new UnsupportedOperationException(); } diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/ClusterI.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/ClusterI.java index d3b24eb3e..87acea43d 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/ClusterI.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/ClusterI.java @@ -12,13 +12,13 @@ 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 callback); + public void load(Consumer callback); public void load(ClusterSupport session, Runnable callback); diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/TransientGraph.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/TransientGraph.java index 3a552ed19..f4e722fe5 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/TransientGraph.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/TransientGraph.java @@ -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 callback) throws DatabaseException { + public void load(ReadGraphImpl graph, int resource, int predicate, final Consumer callback) throws DatabaseException { producePartialStatements(graph, resource, predicate, new AsyncProcedure() { @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 callback) throws DatabaseException { + public void load(ReadGraphImpl graph, int resource, final Consumer callback) throws DatabaseException { produceAllStatements(graph, resource, new AsyncProcedure() { @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); } }); diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/VirtualGraphImpl.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/VirtualGraphImpl.java index 4fd4e9a45..17503977e 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/VirtualGraphImpl.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/VirtualGraphImpl.java @@ -11,10 +11,11 @@ *******************************************************************************/ 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 callback) throws DatabaseException; - public void load(ReadGraphImpl graph, int resource, Callback callback) throws DatabaseException; + public void load(ReadGraphImpl graph, int resource, int predicate, Consumer callback) throws DatabaseException; + public void load(ReadGraphImpl graph, int resource, Consumer callback) throws DatabaseException; } diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/ReadGraphImpl.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/ReadGraphImpl.java index 9b6d74044..b853ed519 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/ReadGraphImpl.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/ReadGraphImpl.java @@ -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 callback) { + public void asyncRequest(Write request, Consumer callback) { assert (request != null); @@ -5936,7 +5936,7 @@ public class ReadGraphImpl implements ReadGraph { @Override public void asyncRequest(DelayedWrite r, - Callback callback) { + Consumer callback) { throw new Error("Not implemented."); } @@ -5955,7 +5955,7 @@ public class ReadGraphImpl implements ReadGraph { } @Override - public void asyncRequest(WriteOnly r, Callback callback) { + public void asyncRequest(WriteOnly r, Consumer callback) { throw new Error("Not implemented."); } diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/WriteGraphImpl.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/WriteGraphImpl.java index f640513c6..ca485f989 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/WriteGraphImpl.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/WriteGraphImpl.java @@ -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() { - - @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 callback) { + public void asyncRequest(DelayedWrite request, Consumer 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() { - - @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 callback) { + public void asyncRequest(Write request, Consumer 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() { - - @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 callback) { + public void asyncRequest(WriteOnly request, Consumer callback) { assert (request != null); getWriteRequestScheduler().scheduleRequest(request, callback, null, Boolean.TRUE); } diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/support/WriteRequestScheduleSupport.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/support/WriteRequestScheduleSupport.java index 30fa049d9..c44c2b91d 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/support/WriteRequestScheduleSupport.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/support/WriteRequestScheduleSupport.java @@ -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 { - void scheduleRequest(DelayedWrite request, Callback callback, Semaphore notify, + void scheduleRequest(DelayedWrite request, Consumer callback, Semaphore notify, Boolean combine); void scheduleRequest(DelayedWriteResult request, Procedure procedure, Semaphore notify, Boolean combine); - void scheduleRequest(Write request, Callback callback, Semaphore notify, Boolean combine); + void scheduleRequest(Write request, Consumer callback, Semaphore notify, Boolean combine); - void scheduleRequest(WriteOnly request, Callback callback, Semaphore notify, Boolean combine); + void scheduleRequest(WriteOnly request, Consumer callback, Semaphore notify, Boolean combine); void scheduleRequest(WriteOnlyResult request, Procedure callback, Semaphore notify, Boolean combine); diff --git a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterWriteOnly.java b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterWriteOnly.java index 17008c963..f7e3a20cf 100644 --- a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterWriteOnly.java +++ b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterWriteOnly.java @@ -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 r) { + public void load(Consumer r) { } @Override diff --git a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/DirectQuerySupportImpl.java b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/DirectQuerySupportImpl.java index 9d6b019e4..a0f6c1d1e 100644 --- a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/DirectQuerySupportImpl.java +++ b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/DirectQuerySupportImpl.java @@ -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() { - - @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() { - - @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() { - - @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() { - - @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() { - - @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() { - - @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() { - - @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() { - - @Override - public void run(ReadGraphImpl graph) { - getRelatedValue4(graph, subject, procedure); - } - - }); + SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject, predicate, + g -> getRelatedValue4(graph, subject, procedure) + ); return; } diff --git a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/NewStatementImpl.java b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/NewStatementImpl.java index 77cda628a..518be61d4 100644 --- a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/NewStatementImpl.java +++ b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/NewStatementImpl.java @@ -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; diff --git a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/QueryDebugImpl.java b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/QueryDebugImpl.java index 7a6421768..e3f738339 100644 --- a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/QueryDebugImpl.java +++ b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/QueryDebugImpl.java @@ -20,7 +20,7 @@ public class QueryDebugImpl implements QueryDebug { } @Override - public Set getParents(AsyncRead request) { + public Set getParents(AsyncRead request) { HashSet result = new HashSet(); CacheEntryBase entry = session.queryProvider2.asyncReadMap.get(request); if(entry != null) { @@ -30,7 +30,7 @@ public class QueryDebugImpl implements QueryDebug { } @Override - public Set getParents(AsyncMultiRead request) { + public Set getParents(AsyncMultiRead request) { HashSet result = new HashSet(); CacheEntryBase entry = session.queryProvider2.asyncMultiReadMap.get(request); if(entry != null) { @@ -40,7 +40,7 @@ public class QueryDebugImpl implements QueryDebug { } @Override - public Set getParents(Read request) { + public Set getParents(Read request) { HashSet result = new HashSet(); CacheEntryBase entry = session.queryProvider2.readMap.get(request); if(entry != null) { @@ -50,7 +50,7 @@ public class QueryDebugImpl implements QueryDebug { } @Override - public Set getParents(MultiRead request) { + public Set getParents(MultiRead request) { HashSet result = new HashSet(); CacheEntryBase entry = session.queryProvider2.multiReadMap.get(request); if(entry != null) { diff --git a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/QuerySupportImpl.java b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/QuerySupportImpl.java index 1d3563fc1..190db364c 100644 --- a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/QuerySupportImpl.java +++ b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/QuerySupportImpl.java @@ -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 { + class CallbackAdapter implements Consumer { 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() { - - @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() { - - @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() { - - @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() { - - @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() { - - @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() { - - @Override - public void run(ReadGraphImpl parameter) { - } - - }); + SessionImplSocket.loadVirtualStatements(virtualGraphServerSupport, graph, subject, g -> {}); } else { diff --git a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/SessionImplSocket.java b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/SessionImplSocket.java index 2ff47c292..9a86dc1fa 100644 --- a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/SessionImplSocket.java +++ b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/SessionImplSocket.java @@ -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 callback = new Callback() { - @Override - public void run(DatabaseException e) { - synchronized (TaskHelper.this) { - throwable = e; - } + final Consumer callback = e -> { + synchronized (TaskHelper.this) { + throwable = e; } }; final Procedure proc = new Procedure() { @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 getResult() { return (T)result; } @@ -387,7 +385,7 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule return null; } - public void scheduleRequest(final Write request, final Callback callback, final Semaphore notify) { + public void scheduleRequest(final Write request, final Consumer 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 void scheduleRequest(final Write request, final Callback callback, final Semaphore notify, Boolean combine) { + public void scheduleRequest(final Write request, final Consumer 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 void scheduleRequest(final DelayedWrite request, final Callback callback, final Semaphore notify) { + public void scheduleRequest(final DelayedWrite request, final Consumer 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 void scheduleRequest(final DelayedWrite request, final Callback callback, final Semaphore notify, Boolean combine) { + public void scheduleRequest(final DelayedWrite request, final Consumer 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 void scheduleRequest(final WriteOnly request, final Callback callback, final Semaphore notify) { + public void scheduleRequest(final WriteOnly request, final Consumer callback, final Semaphore notify) { scheduleRequest(request, callback, notify, null); } @Override - public void scheduleRequest(final WriteOnly request, final Callback callback, final Semaphore notify, Boolean combine) { + public void scheduleRequest(final WriteOnly request, final Consumer 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 exception = new DataContainer(); - scheduleRequest(request, new Callback() { - - @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 exception = new DataContainer(); - scheduleRequest(request, new Callback() { - @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 exception = new DataContainer(); - scheduleRequest(request, new Callback() { - @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 callback) { + public void asyncRequest(final Write request, final Consumer 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 callback) { + public void asyncRequest(final DelayedWrite request, final Consumer 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 callback) { + public void asyncRequest(final WriteOnly request, final Consumer 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 runnable) { + static void loadVirtualStatements(final VirtualGraphServerSupportImpl support, ReadGraphImpl graph, int subject, final Consumer runnable) { - Callback composite = new Callback() { + Consumer composite = new Consumer() { 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 runnable) { + static void loadVirtualStatements(final VirtualGraphServerSupportImpl support, ReadGraphImpl graph, int subject, int predicate, final Consumer runnable) { - Callback composite = new Callback() { + Consumer composite = new Consumer() { 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); } diff --git a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/TransactionToken.java b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/TransactionToken.java index d5f5c4308..003301e6d 100644 --- a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/TransactionToken.java +++ b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/TransactionToken.java @@ -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; diff --git a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/WriteSupportImpl.java b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/WriteSupportImpl.java index 4b3bf37a5..aff7e17ac 100644 --- a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/WriteSupportImpl.java +++ b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/WriteSupportImpl.java @@ -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 getMetadata(Class clazz) throws ServiceException { return MetadataUtils.getMetadata(session, metadata, clazz); diff --git a/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ClusterBig.java b/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ClusterBig.java index 0520ec3e6..2d5e462d6 100644 --- a/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ClusterBig.java +++ b/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ClusterBig.java @@ -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 r) { + public void load(Consumer r) { throw new Error("Not supported."); } diff --git a/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ClusterSmall.java b/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ClusterSmall.java index 4b963f38f..1b7dc0d32 100644 --- a/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ClusterSmall.java +++ b/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ClusterSmall.java @@ -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 r) { + public void load(Consumer r) { if (deleted) return; throw new Error("Not supported."); } diff --git a/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/PredicateTable.java b/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/PredicateTable.java index cfd7bcc55..46ce55507 100644 --- a/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/PredicateTable.java +++ b/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/PredicateTable.java @@ -11,15 +11,10 @@ *******************************************************************************/ 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 { final TableIntAllocatorAdapter allocator; diff --git a/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ValueTable.java b/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ValueTable.java index 5ddcca893..440421fc3 100644 --- a/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ValueTable.java +++ b/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ValueTable.java @@ -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; diff --git a/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ValueTableSmall.java b/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ValueTableSmall.java index 814b8637a..6b57fb9b4 100644 --- a/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ValueTableSmall.java +++ b/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ValueTableSmall.java @@ -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; diff --git a/bundles/org.simantics.db/src/org/simantics/db/AsyncRequestProcessorSpecific.java b/bundles/org.simantics.db/src/org/simantics/db/AsyncRequestProcessorSpecific.java index 182d56862..429696cda 100644 --- a/bundles/org.simantics.db/src/org/simantics/db/AsyncRequestProcessorSpecific.java +++ b/bundles/org.simantics.db/src/org/simantics/db/AsyncRequestProcessorSpecific.java @@ -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 callback); + void asyncRequest(Write request, Consumer callback); void asyncRequest(WriteResult r, Procedure 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 callback); + void asyncRequest(DelayedWrite request, Consumer callback); void asyncRequest(DelayedWriteResult r, Procedure 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 callback); + void asyncRequest(WriteOnly r, Consumer callback); void asyncRequest(WriteOnlyResult r, Procedure procedure);