Updating fix for bug 3989 based on discussion in OVSDB meeting
[ovsdb.git] / library / src / main / java / org / opendaylight / ovsdb / lib / operations / Operation.java
1 /*
2  * Copyright (c) 2013, 2015 Red Hat, Inc. and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.ovsdb.lib.operations;
10
11 import org.opendaylight.ovsdb.lib.schema.TableSchema;
12
13 import com.fasterxml.jackson.annotation.JsonIgnore;
14 import com.fasterxml.jackson.annotation.JsonProperty;
15
16 public abstract class Operation<E extends TableSchema<E>> {
17
18     @JsonIgnore
19     private TableSchema<E> tableSchema;
20
21     private String op;
22
23     @JsonIgnore
24     //todo(Ashwin): remove this
25     // Just a simple way to retain the result of a transact operation which the client can refer to.
26     private OperationResult result;
27
28
29     protected Operation() {
30     }
31
32     protected Operation(TableSchema<E> tableSchema) {
33         this.tableSchema = tableSchema;
34     }
35
36     public Operation(TableSchema<E> schema, String operation) {
37         this.tableSchema = schema;
38         this.op = operation;
39     }
40
41     public String getOp() {
42         return op;
43     }
44
45     public void setOp(String op) {
46         this.op = op;
47     }
48
49     public OperationResult getResult() {
50         return result;
51     }
52
53     public void setResult(OperationResult result) {
54         this.result = result;
55     }
56
57     public TableSchema<E> getTableSchema() {
58         return tableSchema;
59     }
60
61     public void setTableSchema(TableSchema<E> tableSchema) {
62         this.tableSchema = tableSchema;
63     }
64
65     @JsonProperty
66     public String getTable() {
67         return (tableSchema == null) ? null : tableSchema.getName();
68     }
69
70     @Override
71     public String toString() {
72         return "Operation [op=" + op + ", result=" + result + "]";
73     }
74
75 }