2 * Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved.
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.actions;
10 import java.math.BigInteger;
11 import javax.annotation.Nullable;
12 import org.opendaylight.genius.mdsalutil.ActionInfo;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TunnelBuilder;
21 * Set tunnel id field action.
23 public class ActionSetFieldTunnelId extends ActionInfo {
24 private static final long serialVersionUID = 1L;
26 private final BigInteger tunnelId;
27 @Nullable private final BigInteger tunnelMask;
29 public ActionSetFieldTunnelId(BigInteger tunnelId) {
33 public ActionSetFieldTunnelId(int actionKey, BigInteger tunnelId) {
34 this(actionKey, tunnelId, null);
37 public ActionSetFieldTunnelId(BigInteger tunnelId, BigInteger tunnelMask) {
38 this(0, tunnelId, tunnelMask);
41 public ActionSetFieldTunnelId(int actionKey, BigInteger tunnelId, BigInteger tunnelMask) {
43 this.tunnelId = tunnelId;
44 this.tunnelMask = tunnelMask;
48 public Action buildAction() {
49 return buildAction(getActionKey());
53 public Action buildAction(int newActionKey) {
54 TunnelBuilder tunnelBuilder = new TunnelBuilder()
55 .setTunnelId(tunnelId);
56 if (tunnelMask != null) {
57 tunnelBuilder.setTunnelMask(tunnelMask);
59 return new ActionBuilder()
61 new SetFieldCaseBuilder()
64 .setTunnel(tunnelBuilder.build())
67 .setKey(new ActionKey(newActionKey))
71 public BigInteger getTunnelId() {
76 public BigInteger getTunnelMask() {
81 public boolean equals(Object other) {
85 if (other == null || getClass() != other.getClass()) {
88 if (!super.equals(other)) {
92 ActionSetFieldTunnelId that = (ActionSetFieldTunnelId) other;
94 if (tunnelId != null ? !tunnelId.equals(that.tunnelId) : that.tunnelId != null) {
97 return tunnelMask != null ? tunnelMask.equals(that.tunnelMask) : that.tunnelMask == null;
101 public int hashCode() {
102 int result = super.hashCode();
103 result = 31 * result + (tunnelId != null ? tunnelId.hashCode() : 0);
104 result = 31 * result + (tunnelMask != null ? tunnelMask.hashCode() : 0);