Open Kilda Java Documentation
SwitchRulesDeleteRequest.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 
21 
22 import com.fasterxml.jackson.annotation.JsonCreator;
23 import com.fasterxml.jackson.annotation.JsonInclude;
24 import com.fasterxml.jackson.annotation.JsonProperty;
25 import lombok.Value;
26 
27 import java.util.Objects;
28 
29 @Value
30 @JsonInclude(JsonInclude.Include.NON_NULL)
31 public class SwitchRulesDeleteRequest extends CommandData {
32 
33  @JsonProperty("switch_id")
34  private SwitchId switchId;
35 
36  @JsonProperty("delete_rules")
37  private DeleteRulesAction deleteRulesAction;
38 
42  @JsonProperty("criteria")
43  private DeleteRulesCriteria criteria;
44 
52  @JsonCreator
54  @JsonProperty("switch_id") SwitchId switchId,
55  @JsonProperty("delete_rules") DeleteRulesAction deleteRulesAction,
56  @JsonProperty("criteria") DeleteRulesCriteria criteria
57  ) {
58  this.switchId = Objects.requireNonNull(switchId, "switch_id must not be null");
59  if (!Utils.validateSwitchId(switchId)) {
60  throw new IllegalArgumentException("switch_id has invalid value");
61  }
62 
63  this.deleteRulesAction = deleteRulesAction;
64  // NB: criteria is only needed if deleteRulesAction is not provided
65  this.criteria = deleteRulesAction == null ? Objects.requireNonNull(criteria) : criteria;
66  }
67 }
static boolean validateSwitchId(SwitchId switchId)
Definition: Utils.java:144
SwitchRulesDeleteRequest( @JsonProperty("switch_id") SwitchId switchId, @JsonProperty("delete_rules") DeleteRulesAction deleteRulesAction, @JsonProperty("criteria") DeleteRulesCriteria criteria)