2 * Copyright © 2017 Red Hat, Inc. and others.
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
8 package org.opendaylight.genius.mdsalutil.nxmatches;
10 import com.google.common.collect.ImmutableBiMap;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg3;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg4;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg5;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg6;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg7;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.ExtensionKey;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlowBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxReg3Key;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxReg4Key;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxReg5Key;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxReg6Key;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxReg7Key;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.reg.grouping.NxmNxReg;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.reg.grouping.NxmNxRegBuilder;
28 * Nicira extension register match.
30 public class NxMatchRegister extends NxMatchInfoHelper<NxmNxReg, NxmNxRegBuilder> {
31 private static final Map<Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match
32 .rev140421.NxmNxReg>, Class<? extends ExtensionKey>> KEYS =
34 NxmNxReg3.class, NxmNxReg3Key.class,
35 NxmNxReg4.class, NxmNxReg4Key.class,
36 NxmNxReg5.class, NxmNxReg5Key.class,
37 NxmNxReg6.class, NxmNxReg6Key.class,
38 NxmNxReg7.class, NxmNxReg7Key.class
42 ? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg> register;
43 private final long value;
44 private final Long mask;
46 public NxMatchRegister(
47 Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg>
48 register, long value) {
49 this(register, value, null);
52 public NxMatchRegister(
53 Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg>
54 register, long value, Long mask) {
55 super(KEYS.get(register));
56 if (!KEYS.containsKey(register)) {
57 throw new IllegalArgumentException("Unknown NXM register " + register);
59 this.register = register;
65 protected void applyValue(NxAugMatchNodesNodeTableFlowBuilder matchBuilder, NxmNxReg regValue) {
66 matchBuilder.setNxmNxReg(regValue);
70 protected void populateBuilder(NxmNxRegBuilder builder) {
71 builder.setReg(register).setValue(value).setMask(mask);
74 public Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg>
79 public long getValue() {
83 public Long getMask() {
88 public boolean equals(Object other) {
92 if (other == null || getClass() != other.getClass()) {
95 if (!super.equals(other)) {
99 NxMatchRegister that = (NxMatchRegister) other;
101 if (value != that.value) {
104 if (register != null ? !register.equals(that.register) : that.register != null) {
107 return mask != null ? mask.equals(that.mask) : that.mask == null;
111 public int hashCode() {
112 int result = super.hashCode();
113 result = 31 * result + (register != null ? register.hashCode() : 0);
114 result = 31 * result + (int) (value ^ (value >>> 32));
115 result = 31 * result + (mask != null ? mask.hashCode() : 0);
120 public String toString() {
121 return "NxMatchRegister[" + register.getSimpleName() + ", " + value + (mask != null ? "/" + mask : "") + "]";