From d33a5a61e2c056a3d48733819257890406ee9d52 Mon Sep 17 00:00:00 2001 From: jsimomaa Date: Tue, 24 Jan 2017 15:34:00 +0200 Subject: [PATCH] Make Write-interfaces as @FunctionalInterface for lambdas refs #6998 Change-Id: I7552f2f13c6a034296249b4ebe8909269419ecac --- .../processor/MergingGraphRequestProcessor.java | 16 ---------------- .../db/common/request/DelayedWriteRequest.java | 11 ----------- .../request/DelayedWriteResultRequest.java | 6 ------ .../db/common/request/WriteOnlyRequest.java | 6 ------ .../common/request/WriteOnlyResultRequest.java | 6 ------ .../db/common/request/WriteRequest.java | 6 ------ .../db/common/request/WriteResultRequest.java | 6 ------ .../simantics/db/common/utils/Transaction.java | 10 ---------- .../request/DefaultInstanceFactoryRequest.java | 12 ------------ .../procore/internal/SessionImplSocket.java | 12 +----------- .../org/simantics/db/request/DelayedWrite.java | 3 --- .../src/org/simantics/db/request/Write.java | 1 + .../src/org/simantics/db/request/WriteOnly.java | 1 + .../simantics/db/request/WriteOnlyResult.java | 1 + .../org/simantics/db/request/WriteResult.java | 3 ++- .../org/simantics/db/request/WriteTraits.java | 11 +++-------- 16 files changed, 9 insertions(+), 102 deletions(-) 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 acd2aad02..5e07bb034 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 @@ -26,7 +26,6 @@ import org.simantics.db.ReadGraph; import org.simantics.db.RequestProcessor; import org.simantics.db.Resource; import org.simantics.db.Session; -import org.simantics.db.VirtualGraph; import org.simantics.db.WriteGraph; import org.simantics.db.common.procedure.adapter.AsyncMultiProcedureAdapter; import org.simantics.db.common.procedure.adapter.ProcedureAdapter; @@ -56,7 +55,6 @@ import org.simantics.db.request.ExternalRead; import org.simantics.db.request.MultiRead; import org.simantics.db.request.Read; import org.simantics.db.request.ReadInterface; -import org.simantics.db.request.UndoTraits; import org.simantics.db.request.Write; import org.simantics.db.request.WriteInterface; import org.simantics.db.request.WriteOnly; @@ -126,15 +124,6 @@ public class MergingGraphRequestProcessor implements RequestProcessor { throw new RuntimeException("See cause for the real exception.", exception); } - @Override - public VirtualGraph getProvider() { - return null; - } - -// @Override -// public void fillMetadata(Map metadata) { -// } - public void acquire() { try { semaphore.acquire(); @@ -147,11 +136,6 @@ public class MergingGraphRequestProcessor implements RequestProcessor { semaphore.release(); } - @Override - public UndoTraits getUndoTraits() { - return null; - } - @Override public String toString() { return "SyncWriteRequestAdapter " + request; diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/request/DelayedWriteRequest.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/DelayedWriteRequest.java index 7194d9a95..044e91acc 100644 --- a/bundles/org.simantics.db.common/src/org/simantics/db/common/request/DelayedWriteRequest.java +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/DelayedWriteRequest.java @@ -17,7 +17,6 @@ import org.simantics.db.AsyncRequestProcessor; import org.simantics.db.ChangeSetIdentifier; import org.simantics.db.Operation; import org.simantics.db.RequestProcessor; -import org.simantics.db.VirtualGraph; import org.simantics.db.exception.DatabaseException; import org.simantics.db.procedure.Procedure; import org.simantics.db.request.DelayedWrite; @@ -75,16 +74,6 @@ import org.simantics.utils.datastructures.Callback; */ public abstract class DelayedWriteRequest implements DelayedWrite, UndoTraits, WriteInterface { - @Override - public VirtualGraph getProvider() { - return null; - } - - @Override - public UndoTraits getUndoTraits() { - return this; - } - @Override public ChangeSetIdentifier getIdentifier() { return null; diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/request/DelayedWriteResultRequest.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/DelayedWriteResultRequest.java index 94bd4c04b..05bec870e 100644 --- a/bundles/org.simantics.db.common/src/org/simantics/db/common/request/DelayedWriteResultRequest.java +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/DelayedWriteResultRequest.java @@ -17,7 +17,6 @@ import org.simantics.db.VirtualGraph; import org.simantics.db.exception.DatabaseException; import org.simantics.db.procedure.Procedure; import org.simantics.db.request.DelayedWriteResult; -import org.simantics.db.request.UndoTraits; import org.simantics.db.request.WriteInterface; import org.simantics.db.request.WriteTraits; @@ -85,11 +84,6 @@ public abstract class DelayedWriteResultRequest implements DelayedWriteResult final public VirtualGraph getProvider() { return provider; } - - @Override - public UndoTraits getUndoTraits() { - return null; - } @Override public void request(AsyncRequestProcessor processor, final Procedure procedure) { diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/request/WriteOnlyRequest.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/WriteOnlyRequest.java index 03a4b4211..654bf32bf 100644 --- a/bundles/org.simantics.db.common/src/org/simantics/db/common/request/WriteOnlyRequest.java +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/WriteOnlyRequest.java @@ -16,7 +16,6 @@ import org.simantics.db.RequestProcessor; import org.simantics.db.VirtualGraph; import org.simantics.db.exception.DatabaseException; import org.simantics.db.procedure.Procedure; -import org.simantics.db.request.UndoTraits; import org.simantics.db.request.WriteInterface; import org.simantics.db.request.WriteOnly; import org.simantics.utils.datastructures.Callback; @@ -88,11 +87,6 @@ public abstract class WriteOnlyRequest implements WriteOnly, WriteInterface procedure) { processor.asyncRequest(this, new Callback() { diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/request/WriteOnlyResultRequest.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/WriteOnlyResultRequest.java index d9fc13515..37978441b 100644 --- a/bundles/org.simantics.db.common/src/org/simantics/db/common/request/WriteOnlyResultRequest.java +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/WriteOnlyResultRequest.java @@ -16,7 +16,6 @@ import org.simantics.db.RequestProcessor; import org.simantics.db.VirtualGraph; import org.simantics.db.exception.DatabaseException; import org.simantics.db.procedure.Procedure; -import org.simantics.db.request.UndoTraits; import org.simantics.db.request.WriteInterface; import org.simantics.db.request.WriteOnlyResult; @@ -84,11 +83,6 @@ public abstract class WriteOnlyResultRequest implements WriteOnlyResult, W final public VirtualGraph getProvider() { return provider; } - - @Override - public UndoTraits getUndoTraits() { - return null; - } @Override public void request(AsyncRequestProcessor processor, final Procedure procedure) { diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/request/WriteRequest.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/WriteRequest.java index 018542474..cb9460d13 100644 --- a/bundles/org.simantics.db.common/src/org/simantics/db/common/request/WriteRequest.java +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/WriteRequest.java @@ -93,12 +93,6 @@ public abstract class WriteRequest implements Write, UndoTraits, WriteInterface< return provider; } - @Override - public UndoTraits getUndoTraits() { - return this; - } - - @Override public void request(AsyncRequestProcessor processor, final Procedure procedure) { processor.asyncRequest(this, new Callback() { diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/request/WriteResultRequest.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/WriteResultRequest.java index 7f95eaba3..d3c2373e8 100644 --- a/bundles/org.simantics.db.common/src/org/simantics/db/common/request/WriteResultRequest.java +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/WriteResultRequest.java @@ -16,7 +16,6 @@ import org.simantics.db.RequestProcessor; import org.simantics.db.VirtualGraph; import org.simantics.db.exception.DatabaseException; import org.simantics.db.procedure.Procedure; -import org.simantics.db.request.UndoTraits; import org.simantics.db.request.WriteInterface; import org.simantics.db.request.WriteResult; @@ -84,11 +83,6 @@ public abstract class WriteResultRequest implements WriteResult, WriteInte final public VirtualGraph getProvider() { return provider; } - - @Override - public UndoTraits getUndoTraits() { - return null; - } @Override public void request(AsyncRequestProcessor processor, final Procedure procedure) { diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/utils/Transaction.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/utils/Transaction.java index 75020215d..0a8dcea41 100644 --- a/bundles/org.simantics.db.common/src/org/simantics/db/common/utils/Transaction.java +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/utils/Transaction.java @@ -21,7 +21,6 @@ import org.simantics.db.ReadGraph; import org.simantics.db.RequestProcessor; import org.simantics.db.Resource; import org.simantics.db.Statement; -import org.simantics.db.VirtualGraph; import org.simantics.db.WriteGraph; import org.simantics.db.WriteOnlyGraph; import org.simantics.db.common.request.DelayedWriteRequest; @@ -40,7 +39,6 @@ import org.simantics.db.exception.ValidationException; import org.simantics.db.procedure.Procedure; import org.simantics.db.request.DelayedWrite; import org.simantics.db.request.Read; -import org.simantics.db.request.UndoTraits; import org.simantics.db.request.Write; import org.simantics.utils.datastructures.Callback; @@ -238,14 +236,6 @@ public class Transaction { } if (!t.commit) throw new CancelTransactionException(); } - @Override - public UndoTraits getUndoTraits() { - return null; - } - @Override - public VirtualGraph getProvider() { - return null; - } }; processor.asyncRequest( request, callback ); diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/DefaultInstanceFactoryRequest.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/DefaultInstanceFactoryRequest.java index 48ee1aac7..fa9d64d8e 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/DefaultInstanceFactoryRequest.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/DefaultInstanceFactoryRequest.java @@ -16,11 +16,9 @@ import java.util.HashSet; import java.util.Map; import org.simantics.db.Resource; -import org.simantics.db.VirtualGraph; import org.simantics.db.WriteGraph; import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.adapter.Template; -import org.simantics.db.request.UndoTraits; import org.simantics.db.request.WriteResult; import org.simantics.layer0.Layer0; @@ -59,14 +57,4 @@ public class DefaultInstanceFactoryRequest implements WriteResult metadata); } diff --git a/bundles/org.simantics.db/src/org/simantics/db/request/Write.java b/bundles/org.simantics.db/src/org/simantics/db/request/Write.java index f46c7c6e7..66b692ebf 100644 --- a/bundles/org.simantics.db/src/org/simantics/db/request/Write.java +++ b/bundles/org.simantics.db/src/org/simantics/db/request/Write.java @@ -62,6 +62,7 @@ import org.simantics.db.exception.DatabaseException; * @see WriteResult * @see Session */ +@FunctionalInterface public interface Write extends WriteTraits { /** diff --git a/bundles/org.simantics.db/src/org/simantics/db/request/WriteOnly.java b/bundles/org.simantics.db/src/org/simantics/db/request/WriteOnly.java index a74255bf0..5422b5707 100644 --- a/bundles/org.simantics.db/src/org/simantics/db/request/WriteOnly.java +++ b/bundles/org.simantics.db/src/org/simantics/db/request/WriteOnly.java @@ -67,6 +67,7 @@ import org.simantics.db.exception.DatabaseException; * @see Session * @see SimpleGraphRequest */ +@FunctionalInterface public interface WriteOnly extends WriteTraits { /** diff --git a/bundles/org.simantics.db/src/org/simantics/db/request/WriteOnlyResult.java b/bundles/org.simantics.db/src/org/simantics/db/request/WriteOnlyResult.java index e7f37f632..502c84d18 100644 --- a/bundles/org.simantics.db/src/org/simantics/db/request/WriteOnlyResult.java +++ b/bundles/org.simantics.db/src/org/simantics/db/request/WriteOnlyResult.java @@ -65,6 +65,7 @@ import org.simantics.db.exception.DatabaseException; * @see Session * @see SimpleGraphRequest */ +@FunctionalInterface public interface WriteOnlyResult extends WriteTraits { /** diff --git a/bundles/org.simantics.db/src/org/simantics/db/request/WriteResult.java b/bundles/org.simantics.db/src/org/simantics/db/request/WriteResult.java index 8134b4e28..18f6a1e3d 100644 --- a/bundles/org.simantics.db/src/org/simantics/db/request/WriteResult.java +++ b/bundles/org.simantics.db/src/org/simantics/db/request/WriteResult.java @@ -65,6 +65,7 @@ import org.simantics.db.exception.DatabaseException; * @see Session * @see SimpleGraphRequest */ +@FunctionalInterface public interface WriteResult extends WriteTraits { /** @@ -91,5 +92,5 @@ public interface WriteResult extends WriteTraits { * be cancelled and any changes rolled back */ T perform(WriteGraph graph) throws DatabaseException; - + } diff --git a/bundles/org.simantics.db/src/org/simantics/db/request/WriteTraits.java b/bundles/org.simantics.db/src/org/simantics/db/request/WriteTraits.java index d0738e0a2..16b4e793d 100644 --- a/bundles/org.simantics.db/src/org/simantics/db/request/WriteTraits.java +++ b/bundles/org.simantics.db/src/org/simantics/db/request/WriteTraits.java @@ -15,12 +15,7 @@ import org.simantics.db.VirtualGraph; public interface WriteTraits { - /** - * If this request is undoable it should return UndoTraits interface. - * - * @return null or UndoTraits interface. - */ - UndoTraits getUndoTraits(); - - VirtualGraph getProvider(); + default VirtualGraph getProvider() { + return null; + } } -- 2.47.1