Open Kilda Java Documentation
CacheFlowEntry.java
Go to the documentation of this file.
1 /* Copyright 2018 Telstra Open Source
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 package org.openkilda.wfm.topology.stats;
17 
18 import lombok.AllArgsConstructor;
19 import lombok.Builder;
20 import lombok.NonNull;
21 import lombok.Value;
22 
23 import java.io.Serializable;
24 
25 @Value
26 @AllArgsConstructor
27 @Builder(toBuilder = true)
28 public class CacheFlowEntry implements Serializable {
29 
30  @NonNull
31  private String flowId;
32 
33  private String ingressSwitch;
34  private String egressSwitch;
35 
36  public CacheFlowEntry(String flowId) {
37  this(flowId, null, null);
38  }
39 
44  public CacheFlowEntry replace(String sw, MeasurePoint point) {
45  CacheFlowEntryBuilder replacement = toBuilder();
46  switch (point) {
47  case INGRESS:
48  replacement.ingressSwitch(sw);
49  break;
50  case EGRESS:
51  replacement.egressSwitch(sw);
52  break;
53  default:
54  throw new IllegalArgumentException(String.format("Unsupported measurement point value %s", point));
55  }
56  return replacement.build();
57  }
58 }
CacheFlowEntry(String flowId)
CacheFlowEntry replace(String sw, MeasurePoint point)