2 * Copyright © 2016 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.actions;
10 import org.opendaylight.genius.mdsalutil.ActionInfo;
11 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
20 * Set UDP destination port action.
22 public class ActionSetUdpDestinationPort extends ActionInfo {
23 private static final long serialVersionUID = 1L;
25 private final int port;
27 public ActionSetUdpDestinationPort(int port) {
31 public ActionSetUdpDestinationPort(int actionKey, int port) {
37 public Action buildAction() {
38 return buildAction(getActionKey());
42 public Action buildAction(int newActionKey) {
43 return new ActionBuilder()
44 .setAction(new SetFieldCaseBuilder()
45 .setSetField(new SetFieldBuilder()
46 .setLayer4Match(new UdpMatchBuilder()
47 .setUdpDestinationPort(new PortNumber(port)).build())
50 .setKey(new ActionKey(newActionKey))
54 public int getPort() {
59 public boolean equals(Object other) {
63 if (other == null || getClass() != other.getClass()) {
66 if (!super.equals(other)) {
70 ActionSetUdpDestinationPort that = (ActionSetUdpDestinationPort) other;
72 return port == that.port;
76 public int hashCode() {
77 int result = super.hashCode();
78 result = 31 * result + port;
83 public String toString() {
84 return "ActionSetUdpDestinationPort [port=" + port + ", getActionKey()=" + getActionKey() + "]";