Bump odlparent->6.0.0,mdsal->5.0.3
[netvirt.git] / elanmanager / api / src / main / java / org / opendaylight / netvirt / elan / arp / responder / ArpResponderInput.java
1 /*
2  * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.netvirt.elan.arp.responder;
9
10 import com.google.common.base.Strings;
11 import java.math.BigInteger;
12 import java.util.Collections;
13 import java.util.List;
14
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
16
17 public final class ArpResponderInput {
18
19     private BigInteger dpId;
20     private String interfaceName;
21     private String spa;
22     private String sha;
23     private int lportTag;
24     private List<Instruction> instructions;
25
26     private ArpResponderInput() {
27
28     }
29
30     public BigInteger getDpId() {
31         return dpId;
32     }
33
34     public String getInterfaceName() {
35         return interfaceName;
36     }
37
38     public String getSpa() {
39         return spa;
40     }
41
42     public String getSha() {
43         return sha;
44     }
45
46     public int getLportTag() {
47         return lportTag;
48     }
49
50     public List<Instruction> getInstructions() {
51         if (instructions == null) {
52             instructions = Collections.emptyList();
53         }
54         return instructions;
55     }
56
57     public static class ArpReponderInputBuilder {
58
59         private ArpResponderInput input;
60
61         public ArpReponderInputBuilder() {
62             input = new ArpResponderInput();
63         }
64
65         public ArpResponderInput build() {
66             return input;
67         }
68
69         public ArpResponderInput buildForInstallFlow() {
70
71             if (input.dpId == null || Strings.isNullOrEmpty(input.interfaceName) || Strings.isNullOrEmpty(input.spa)
72                     || Strings.isNullOrEmpty(input.sha) || input.lportTag == 0
73                     || input.instructions == null || input.instructions.isEmpty()) {
74                 throw new AssertionError("Missing mandatory fields for ARP Responder Install Flow");
75             }
76
77             return input;
78         }
79
80         public ArpResponderInput buildForRemoveFlow() {
81
82             if (input.dpId == null || Strings.isNullOrEmpty(input.interfaceName) || Strings.isNullOrEmpty(input.spa)
83                     || input.lportTag == 0) {
84                 throw new AssertionError("Missing mandatory fields for ARP Responder Install Flow");
85             }
86
87             return input;
88         }
89
90         public ArpReponderInputBuilder(ArpResponderInput input) {
91             this.input = input;
92         }
93
94         public ArpReponderInputBuilder setDpId(BigInteger dpId) {
95             input.dpId = dpId;
96             return this;
97         }
98
99         public ArpReponderInputBuilder setInterfaceName(String interfaceName) {
100             input.interfaceName = interfaceName;
101             return this;
102         }
103
104         public ArpReponderInputBuilder setSpa(String spa) {
105             input.spa = spa;
106             return this;
107         }
108
109         public ArpReponderInputBuilder setSha(String sha) {
110             input.sha = sha;
111             return this;
112         }
113
114         public ArpReponderInputBuilder setLportTag(int lportTag) {
115             input.lportTag = lportTag;
116             return this;
117         }
118
119         public ArpReponderInputBuilder setInstructions(List<Instruction> instructions) {
120             input.instructions = instructions == null ? Collections.emptyList() : instructions;
121             return this;
122         }
123
124     }
125
126 }