Merge "Fix Ipv6 format compression" into stable/boron
[openflowplugin.git] / extension / openflowplugin-extension-nicira / src / main / java / org / opendaylight / openflowplugin / extension / vendor / nicira / convertor / action / RegMoveConvertor.java
1 /*
2  * Copyright (c) 2014, 2016 Cisco Systems, Inc. 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.openflowplugin.extension.vendor.nicira.convertor.action;
9
10 import org.opendaylight.openflowjava.nx.NiciraMatchCodecs;
11 import org.opendaylight.openflowjava.nx.codec.match.NxmHeader;
12 import org.opendaylight.openflowplugin.extension.api.ConvertorActionFromOFJava;
13 import org.opendaylight.openflowplugin.extension.api.ConvertorActionToOFJava;
14 import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
15 import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.CodecPreconditionException;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionRegMove;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionRegMoveBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.reg.move.grouping.NxActionRegMove;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.reg.move.grouping.NxActionRegMoveBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg0;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg1;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg2;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg3;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg4;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg5;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg6;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg7;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.NxActionRegMoveGrouping;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.DstChoice;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxArpShaCase;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxArpShaCaseBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxArpThaCase;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxArpThaCaseBuilder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc1Case;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc1CaseBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc2Case;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc2CaseBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc3Case;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc3CaseBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc4Case;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc4CaseBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNsiCase;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNsiCaseBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNspCase;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNspCaseBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxEncapEthSrcCase;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxEncapEthSrcCaseBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxEncapEthDstCase;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxEncapEthDstCaseBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshMdtypeCase;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshMdtypeCaseBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshNpCase;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshNpCaseBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxTunGpeNpCase;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxTunGpeNpCaseBuilder;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxRegCase;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxRegCaseBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxTunIdCase;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxTunIdCaseBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxTunIpv4DstCase;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxTunIpv4DstCaseBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxTunIpv4SrcCase;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxTunIpv4SrcCaseBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfArpOpCase;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfArpOpCaseBuilder;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfArpSpaCase;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfArpSpaCaseBuilder;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfArpTpaCase;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfArpTpaCaseBuilder;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfEthDstCase;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfEthDstCaseBuilder;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfEthSrcCase;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfEthSrcCaseBuilder;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfIcmpTypeCase;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfIcmpTypeCaseBuilder;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfIpDstCase;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfIpDstCaseBuilder;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfIpSrcCase;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfIpSrcCaseBuilder;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.flows.statistics.update.flow.and.statistics.map.list.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionRegMoveNotifFlowsStatisticsUpdateApplyActionsCaseBuilder;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.flows.statistics.update.flow.and.statistics.map.list.instructions.instruction.instruction.write.actions._case.write.actions.action.action.NxActionRegMoveNotifFlowsStatisticsUpdateWriteActionsCaseBuilder;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.group.desc.stats.updated.group.desc.stats.buckets.bucket.action.action.NxActionRegMoveNotifGroupDescStatsUpdatedCaseBuilder;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.write.actions._case.write.actions.action.action.NxActionRegMoveNodesNodeTableFlowWriteActionsCaseBuilder;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.NxRegMove;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.NxRegMoveBuilder;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Dst;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.DstBuilder;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Src;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.SrcBuilder;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.SrcChoice;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxArpShaCase;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxArpShaCaseBuilder;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxArpThaCase;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxArpThaCaseBuilder;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshc1Case;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshc1CaseBuilder;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshc2Case;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshc2CaseBuilder;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshc3Case;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshc3CaseBuilder;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshc4Case;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshc4CaseBuilder;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNsiCase;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNsiCaseBuilder;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNspCase;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNspCaseBuilder;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxEncapEthSrcCase;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxEncapEthSrcCaseBuilder;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxEncapEthDstCase;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxEncapEthDstCaseBuilder;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshMdtypeCase;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshMdtypeCaseBuilder;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshNpCase;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshNpCaseBuilder;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunGpeNpCase;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunGpeNpCaseBuilder;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxRegCase;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxRegCaseBuilder;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunIdCase;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunIdCaseBuilder;
123 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunIpv4DstCase;
124 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunIpv4DstCaseBuilder;
125 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunIpv4SrcCase;
126 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunIpv4SrcCaseBuilder;
127 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfArpOpCase;
128 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfArpOpCaseBuilder;
129 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfArpSpaCase;
130 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfArpSpaCaseBuilder;
131 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfArpTpaCase;
132 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfArpTpaCaseBuilder;
133 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfEthDstCase;
134 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfEthDstCaseBuilder;
135 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfEthSrcCase;
136 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfEthSrcCaseBuilder;
137 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfEthTypeCase;
138 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfEthTypeCaseBuilder;
139 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfIpDstCase;
140 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfIpDstCaseBuilder;
141 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfIpSrcCase;
142 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfIpSrcCaseBuilder;
143
144
145 import com.google.common.base.Preconditions;
146
147 /**
148  * @author msunal
149  * @author Josh Hershberg (jhershbe@redhat.com)
150  */
151 public class RegMoveConvertor implements
152         ConvertorActionToOFJava<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, Action>,
153         ConvertorActionFromOFJava<Action, ActionPath> {
154
155     @Override
156     public org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action convert(Action input, ActionPath path) {
157         NxActionRegMove actionRegMove = ((ActionRegMove) input.getActionChoice()).getNxActionRegMove();
158         DstBuilder dstBuilder = new DstBuilder();
159         dstBuilder.setDstChoice(resolveDst(actionRegMove.getDst()));
160         dstBuilder.setStart(actionRegMove.getDstOfs());
161         dstBuilder.setEnd(actionRegMove.getDstOfs() + actionRegMove.getNBits() - 1);
162         SrcBuilder srcBuilder = new SrcBuilder();
163         srcBuilder.setSrcChoice(resolveSrc(actionRegMove.getSrc()));
164         srcBuilder.setStart(actionRegMove.getSrcOfs());
165         srcBuilder.setEnd(actionRegMove.getSrcOfs() + actionRegMove.getNBits() - 1);
166         NxRegMoveBuilder nxRegMoveBuilder = new NxRegMoveBuilder();
167         nxRegMoveBuilder.setDst(dstBuilder.build());
168         nxRegMoveBuilder.setSrc(srcBuilder.build());
169         return resolveAction(nxRegMoveBuilder.build(), path);
170     }
171
172     public static DstChoice resolveDst(long dstValue) {
173         Class<? extends NxmNxReg> potentialDst = resolveReg(dstValue);
174         if (potentialDst != null) {
175             return new DstNxRegCaseBuilder().setNxReg(potentialDst).build();
176         }
177         if (dstValue == NiciraMatchCodecs.TUN_ID_CODEC.getHeaderWithoutHasMask().toLong()) {
178             return new DstNxTunIdCaseBuilder().setNxTunId(true).build();
179         }
180         if (dstValue == NiciraMatchCodecs.ARP_SHA_CODEC.getHeaderWithoutHasMask().toLong()) {
181             return new DstNxArpShaCaseBuilder().setNxArpSha(true).build();
182         }
183         if (dstValue == NiciraMatchCodecs.ARP_THA_CODEC.getHeaderWithoutHasMask().toLong()) {
184             return new DstNxArpThaCaseBuilder().setNxArpTha(true).build();
185         }
186         if (dstValue == NiciraMatchCodecs.ARP_OP_CODEC.getHeaderWithoutHasMask().toLong()) {
187             return new DstOfArpOpCaseBuilder().setOfArpOp(true).build();
188         }
189         if (dstValue == NiciraMatchCodecs.ARP_SPA_CODEC.getHeaderWithoutHasMask().toLong()) {
190             return new DstOfArpSpaCaseBuilder().setOfArpSpa(true).build();
191         }
192         if (dstValue == NiciraMatchCodecs.ARP_TPA_CODEC.getHeaderWithoutHasMask().toLong()) {
193             return new DstOfArpTpaCaseBuilder().setOfArpTpa(true).build();
194         }
195         if (dstValue == NiciraMatchCodecs.ETH_DST_CODEC.getHeaderWithoutHasMask().toLong()) {
196             return new DstOfEthDstCaseBuilder().setOfEthDst(true).build();
197         }
198         if (dstValue == NiciraMatchCodecs.ETH_SRC_CODEC.getHeaderWithoutHasMask().toLong()) {
199             return new DstOfEthSrcCaseBuilder().setOfEthSrc(true).build();
200         }
201         if (dstValue == NiciraMatchCodecs.TUN_IPV4_DST_CODEC.getHeaderWithoutHasMask().toLong()) {
202             return new DstNxTunIpv4DstCaseBuilder().setNxTunIpv4Dst(true).build();
203         }
204         if (dstValue == NiciraMatchCodecs.TUN_IPV4_SRC_CODEC.getHeaderWithoutHasMask().toLong()) {
205             return new DstNxTunIpv4SrcCaseBuilder().setNxTunIpv4Src(true).build();
206         }
207         if (dstValue == NiciraMatchCodecs.NSP_CODEC.getHeaderWithoutHasMask().toLong()) {
208             return new DstNxNspCaseBuilder().setNxNspDst(true).build();
209         }
210         if (dstValue == NiciraMatchCodecs.NSI_CODEC.getHeaderWithoutHasMask().toLong()) {
211             return new DstNxNsiCaseBuilder().setNxNsiDst(true).build();
212         }
213         if (dstValue == NiciraMatchCodecs.NSC1_CODEC.getHeaderWithoutHasMask().toLong()) {
214             return new DstNxNshc1CaseBuilder().setNxNshc1Dst(true).build();
215         }
216         if (dstValue == NiciraMatchCodecs.NSC2_CODEC.getHeaderWithoutHasMask().toLong()) {
217             return new DstNxNshc2CaseBuilder().setNxNshc2Dst(true).build();
218         }
219         if (dstValue == NiciraMatchCodecs.NSC3_CODEC.getHeaderWithoutHasMask().toLong()) {
220             return new DstNxNshc3CaseBuilder().setNxNshc3Dst(true).build();
221         }
222         if (dstValue == NiciraMatchCodecs.NSC4_CODEC.getHeaderWithoutHasMask().toLong()) {
223             return new DstNxNshc4CaseBuilder().setNxNshc4Dst(true).build();
224         }
225         if (dstValue == NiciraMatchCodecs.ENCAP_ETH_SRC_CODEC.getHeaderWithoutHasMask().toLong()) {
226             return new DstNxEncapEthSrcCaseBuilder().setNxEncapEthSrc(true).build();
227         }
228         if (dstValue == NiciraMatchCodecs.ENCAP_ETH_DST_CODEC.getHeaderWithoutHasMask().toLong()) {
229             return new DstNxEncapEthDstCaseBuilder().setNxEncapEthDst(true).build();
230         }
231         if (dstValue == NiciraMatchCodecs.NSH_MDTYPE_CODEC.getHeaderWithoutHasMask().toLong()) {
232             return new DstNxNshMdtypeCaseBuilder().setNxNshMdtype(true).build();
233         }
234         if (dstValue == NiciraMatchCodecs.NSH_NP_CODEC.getHeaderWithoutHasMask().toLong()) {
235             return new DstNxNshNpCaseBuilder().setNxNshNp(true).build();
236         }
237         if (dstValue == NiciraMatchCodecs.TUN_GPE_NP_CODEC.getHeaderWithoutHasMask().toLong()) {
238             return new DstNxTunGpeNpCaseBuilder().setNxTunGpeNp(true).build();
239         }
240         if (dstValue == NiciraMatchCodecs.IP_SRC_CODEC.getHeaderWithoutHasMask().toLong()) {
241             return new DstOfIpSrcCaseBuilder().setOfIpSrc(true).build();
242         }
243         if (dstValue == NiciraMatchCodecs.IP_DST_CODEC.getHeaderWithoutHasMask().toLong()) {
244             return new DstOfIpDstCaseBuilder().setOfIpDst(true).build();
245         }
246         if (dstValue == NiciraMatchCodecs.ICMP_TYPE_CODEC.getHeaderWithoutHasMask().toLong()) {
247             return new DstOfIcmpTypeCaseBuilder().setOfIcmpType(true).build();
248         }
249
250         throw new CodecPreconditionException("Missing codec for " + new NxmHeader(dstValue));
251     }
252
253     static SrcChoice resolveSrc(long srcValue) {
254         Class<? extends NxmNxReg> potentialSrc = resolveReg(srcValue);
255         if (potentialSrc != null) {
256             return new SrcNxRegCaseBuilder().setNxReg(potentialSrc).build();
257         }
258         if (srcValue == NiciraMatchCodecs.TUN_ID_CODEC.getHeaderWithoutHasMask().toLong()) {
259             return new SrcNxTunIdCaseBuilder().setNxTunId(true).build();
260         }
261         if (srcValue == NiciraMatchCodecs.ARP_SHA_CODEC.getHeaderWithoutHasMask().toLong()) {
262             return new SrcNxArpShaCaseBuilder().setNxArpSha(true).build();
263         }
264         if (srcValue == NiciraMatchCodecs.ARP_THA_CODEC.getHeaderWithoutHasMask().toLong()) {
265             return new SrcNxArpThaCaseBuilder().setNxArpTha(true).build();
266         }
267         if (srcValue == NiciraMatchCodecs.ARP_OP_CODEC.getHeaderWithoutHasMask().toLong()) {
268             return new SrcOfArpOpCaseBuilder().setOfArpOp(true).build();
269         }
270         if (srcValue == NiciraMatchCodecs.ARP_SPA_CODEC.getHeaderWithoutHasMask().toLong()) {
271             return new SrcOfArpSpaCaseBuilder().setOfArpSpa(true).build();
272         }
273         if (srcValue == NiciraMatchCodecs.ARP_TPA_CODEC.getHeaderWithoutHasMask().toLong()) {
274             return new SrcOfArpTpaCaseBuilder().setOfArpTpa(true).build();
275         }
276         if (srcValue == NiciraMatchCodecs.ETH_DST_CODEC.getHeaderWithoutHasMask().toLong()) {
277             return new SrcOfEthDstCaseBuilder().setOfEthDst(true).build();
278         }
279         if (srcValue == NiciraMatchCodecs.ETH_SRC_CODEC.getHeaderWithoutHasMask().toLong()) {
280             return new SrcOfEthSrcCaseBuilder().setOfEthSrc(true).build();
281         }
282         if (srcValue == NiciraMatchCodecs.ETH_TYPE_CODEC.getHeaderWithoutHasMask().toLong()) {
283             return new SrcOfEthTypeCaseBuilder().setOfEthType(true).build();
284         }
285         if (srcValue == NiciraMatchCodecs.TUN_IPV4_DST_CODEC.getHeaderWithoutHasMask().toLong()) {
286             return new SrcNxTunIpv4DstCaseBuilder().setNxTunIpv4Dst(true).build();
287         }
288         if (srcValue == NiciraMatchCodecs.TUN_IPV4_SRC_CODEC.getHeaderWithoutHasMask().toLong()) {
289             return new SrcNxTunIpv4SrcCaseBuilder().setNxTunIpv4Src(true).build();
290         }
291         if (srcValue == NiciraMatchCodecs.NSP_CODEC.getHeaderWithoutHasMask().toLong()) {
292             return new SrcNxNspCaseBuilder().setNxNspDst(true).build();
293         }
294         if (srcValue == NiciraMatchCodecs.NSI_CODEC.getHeaderWithoutHasMask().toLong()) {
295             return new SrcNxNsiCaseBuilder().setNxNsiDst(true).build();
296         }
297         if (srcValue == NiciraMatchCodecs.NSC1_CODEC.getHeaderWithoutHasMask().toLong()) {
298             return new SrcNxNshc1CaseBuilder().setNxNshc1Dst(true).build();
299         }
300         if (srcValue == NiciraMatchCodecs.NSC2_CODEC.getHeaderWithoutHasMask().toLong()) {
301             return new SrcNxNshc2CaseBuilder().setNxNshc2Dst(true).build();
302         }
303         if (srcValue == NiciraMatchCodecs.NSC3_CODEC.getHeaderWithoutHasMask().toLong()) {
304             return new SrcNxNshc3CaseBuilder().setNxNshc3Dst(true).build();
305         }
306         if (srcValue == NiciraMatchCodecs.NSC4_CODEC.getHeaderWithoutHasMask().toLong()) {
307             return new SrcNxNshc4CaseBuilder().setNxNshc4Dst(true).build();
308         }
309         if (srcValue == NiciraMatchCodecs.ENCAP_ETH_SRC_CODEC.getHeaderWithoutHasMask().toLong()) {
310             return new SrcNxEncapEthSrcCaseBuilder().setNxEncapEthSrc(true).build();
311         }
312         if (srcValue == NiciraMatchCodecs.ENCAP_ETH_DST_CODEC.getHeaderWithoutHasMask().toLong()) {
313             return new SrcNxEncapEthDstCaseBuilder().setNxEncapEthDst(true).build();
314         }
315         if (srcValue == NiciraMatchCodecs.NSH_MDTYPE_CODEC.getHeaderWithoutHasMask().toLong()) {
316             return new SrcNxNshMdtypeCaseBuilder().setNxNshMdtype(true).build();
317         }
318         if (srcValue == NiciraMatchCodecs.NSH_NP_CODEC.getHeaderWithoutHasMask().toLong()) {
319             return new SrcNxNshNpCaseBuilder().setNxNshNp(true).build();
320         }
321         if (srcValue == NiciraMatchCodecs.TUN_GPE_NP_CODEC.getHeaderWithoutHasMask().toLong()) {
322             return new SrcNxTunGpeNpCaseBuilder().setNxTunGpeNp(true).build();
323         }
324         if (srcValue == NiciraMatchCodecs.IP_DST_CODEC.getHeaderWithoutHasMask().toLong()) {
325             return new SrcOfIpDstCaseBuilder().setOfIpDst(true).build();
326         }
327         if (srcValue == NiciraMatchCodecs.IP_SRC_CODEC.getHeaderWithoutHasMask().toLong()) {
328             return new SrcOfIpSrcCaseBuilder().setOfIpSrc(true).build();
329         }
330
331         throw new CodecPreconditionException("Missing codec for " + new NxmHeader(srcValue));
332     }
333
334     private static Class<? extends NxmNxReg> resolveReg(long value) {
335         if (value == NiciraMatchCodecs.REG0_CODEC.getHeaderWithoutHasMask().toLong()) {
336             return NxmNxReg0.class;
337         }
338         if (value == NiciraMatchCodecs.REG1_CODEC.getHeaderWithoutHasMask().toLong()) {
339             return NxmNxReg1.class;
340         }
341         if (value == NiciraMatchCodecs.REG2_CODEC.getHeaderWithoutHasMask().toLong()) {
342             return NxmNxReg2.class;
343         }
344         if (value == NiciraMatchCodecs.REG3_CODEC.getHeaderWithoutHasMask().toLong()) {
345             return NxmNxReg3.class;
346         }
347         if (value == NiciraMatchCodecs.REG4_CODEC.getHeaderWithoutHasMask().toLong()) {
348             return NxmNxReg4.class;
349         }
350         if (value == NiciraMatchCodecs.REG5_CODEC.getHeaderWithoutHasMask().toLong()) {
351             return NxmNxReg5.class;
352         }
353         if (value == NiciraMatchCodecs.REG6_CODEC.getHeaderWithoutHasMask().toLong()) {
354             return NxmNxReg6.class;
355         }
356         if (value == NiciraMatchCodecs.REG7_CODEC.getHeaderWithoutHasMask().toLong()) {
357             return NxmNxReg7.class;
358         }
359         return null;
360     }
361
362     private static org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action resolveAction(
363             NxRegMove value, ActionPath path) {
364         switch (path) {
365             case NODES_NODE_TABLE_FLOW_INSTRUCTIONS_INSTRUCTION_WRITEACTIONSCASE_WRITEACTIONS_ACTION_ACTION_EXTENSIONLIST_EXTENSION:
366                 return new NxActionRegMoveNodesNodeTableFlowWriteActionsCaseBuilder().setNxRegMove(value).build();
367             case FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_WRITEACTIONSCASE_WRITEACTIONS_ACTION_ACTION:
368                 return new NxActionRegMoveNotifFlowsStatisticsUpdateWriteActionsCaseBuilder().setNxRegMove(value).build();
369             case FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_APPLYACTIONSCASE_APPLYACTIONS_ACTION_ACTION:
370                 return new NxActionRegMoveNotifFlowsStatisticsUpdateApplyActionsCaseBuilder().setNxRegMove(value).build();
371             case GROUPDESCSTATSUPDATED_GROUPDESCSTATS_BUCKETS_BUCKET_ACTION:
372                 return new NxActionRegMoveNotifGroupDescStatsUpdatedCaseBuilder().setNxRegMove(value).build();
373             default:
374                 throw new CodecPreconditionException(path);
375         }
376     }
377
378     @Override
379     public Action convert(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action nxActionArg) {
380         Preconditions.checkArgument(nxActionArg instanceof NxActionRegMoveGrouping);
381         NxActionRegMoveGrouping nxAction = (NxActionRegMoveGrouping) nxActionArg;
382
383         Dst dst = nxAction.getNxRegMove().getDst();
384         Src src = nxAction.getNxRegMove().getSrc();
385         ActionRegMoveBuilder actionRegMoveBuilder = new ActionRegMoveBuilder();
386         NxActionRegMoveBuilder nxActionRegMove = new NxActionRegMoveBuilder();
387
388         nxActionRegMove.setDst(resolveDst(dst.getDstChoice()));
389         nxActionRegMove.setDstOfs(dst.getStart());
390         nxActionRegMove.setSrc(resolveSrc(src.getSrcChoice()));
391         nxActionRegMove.setSrcOfs(src.getStart());
392         nxActionRegMove.setNBits(dst.getEnd() - dst.getStart() + 1);
393         actionRegMoveBuilder.setNxActionRegMove(nxActionRegMove.build());
394         return ActionUtil.createAction(actionRegMoveBuilder.build());
395     }
396
397     public static long resolveDst(DstChoice dstChoice) {
398         if (dstChoice instanceof DstNxRegCase) {
399             return resolveReg(((DstNxRegCase) dstChoice).getNxReg());
400         }
401         if (dstChoice instanceof DstNxTunIdCase) {
402             return NiciraMatchCodecs.TUN_ID_CODEC.getHeaderWithoutHasMask().toLong();
403         }
404         if (dstChoice instanceof DstNxArpShaCase) {
405             return NiciraMatchCodecs.ARP_SHA_CODEC.getHeaderWithoutHasMask().toLong();
406         }
407         if (dstChoice instanceof DstNxArpThaCase) {
408             return NiciraMatchCodecs.ARP_THA_CODEC.getHeaderWithoutHasMask().toLong();
409         }
410         if (dstChoice instanceof DstOfArpOpCase) {
411             return NiciraMatchCodecs.ARP_OP_CODEC.getHeaderWithoutHasMask().toLong();
412         }
413         if (dstChoice instanceof DstOfArpSpaCase) {
414             return NiciraMatchCodecs.ARP_SPA_CODEC.getHeaderWithoutHasMask().toLong();
415         }
416         if (dstChoice instanceof DstOfArpTpaCase) {
417             return NiciraMatchCodecs.ARP_TPA_CODEC.getHeaderWithoutHasMask().toLong();
418         }
419         if (dstChoice instanceof DstNxTunIpv4DstCase) {
420             return NiciraMatchCodecs.TUN_IPV4_DST_CODEC.getHeaderWithoutHasMask().toLong();
421         }
422         if (dstChoice instanceof DstNxTunIpv4SrcCase) {
423             return NiciraMatchCodecs.TUN_IPV4_SRC_CODEC.getHeaderWithoutHasMask().toLong();
424         }
425         if (dstChoice instanceof DstOfEthDstCase) {
426             return NiciraMatchCodecs.ETH_DST_CODEC.getHeaderWithoutHasMask().toLong();
427         }
428         if (dstChoice instanceof DstOfEthSrcCase) {
429             return NiciraMatchCodecs.ETH_SRC_CODEC.getHeaderWithoutHasMask().toLong();
430         }
431         if (dstChoice instanceof DstNxTunIpv4DstCase) {
432             return NiciraMatchCodecs.TUN_IPV4_DST_CODEC.getHeaderWithoutHasMask().toLong();
433         }
434         if (dstChoice instanceof DstNxTunIpv4SrcCase) {
435             return NiciraMatchCodecs.TUN_IPV4_SRC_CODEC.getHeaderWithoutHasMask().toLong();
436         }
437         if (dstChoice instanceof DstNxNspCase) {
438             return NiciraMatchCodecs.NSP_CODEC.getHeaderWithoutHasMask().toLong();
439         }
440         if (dstChoice instanceof DstNxNsiCase) {
441             return NiciraMatchCodecs.NSI_CODEC.getHeaderWithoutHasMask().toLong();
442         }
443         if (dstChoice instanceof DstNxNshc1Case) {
444             return  NiciraMatchCodecs.NSC1_CODEC.getHeaderWithoutHasMask().toLong();
445         }
446         if (dstChoice instanceof DstNxNshc2Case) {
447             return  NiciraMatchCodecs.NSC2_CODEC.getHeaderWithoutHasMask().toLong();
448         }
449         if (dstChoice instanceof DstNxNshc3Case) {
450             return  NiciraMatchCodecs.NSC3_CODEC.getHeaderWithoutHasMask().toLong();
451         }
452         if (dstChoice instanceof DstNxNshc4Case) {
453             return  NiciraMatchCodecs.NSC4_CODEC.getHeaderWithoutHasMask().toLong();
454         }
455         if (dstChoice instanceof DstOfIpSrcCase) {
456             return NiciraMatchCodecs.IP_SRC_CODEC.getHeaderWithoutHasMask().toLong();
457         }
458         if (dstChoice instanceof DstOfIpDstCase) {
459             return NiciraMatchCodecs.IP_DST_CODEC.getHeaderWithoutHasMask().toLong();
460         }
461         if (dstChoice instanceof DstOfIcmpTypeCase) {
462             return NiciraMatchCodecs.ICMP_TYPE_CODEC.getHeaderWithoutHasMask().toLong();
463         }
464         if (dstChoice instanceof DstNxEncapEthSrcCase) {
465             return  NiciraMatchCodecs.ENCAP_ETH_SRC_CODEC.getHeaderWithoutHasMask().toLong();
466         }
467         if (dstChoice instanceof DstNxEncapEthDstCase) {
468             return  NiciraMatchCodecs.ENCAP_ETH_DST_CODEC.getHeaderWithoutHasMask().toLong();
469         }
470         if (dstChoice instanceof DstNxNshMdtypeCase) {
471             return  NiciraMatchCodecs.NSH_MDTYPE_CODEC.getHeaderWithoutHasMask().toLong();
472         }
473         if (dstChoice instanceof DstNxNshNpCase) {
474             return  NiciraMatchCodecs.NSH_NP_CODEC.getHeaderWithoutHasMask().toLong();
475         }
476         if (dstChoice instanceof DstNxTunGpeNpCase) {
477             return  NiciraMatchCodecs.TUN_GPE_NP_CODEC.getHeaderWithoutHasMask().toLong();
478         }
479
480
481         throw new CodecPreconditionException("Missing implementation of a case in dst-choice? " + dstChoice.getClass());
482     }
483
484     static long resolveSrc(SrcChoice srcChoice) {
485         if (srcChoice instanceof SrcNxRegCase) {
486             return resolveReg(((SrcNxRegCase) srcChoice).getNxReg());
487         }
488         if (srcChoice instanceof SrcNxTunIdCase) {
489             return NiciraMatchCodecs.TUN_ID_CODEC.getHeaderWithoutHasMask().toLong();
490         }
491         if (srcChoice instanceof SrcNxArpShaCase) {
492             return NiciraMatchCodecs.ARP_SHA_CODEC.getHeaderWithoutHasMask().toLong();
493         }
494         if (srcChoice instanceof SrcNxArpThaCase) {
495             return NiciraMatchCodecs.ARP_THA_CODEC.getHeaderWithoutHasMask().toLong();
496         }
497         if (srcChoice instanceof SrcOfArpOpCase) {
498             return NiciraMatchCodecs.ARP_OP_CODEC.getHeaderWithoutHasMask().toLong();
499         }
500         if (srcChoice instanceof SrcOfArpSpaCase) {
501             return NiciraMatchCodecs.ARP_SPA_CODEC.getHeaderWithoutHasMask().toLong();
502         }
503         if (srcChoice instanceof SrcOfArpTpaCase) {
504             return NiciraMatchCodecs.ARP_TPA_CODEC.getHeaderWithoutHasMask().toLong();
505         }
506         if (srcChoice instanceof SrcNxTunIpv4DstCase) {
507             return NiciraMatchCodecs.TUN_IPV4_DST_CODEC.getHeaderWithoutHasMask().toLong();
508         }
509         if (srcChoice instanceof SrcNxTunIpv4SrcCase) {
510             return NiciraMatchCodecs.TUN_IPV4_SRC_CODEC.getHeaderWithoutHasMask().toLong();
511         }
512         if (srcChoice instanceof SrcOfEthDstCase) {
513             return NiciraMatchCodecs.ETH_DST_CODEC.getHeaderWithoutHasMask().toLong();
514         }
515         if (srcChoice instanceof SrcOfEthSrcCase) {
516             return NiciraMatchCodecs.ETH_SRC_CODEC.getHeaderWithoutHasMask().toLong();
517         }
518         if (srcChoice instanceof SrcOfEthTypeCase) {
519             return NiciraMatchCodecs.ETH_TYPE_CODEC.getHeaderWithoutHasMask().toLong();
520         }
521         if (srcChoice instanceof SrcNxTunIpv4DstCase) {
522             return NiciraMatchCodecs.TUN_IPV4_DST_CODEC.getHeaderWithoutHasMask().toLong();
523         }
524         if (srcChoice instanceof SrcNxTunIpv4SrcCase) {
525             return NiciraMatchCodecs.TUN_IPV4_SRC_CODEC.getHeaderWithoutHasMask().toLong();
526         }
527         if (srcChoice instanceof SrcNxNspCase) {
528             return NiciraMatchCodecs.NSP_CODEC.getHeaderWithoutHasMask().toLong();
529         }
530         if (srcChoice instanceof SrcNxNsiCase) {
531             return NiciraMatchCodecs.NSI_CODEC.getHeaderWithoutHasMask().toLong();
532         }
533         if (srcChoice instanceof SrcNxNshc1Case) {
534             return  NiciraMatchCodecs.NSC1_CODEC.getHeaderWithoutHasMask().toLong();
535         }
536         if (srcChoice instanceof SrcNxNshc2Case) {
537             return  NiciraMatchCodecs.NSC2_CODEC.getHeaderWithoutHasMask().toLong();
538         }
539         if (srcChoice instanceof SrcNxNshc3Case) {
540             return  NiciraMatchCodecs.NSC3_CODEC.getHeaderWithoutHasMask().toLong();
541         }
542         if (srcChoice instanceof SrcNxNshc4Case) {
543             return  NiciraMatchCodecs.NSC4_CODEC.getHeaderWithoutHasMask().toLong();
544         }
545         if (srcChoice instanceof SrcOfIpSrcCase) {
546             return NiciraMatchCodecs.IP_SRC_CODEC.getHeaderWithoutHasMask().toLong();
547         }
548         if (srcChoice instanceof SrcOfIpDstCase) {
549             return NiciraMatchCodecs.IP_DST_CODEC.getHeaderWithoutHasMask().toLong();
550         }
551         if (srcChoice instanceof SrcNxEncapEthSrcCase) {
552             return  NiciraMatchCodecs.ENCAP_ETH_SRC_CODEC.getHeaderWithoutHasMask().toLong();
553         }
554         if (srcChoice instanceof SrcNxEncapEthDstCase) {
555             return  NiciraMatchCodecs.ENCAP_ETH_DST_CODEC.getHeaderWithoutHasMask().toLong();
556         }
557         if (srcChoice instanceof SrcNxNshMdtypeCase) {
558             return  NiciraMatchCodecs.NSH_MDTYPE_CODEC.getHeaderWithoutHasMask().toLong();
559         }
560         if (srcChoice instanceof SrcNxNshNpCase) {
561             return  NiciraMatchCodecs.NSH_NP_CODEC.getHeaderWithoutHasMask().toLong();
562         }
563         if (srcChoice instanceof SrcNxTunGpeNpCase) {
564             return  NiciraMatchCodecs.TUN_GPE_NP_CODEC.getHeaderWithoutHasMask().toLong();
565         }
566
567         throw new CodecPreconditionException("Missing implementation of a case in src-choice? " + srcChoice.getClass());
568     }
569
570     private static long resolveReg(Class<? extends NxmNxReg> reg) {
571         if (reg.equals(NxmNxReg0.class)) {
572             return NiciraMatchCodecs.REG0_CODEC.getHeaderWithoutHasMask().toLong();
573         }
574         if (reg.equals(NxmNxReg1.class)) {
575             return NiciraMatchCodecs.REG1_CODEC.getHeaderWithoutHasMask().toLong();
576         }
577         if (reg.equals(NxmNxReg2.class)) {
578             return NiciraMatchCodecs.REG2_CODEC.getHeaderWithoutHasMask().toLong();
579         }
580         if (reg.equals(NxmNxReg3.class)) {
581             return NiciraMatchCodecs.REG3_CODEC.getHeaderWithoutHasMask().toLong();
582         }
583         if (reg.equals(NxmNxReg4.class)) {
584             return NiciraMatchCodecs.REG4_CODEC.getHeaderWithoutHasMask().toLong();
585         }
586         if (reg.equals(NxmNxReg5.class)) {
587             return NiciraMatchCodecs.REG5_CODEC.getHeaderWithoutHasMask().toLong();
588         }
589         if (reg.equals(NxmNxReg6.class)) {
590             return NiciraMatchCodecs.REG6_CODEC.getHeaderWithoutHasMask().toLong();
591         }
592         if (reg.equals(NxmNxReg7.class)) {
593             return NiciraMatchCodecs.REG7_CODEC.getHeaderWithoutHasMask().toLong();
594         }
595         throw new CodecPreconditionException("Missing codec for nxm_nx_reg?" + reg);
596     }
597
598 }