2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.groupbasedpolicy.renderer.ofoverlay.statistics.flowcache;
10 import java.util.ArrayList;
11 import java.util.List;
13 import com.google.common.base.Joiner;
14 import com.google.common.base.Preconditions;
16 public final class FlowCacheKeys {
18 private static final String SEPARATOR = ",";
22 private FlowCacheKeys(FlowCacheKeysBuilder builder) {
23 this.value = Joiner.on(SEPARATOR).join(builder.getValues());
26 public String getValue() {
30 public static FlowCacheKeysBuilder builder(){
31 return new FlowCacheKeysBuilder();
34 public static class FlowCacheKeysBuilder {
36 private List<String> values = new ArrayList<>();
38 public List<String> getValues() {
43 * Sets FlowCache's "key" values by copying {@code String}s from {@code values},
44 * to avoid immutable list put as a parameter.
45 * {@code null}s are omitted.
47 * @param values List of String
48 * @return FlowCacheKeysBuilder
50 public FlowCacheKeysBuilder setValues(List<String> values) {
51 Preconditions.checkNotNull(values);
52 for (String value : values) {
54 this.values.add(value);
60 public FlowCacheKeysBuilder addValue(String value) {
61 values.add(Preconditions.checkNotNull(value));
65 public FlowCacheKeys build() {
66 return new FlowCacheKeys(this);