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