Fixing checkstyle issues on Ashwin's initial POC code for the new Schema design.
[netvirt.git] / ovsdb / src / main / java / org / opendaylight / ovsdb / lib / message / operations / Operation.java
index 856e74f94cd1a1f46e7853c2d59f668a674fbd9c..1330bb94c4d77ce0d7d1fa96c3102163e98b3597 100644 (file)
@@ -5,18 +5,39 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  *
- * Authors : Madhu Venugopal
+ * Authors : Madhu Venugopal, Ashwin Raveendran
  */
 package org.opendaylight.ovsdb.lib.message.operations;
 
 import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.opendaylight.ovsdb.lib.meta.TableSchema;
+
+public abstract class Operation<E extends TableSchema<E>> {
+
+    @JsonIgnore
+    private TableSchema<E> tableSchema;
 
-public abstract class Operation {
     private String op;
+
     @JsonIgnore
+    //todo(Ashwin): remove this
     // Just a simple way to retain the result of a transact operation which the client can refer to.
     private OperationResult result;
 
+
+    protected Operation() {
+    }
+
+    protected Operation(TableSchema<E> tableSchema) {
+        this.tableSchema = tableSchema;
+    }
+
+    public Operation(TableSchema<E> schema, String operation) {
+        this.tableSchema = schema;
+        this.op = operation;
+    }
+
     public String getOp() {
         return op;
     }
@@ -33,8 +54,22 @@ public abstract class Operation {
         this.result = result;
     }
 
+    public TableSchema<E> getTableSchema() {
+        return tableSchema;
+    }
+
+    public void setTableSchema(TableSchema<E> tableSchema) {
+        this.tableSchema = tableSchema;
+    }
+
+    @JsonProperty
+    public String getTable() {
+        return tableSchema.getName();
+    }
+
     @Override
     public String toString() {
         return "Operation [op=" + op + ", result=" + result + "]";
     }
+
 }