Neutron Port allocation for DHCP Service
[netvirt.git] / vpnservice / elanmanager / 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
12 import java.math.BigInteger;
13 import java.util.Collections;
14 import java.util.List;
15
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
17
18 public class ArpResponderInput {
19
20     private BigInteger dpId;
21     private String interfaceName;
22     private String spa;
23     private String sha;
24     private int lportTag;
25     private List<Instruction> instructions;
26
27
28     private ArpResponderInput() {}
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 || input.instructions.isEmpty()) {
73                 throw new AssertionError("Missing mandatory fields for ARP Responder Install Flow");
74             }
75
76             return input;
77         }
78
79         public ArpResponderInput buildForRemoveFlow() {
80
81             if (input.dpId == null || Strings.isNullOrEmpty(input.interfaceName) || Strings.isNullOrEmpty(input.spa)
82                     || input.lportTag == 0) {
83                 throw new AssertionError("Missing mandatory fields for ARP Responder Install Flow");
84             }
85
86             return input;
87         }
88
89         public ArpReponderInputBuilder(ArpResponderInput input) {
90             super();
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 }