Open Kilda Java Documentation
BidirectionalFlow.java
Go to the documentation of this file.
1 /*
2  * Copyright 2017 Telstra Open Source
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package org.openkilda.messaging.model;
18 
20 
21 import com.fasterxml.jackson.annotation.JsonCreator;
22 import com.fasterxml.jackson.annotation.JsonProperty;
23 import lombok.Builder;
24 import lombok.Value;
25 
26 import java.io.Serializable;
27 
28 @Value
29 public class BidirectionalFlow implements Serializable {
30 
31  private static final long serialVersionUID = 1L;
32 
33  @JsonProperty("flow_id")
34  private String flowId;
35 
36  // FIXME(surabujin): String field is worse possible representation of time
37  // private String lastUpdated;
38 
39  @JsonProperty("bandwidth")
40  private long bandwidth;
41  @JsonProperty("ignore_bandwidth")
42  private boolean ignoreBandwidth;
43 
44  @JsonProperty("cookie")
45  private long cookie;
46 
47  @JsonProperty("description")
48  private String description;
49 
50  @JsonProperty("state")
51  private FlowState state;
52 
53  @JsonProperty("forward")
54  private Flow forward;
55 
56  @JsonProperty("reverse")
57  private Flow reverse;
58 
60  this(flowPair.getLeft(), flowPair.getRight());
61  }
62 
63  public BidirectionalFlow(Flow forward, Flow reverse) {
64  flowId = forward.getFlowId();
65  bandwidth = forward.getBandwidth();
66  ignoreBandwidth = forward.isIgnoreBandwidth();
67  cookie = forward.getFlagglessCookie();
68  description = forward.getDescription();
69  state = forward.getState();
70 
71  this.forward = forward;
72  this.reverse = reverse;
73  }
74 
75  @Builder
76  @JsonCreator
78  @JsonProperty("flow_id") String flowId,
79  @JsonProperty("bandwidth") long bandwidth,
80  @JsonProperty("ignore_bandwidth") boolean ignoreBandwidth,
81  @JsonProperty("cookie") long cookie,
82  @JsonProperty("description") String description,
83  @JsonProperty("state") FlowState state,
84  @JsonProperty("forward") Flow forward,
85  @JsonProperty("reverse") Flow reverse) {
86  this.flowId = flowId;
87  this.bandwidth = bandwidth;
88  this.ignoreBandwidth = ignoreBandwidth;
89  this.cookie = cookie;
90  this.description = description;
91  this.state = state;
92  this.forward = forward;
93  this.reverse = reverse;
94  }
95 }
BidirectionalFlow( @JsonProperty("flow_id") String flowId, @JsonProperty("bandwidth") long bandwidth, @JsonProperty("ignore_bandwidth") boolean ignoreBandwidth, @JsonProperty("cookie") long cookie, @JsonProperty("description") String description, @JsonProperty("state") FlowState state, @JsonProperty("forward") Flow forward, @JsonProperty("reverse") Flow reverse)
BidirectionalFlow(ImmutablePair< Flow, Flow > flowPair)