]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Make Write-interfaces as @FunctionalInterface for lambdas 90/290/1
authorjsimomaa <jani.simomaa@gmail.com>
Tue, 24 Jan 2017 13:34:00 +0000 (15:34 +0200)
committerjsimomaa <jani.simomaa@gmail.com>
Tue, 24 Jan 2017 13:50:43 +0000 (15:50 +0200)
refs #6998

Change-Id: I7552f2f13c6a034296249b4ebe8909269419ecac

16 files changed:
bundles/org.simantics.db.common/src/org/simantics/db/common/processor/MergingGraphRequestProcessor.java
bundles/org.simantics.db.common/src/org/simantics/db/common/request/DelayedWriteRequest.java
bundles/org.simantics.db.common/src/org/simantics/db/common/request/DelayedWriteResultRequest.java
bundles/org.simantics.db.common/src/org/simantics/db/common/request/WriteOnlyRequest.java
bundles/org.simantics.db.common/src/org/simantics/db/common/request/WriteOnlyResultRequest.java
bundles/org.simantics.db.common/src/org/simantics/db/common/request/WriteRequest.java
bundles/org.simantics.db.common/src/org/simantics/db/common/request/WriteResultRequest.java
bundles/org.simantics.db.common/src/org/simantics/db/common/utils/Transaction.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/DefaultInstanceFactoryRequest.java
bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/SessionImplSocket.java
bundles/org.simantics.db/src/org/simantics/db/request/DelayedWrite.java
bundles/org.simantics.db/src/org/simantics/db/request/Write.java
bundles/org.simantics.db/src/org/simantics/db/request/WriteOnly.java
bundles/org.simantics.db/src/org/simantics/db/request/WriteOnlyResult.java
bundles/org.simantics.db/src/org/simantics/db/request/WriteResult.java
bundles/org.simantics.db/src/org/simantics/db/request/WriteTraits.java

index acd2aad02c909e40a66eb22c406923aad39c0471..5e07bb034ecb924adc8567f99f09990e141e69ed 100644 (file)
@@ -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<String, String> 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;
index 7194d9a955281608767d3dbde532e9399f6e2c63..044e91acc7e6e9922158f3b18d833f99846daae1 100644 (file)
@@ -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<Object> {
 
-       @Override
-    public VirtualGraph getProvider() {
-        return null;
-    }
-    
-    @Override
-    public UndoTraits getUndoTraits() {
-        return this;
-    }
-    
     @Override
     public ChangeSetIdentifier getIdentifier() {
        return null;
index 94bd4c04ba1cb3cdc9cf8607ba9d7bd55e832040..05bec870e9eb0b7d709614d0619347c3a9d7e4aa 100644 (file)
@@ -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<T> implements DelayedWriteResult
     final public VirtualGraph getProvider() {
         return provider;
     }
-    
-    @Override
-    public UndoTraits getUndoTraits() {
-       return null;
-    }
 
     @Override
     public void request(AsyncRequestProcessor processor, final Procedure<T> procedure) {
index 03a4b4211352ff91c2c0ba9ff1b955bcc62842f9..654bf32bf2baf2861bf274d21263cba66e249a25 100644 (file)
@@ -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<Obje
         return provider;
     }
 
-    @Override
-    public UndoTraits getUndoTraits() {
-        return null;
-    }
-
     @Override
     public void request(AsyncRequestProcessor processor, final Procedure<Object> procedure) {
        processor.asyncRequest(this, new Callback<DatabaseException>() {
index d9fc13515fbb6b2451a98c1a478cffc78ff3ea72..37978441bf9d41297f49013d48e9ca52a1548332 100644 (file)
@@ -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<T> implements WriteOnlyResult<T>, W
     final public VirtualGraph getProvider() {
         return provider;
     }
-    
-    @Override
-    public UndoTraits getUndoTraits() {
-       return null;
-    }
 
     @Override
     public void request(AsyncRequestProcessor processor, final Procedure<T> procedure) {
index 01854247444353e712525763fd4bb2e4b2252f12..cb9460d13a2b49286b8b554683be9a81157122e7 100644 (file)
@@ -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<Object> procedure) {
        processor.asyncRequest(this, new Callback<DatabaseException>() {
index 7f95eaba3d6bdc641ad22bce97be5c579a7f11b7..d3c2373e892dd836e151c2f01819afffb3b34056 100644 (file)
@@ -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<T> implements WriteResult<T>, WriteInte
     final public VirtualGraph getProvider() {
         return provider;
     }
-    
-    @Override
-    public UndoTraits getUndoTraits() {
-       return null;
-    }
 
     @Override
     public void request(AsyncRequestProcessor processor, final Procedure<T> procedure) {
index 75020215d686d00c79fd72a870c00e3184c7be60..0a8dcea413295cdf1cd436d6a2b04995f4642b39 100644 (file)
@@ -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 );
index 48ee1aac7f0a0b806fd1cf31a594ae116f95b286..fa9d64d8e7677e0a653117231c209bc7d32704a8 100644 (file)
@@ -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<Map<String, Ob
                return parameters;
                
        }
-
-       @Override
-       public UndoTraits getUndoTraits() {
-               return null;
-       }
-
-       @Override
-       public VirtualGraph getProvider() {
-               return null;
-       }
 }
index 6c3497f1569b4040ae10200e8a78d1a913bc7cdc..80dc3b9bbbbea42e31c1ee3fdc09f613e4753ec1 100644 (file)
@@ -118,7 +118,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;
@@ -346,16 +345,7 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule
                     callback.run(new DatabaseException("" + name + "operation failed.", t));
             }
         };
-        final WriteTraits writeTraits = new WriteTraits() {
-            @Override
-            public UndoTraits getUndoTraits() {
-                return null;
-            }
-            @Override
-            public VirtualGraph getProvider() {
-                return null;
-            }
-        };
+        final WriteTraits writeTraits = new WriteTraits() {};
         TaskHelper(String name) {
             this.name = name;
         }
index 22d68e19a42e3a7d314c72bf371f0adfea3bb708..46f2764bf37de53136747acbce60430056d7927b 100644 (file)
@@ -15,7 +15,6 @@ import java.util.Map;
 
 import org.simantics.db.ChangeSetIdentifier;
 import org.simantics.db.Session;
-import org.simantics.db.VirtualGraph;
 import org.simantics.db.WriteGraph;
 import org.simantics.db.exception.CancelTransactionException;
 import org.simantics.db.exception.DatabaseException;
@@ -98,7 +97,5 @@ public interface DelayedWrite extends WriteTraits {
     
     ChangeSetIdentifier getIdentifier();
     
-    VirtualGraph getProvider();
-    
     void fillMetadata(Map<String, String> metadata);
 }
index f46c7c6e749b730e7060dd05e46a99d2cdac1646..66b692ebf471d75e0a1eda147f669385181f7d11 100644 (file)
@@ -62,6 +62,7 @@ import org.simantics.db.exception.DatabaseException;
  * @see WriteResult
  * @see Session
  */
+@FunctionalInterface
 public interface Write extends WriteTraits {
 
     /**
index a74255bf0e766682cb52aebf836e98a74bf58020..5422b57078d15024e44e0c8f6e227df8f88cc962 100644 (file)
@@ -67,6 +67,7 @@ import org.simantics.db.exception.DatabaseException;
  * @see Session
  * @see SimpleGraphRequest
  */
+@FunctionalInterface
 public interface WriteOnly extends WriteTraits {
 
     /**
index e7f37f6326f0778a2665b2953bd9431eb020e6d3..502c84d18ee93d5d775e3bd5ced4b7d678e81095 100644 (file)
@@ -65,6 +65,7 @@ import org.simantics.db.exception.DatabaseException;
  * @see Session
  * @see SimpleGraphRequest
  */
+@FunctionalInterface
 public interface WriteOnlyResult<T> extends WriteTraits {
 
     /**
index 8134b4e28a0e83f20fd1aa152c15bfaefc4f8ad4..18f6a1e3db9d3d7bcfad00a47610f8f7de9627fc 100644 (file)
@@ -65,6 +65,7 @@ import org.simantics.db.exception.DatabaseException;
  * @see Session
  * @see SimpleGraphRequest
  */
+@FunctionalInterface
 public interface WriteResult<T> extends WriteTraits {
 
     /**
@@ -91,5 +92,5 @@ public interface WriteResult<T> extends WriteTraits {
      *         be cancelled and any changes rolled back
      */
     T perform(WriteGraph graph) throws DatabaseException;
-    
+
 }
index d0738e0a240d31f771b814c24fe83620b95a26f5..16b4e793d6c0777918ac175ba4c6b6bdcc596bfd 100644 (file)
@@ -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;
+    }
 }