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 final BigInteger tunnelId;
25 @Nullable private final BigInteger tunnelMask;
27 public ActionSetFieldTunnelId(BigInteger tunnelId) {
31 public ActionSetFieldTunnelId(int actionKey, BigInteger tunnelId) {
32 this(actionKey, tunnelId, null);
35 public ActionSetFieldTunnelId(BigInteger tunnelId, BigInteger tunnelMask) {
36 this(0, tunnelId, tunnelMask);
39 public ActionSetFieldTunnelId(int actionKey, BigInteger tunnelId, BigInteger tunnelMask) {
41 this.tunnelId = tunnelId;
42 this.tunnelMask = tunnelMask;
46 public Action buildAction() {
47 return buildAction(getActionKey());
50 public Action buildAction(int newActionKey) {
51 TunnelBuilder tunnelBuilder = new TunnelBuilder()
52 .setTunnelId(tunnelId);
53 if (tunnelMask != null) {
54 tunnelBuilder.setTunnelMask(tunnelMask);
56 return new ActionBuilder()
58 new SetFieldCaseBuilder()
61 .setTunnel(tunnelBuilder.build())
64 .setKey(new ActionKey(newActionKey))
68 public BigInteger getTunnelId() {
73 public BigInteger getTunnelMask() {
78 public boolean equals(Object o) {
79 if (this == o) return true;
80 if (o == null || getClass() != o.getClass()) return false;
81 if (!super.equals(o)) return false;
83 ActionSetFieldTunnelId that = (ActionSetFieldTunnelId) o;
85 if (tunnelId != null ? !tunnelId.equals(that.tunnelId) : that.tunnelId != null) return false;
86 return tunnelMask != null ? tunnelMask.equals(that.tunnelMask) : that.tunnelMask == null;
90 public int hashCode() {
91 int result = super.hashCode();
92 result = 31 * result + (tunnelId != null ? tunnelId.hashCode() : 0);
93 result = 31 * result + (tunnelMask != null ? tunnelMask.hashCode() : 0);