Add missing @Override and serialVersionUID to genius.mdsalutil
[genius.git] / mdsalutil / mdsalutil-api / src / main / java / org / opendaylight / genius / mdsalutil / actions / ActionSetFieldMplsLabel.java
1 /*
2  * Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved.
3  *
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
7  */
8 package org.opendaylight.genius.mdsalutil.actions;
9
10 import org.opendaylight.genius.mdsalutil.ActionInfo;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder;
17
18 /**
19  * Set MPLS label field action.
20  */
21 public class ActionSetFieldMplsLabel extends ActionInfo {
22     private static final long serialVersionUID = 1L;
23
24     private final long label;
25
26     public ActionSetFieldMplsLabel(long label) {
27         this(0, label);
28     }
29
30     public ActionSetFieldMplsLabel(int actionKey, long label) {
31         super(actionKey);
32         this.label = label;
33     }
34
35     @Override
36     public Action buildAction() {
37         return buildAction(getActionKey());
38     }
39
40     @Override
41     public Action buildAction(int newActionKey) {
42         return new ActionBuilder()
43             .setAction(
44                 new SetFieldCaseBuilder()
45                     .setSetField(
46                         new SetFieldBuilder()
47                             .setProtocolMatchFields(
48                                 new ProtocolMatchFieldsBuilder().setMplsLabel(label).build())
49                             .build())
50                     .build())
51             .setKey(new ActionKey(newActionKey))
52             .build();
53     }
54
55     @Override
56     public boolean equals(Object other) {
57         if (this == other) {
58             return true;
59         }
60         if (other == null || getClass() != other.getClass()) {
61             return false;
62         }
63         if (!super.equals(other)) {
64             return false;
65         }
66
67         ActionSetFieldMplsLabel that = (ActionSetFieldMplsLabel) other;
68
69         return label == that.label;
70     }
71
72     @Override
73     public int hashCode() {
74         int result = super.hashCode();
75         result = 31 * result + (int) (label ^ label >>> 32);
76         return result;
77     }
78 }