Bug 4988: OF statistics & REST client
[groupbasedpolicy.git] / renderers / ofoverlay / src / main / java / org / opendaylight / groupbasedpolicy / renderer / ofoverlay / statistics / flowcache / FlowCacheKeys.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 java.util.ArrayList;
11 import java.util.List;
12
13 import com.google.common.base.Joiner;
14 import com.google.common.base.Preconditions;
15
16 public final class FlowCacheKeys {
17
18     private static final String SEPARATOR = ",";
19
20     private String value;
21
22     private FlowCacheKeys(FlowCacheKeysBuilder builder) {
23         this.value = Joiner.on(SEPARATOR).join(builder.getValues());
24     }
25
26     public String getValue() {
27         return value;
28     }
29
30     public static FlowCacheKeysBuilder builder(){
31         return new FlowCacheKeysBuilder();
32     }
33
34     public static class FlowCacheKeysBuilder {
35
36         private List<String> values = new ArrayList<>();
37
38         public List<String> getValues() {
39             return values;
40         }
41
42         public FlowCacheKeysBuilder setValues(List<String> values) {
43             this.values = Preconditions.checkNotNull(values);
44             return this;
45         }
46
47         public FlowCacheKeysBuilder addValue(String value) {
48             values.add(Preconditions.checkNotNull(value));
49             return this;
50         }
51
52         public FlowCacheKeys build() {
53             return new FlowCacheKeys(this);
54         }
55     }
56 }