Vpn to Vni demux table for L3VPN Over VxLAN
[genius.git] / mdsalutil / mdsalutil-api / src / main / java / org / opendaylight / genius / mdsalutil / NxMatchInfoBuilder.java
1 /*
2  * Copyright (c) 2016 Red Hat 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.genius.mdsalutil;
9
10 /**
11  * Builder for NxMatchInfo.
12  * This class, even if not directly called from anywhere statically, is needed
13  * by the XtendBeanGenerator in order to be able to generate code which creates
14  * MatchInfo instances.
15  */
16 public class NxMatchInfoBuilder extends AbstractMatchInfoBaseBuilder<NxMatchInfo> {
17
18     private NxMatchFieldType matchField;
19
20     @Override
21     public NxMatchInfo build() {
22         if (matchField == null) {
23             throw new IllegalStateException("matchField must be set");
24         } else if (matchValues != null && bigMatchValues == null && stringMatchValues == null) {
25             return new NxMatchInfo(matchField, matchValues);
26         } else if (matchValues == null && bigMatchValues != null && stringMatchValues == null) {
27             return new NxMatchInfo(matchField, bigMatchValues);
28         } else if (matchValues == null && bigMatchValues == null && stringMatchValues != null) {
29             return new NxMatchInfo(matchField, stringMatchValues);
30         } else {
31             throw new IllegalStateException("Can only use either matchValues or bigMatchValues or stringMatchValues");
32         }
33     }
34
35     public NxMatchFieldType getMatchField() {
36         return matchField;
37     }
38
39     public void setMatchField(NxMatchFieldType matchField) {
40         this.matchField = matchField;
41     }
42
43 }