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.yang.types.rev130715.MacAddress;
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.ethernet.match.fields.EthernetSourceBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
21 * Set Ethernet source field action.
23 public class ActionSetFieldEthernetSource extends ActionInfo {
25 private final MacAddress source;
27 public ActionSetFieldEthernetSource(MacAddress source) {
31 public ActionSetFieldEthernetSource(int actionKey, MacAddress source) {
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 .setEthernetMatch(new EthernetMatchBuilder()
47 .setEthernetSource(new EthernetSourceBuilder().setAddress(source).build())
51 .setKey(new ActionKey(newActionKey))
55 public MacAddress getSource() {
60 public boolean equals(Object other) {
64 if (other == null || getClass() != other.getClass()) {
67 if (!super.equals(other)) {
71 ActionSetFieldEthernetSource that = (ActionSetFieldEthernetSource) other;
73 return source != null ? source.equals(that.source) : that.source == null;
77 public int hashCode() {
78 int result = super.hashCode();
79 result = 31 * result + (source != null ? source.hashCode() : 0);
84 public String toString() {
85 return "ActionSetFieldEthernetSource [source=" + source + ", getActionKey()=" + getActionKey() + "]";