Bug 4988: OF statistics & REST client
[groupbasedpolicy.git] / renderers / ofoverlay / src / main / java / org / opendaylight / groupbasedpolicy / renderer / ofoverlay / statistics / flowcache / FlowCacheDefinition.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, 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 package org.opendaylight.groupbasedpolicy.renderer.ofoverlay.statistics.flowcache;
9
10 import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.statistics.flowcache.FlowCacheFilter.FlowCacheFilterBuilder;
11 import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.statistics.flowcache.FlowCacheKeys.FlowCacheKeysBuilder;
12
13 import com.google.common.base.Preconditions;
14
15 /**
16  * An object to handle flow-cache parameters for JSON conversion
17  */
18 public final class FlowCacheDefinition {
19
20     private String keys;
21     private String value;
22     private String filter;
23     private boolean log;
24
25     private FlowCacheDefinition() {
26     }
27
28     private FlowCacheDefinition(FlowCacheDefinitionBuilder builder) {
29         this.keys = builder.getKeysBuilder().build().getValue();
30         this.value = builder.getValue();
31         this.filter = builder.getFilterBuilder().build().getValue();
32         this.log = builder.isLog();
33     }
34
35     public String getKeys() {
36         return keys;
37     }
38
39     public String getValue() {
40         return value;
41     }
42
43     public String getFilter() {
44         return filter;
45     }
46
47     public boolean getLog() {
48         return log;
49     }
50
51     public static FlowCacheDefinitionBuilder builder(){
52         return new FlowCacheDefinitionBuilder();
53     }
54
55     @Override
56     public String toString() {
57         return "FlowCacheDefinition [keys=" + keys + ", value=" + value + ", filter=" + filter + ", log=" + log + "]";
58     }
59
60     public static class FlowCacheDefinitionBuilder {
61
62         private String value;
63         private boolean log = false;
64         private final FlowCacheKeysBuilder keysBuilder = new FlowCacheKeysBuilder();
65         private final FlowCacheFilterBuilder filterBuilder = new FlowCacheFilterBuilder();
66
67         public FlowCacheKeysBuilder getKeysBuilder() {
68             return keysBuilder;
69         }
70
71         public String getValue() {
72             return value;
73         }
74
75         public FlowCacheDefinitionBuilder setValue(String value) {
76             Preconditions.checkNotNull(value);
77             this.value = value;
78             return this;
79         }
80
81         public FlowCacheFilterBuilder getFilterBuilder() {
82             return filterBuilder;
83         }
84
85         public boolean isLog() {
86             return log;
87         }
88
89         public FlowCacheDefinitionBuilder setLog(boolean log) {
90             this.log = log;
91             return this;
92         }
93
94         public FlowCacheDefinition build() {
95             return new FlowCacheDefinition(this);
96         }
97     }
98 }