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 {
24 private final int port;
26 public ActionSetUdpDestinationPort(int port) {
30 public ActionSetUdpDestinationPort(int actionKey, int port) {
36 public Action buildAction() {
37 return buildAction(getActionKey());
41 public Action buildAction(int newActionKey) {
42 return new ActionBuilder()
43 .setAction(new SetFieldCaseBuilder()
44 .setSetField(new SetFieldBuilder()
45 .setLayer4Match(new UdpMatchBuilder()
46 .setUdpDestinationPort(new PortNumber(port)).build())
49 .setKey(new ActionKey(newActionKey))
53 public int getPort() {
58 public boolean equals(Object other) {
62 if (other == null || getClass() != other.getClass()) {
65 if (!super.equals(other)) {
69 ActionSetUdpDestinationPort that = (ActionSetUdpDestinationPort) other;
71 return port == that.port;
75 public int hashCode() {
76 int result = super.hashCode();
77 result = 31 * result + port;
82 public String toString() {
83 return "ActionSetUdpDestinationPort [port=" + port + ", getActionKey()=" + getActionKey() + "]";