Open Kilda Java Documentation
SwitchRulesInstallRequest.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.messaging.command.switches;
17 
18 import static com.google.common.base.MoreObjects.toStringHelper;
19 import static org.openkilda.messaging.Utils.TIMESTAMP;
20 
24 
25 import com.fasterxml.jackson.annotation.JsonCreator;
26 import com.fasterxml.jackson.annotation.JsonInclude;
27 import com.fasterxml.jackson.annotation.JsonProperty;
28 
29 import java.util.Objects;
30 
31 @JsonInclude(JsonInclude.Include.NON_NULL)
32 public class SwitchRulesInstallRequest extends CommandData {
33 
34  @JsonProperty("switch_id")
35  private SwitchId switchId;
36 
37  @JsonProperty("install_rules")
38  private InstallRulesAction installRulesAction;
39 
46  @JsonCreator
48  @JsonProperty("switch_id") SwitchId switchId,
49  @JsonProperty("install_rules") InstallRulesAction installRulesAction
50  ) {
51  this.switchId = Objects.requireNonNull(switchId, "switch_id must not be null");
52  if (!Utils.validateSwitchId(switchId)) {
53  throw new IllegalArgumentException("switch_id has invalid value");
54  }
55 
56  this.installRulesAction = Objects.requireNonNull(installRulesAction);
57  }
58 
59  public SwitchId getSwitchId() {
60  return switchId;
61  }
62 
64  return installRulesAction;
65  }
66 
67  @Override
68  public String toString() {
69  return toStringHelper(this)
70  .add(TIMESTAMP, timestamp)
71  .add("switch_id", switchId)
72  .add("install_rules", installRulesAction)
73  .toString();
74  }
75 }
static boolean validateSwitchId(SwitchId switchId)
Definition: Utils.java:144
SwitchRulesInstallRequest( @JsonProperty("switch_id") SwitchId switchId, @JsonProperty("install_rules") InstallRulesAction installRulesAction)
static final String TIMESTAMP
Definition: Utils.java:35