blob: bf59cf46ee48e25718a73e929e3417e7848ffe91 [file] [log] [blame]
Carmelo Cascone17fc9e42016-05-31 11:29:21 -07001/*
2 * Copyright 2016-present Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.bmv2.api.runtime;
18
Carmelo Cascone9e39e312016-06-16 14:47:09 -070019import com.google.common.annotations.Beta;
Carmelo Cascone17fc9e42016-05-31 11:29:21 -070020import com.google.common.base.MoreObjects;
21import com.google.common.base.Objects;
22
23/**
Carmelo Cascone25f18882016-06-14 19:16:50 -070024 * Representation of a table entry installed on a BMv2 device.
Carmelo Cascone17fc9e42016-05-31 11:29:21 -070025 */
Carmelo Cascone9e39e312016-06-16 14:47:09 -070026@Beta
Carmelo Cascone17fc9e42016-05-31 11:29:21 -070027public final class Bmv2ParsedTableEntry {
28 private final long entryId;
29 private final Bmv2MatchKey matchKey;
30 private final Bmv2Action action;
Carmelo Cascone25f18882016-06-14 19:16:50 -070031 private final int priority;
Carmelo Cascone17fc9e42016-05-31 11:29:21 -070032
33 /**
34 * Creates a new parsed table entry.
35 *
Carmelo Cascone25f18882016-06-14 19:16:50 -070036 * @param entryId a long value
Carmelo Cascone17fc9e42016-05-31 11:29:21 -070037 * @param matchKey a match key
38 * @param action an action
Carmelo Cascone25f18882016-06-14 19:16:50 -070039 * @param priority an integer value
Carmelo Cascone17fc9e42016-05-31 11:29:21 -070040 */
Carmelo Cascone25f18882016-06-14 19:16:50 -070041 public Bmv2ParsedTableEntry(long entryId, Bmv2MatchKey matchKey, Bmv2Action action, int priority) {
Carmelo Cascone17fc9e42016-05-31 11:29:21 -070042 this.entryId = entryId;
43 this.matchKey = matchKey;
44 this.action = action;
Carmelo Cascone25f18882016-06-14 19:16:50 -070045 this.priority = priority;
Carmelo Cascone17fc9e42016-05-31 11:29:21 -070046 }
47
48 /**
49 * Returns the entry ID.
50 *
51 * @return a long value
52 */
53 public long entryId() {
54 return entryId;
55 }
56
57 /**
58 * Returns the match key.
59 *
60 * @return a match key object
61 */
62 public Bmv2MatchKey matchKey() {
63 return matchKey;
64 }
65
66 /**
67 * Returns the action.
68 *
69 * @return an action object
70 */
71 public Bmv2Action action() {
72 return action;
73 }
74
Carmelo Cascone25f18882016-06-14 19:16:50 -070075 /**
76 * Returns the priority.
77 *
78 * @return an integer value
79 */
80 public int getPriority() {
81 return priority;
82 }
83
Carmelo Cascone17fc9e42016-05-31 11:29:21 -070084 @Override
85 public int hashCode() {
Carmelo Cascone25f18882016-06-14 19:16:50 -070086 return Objects.hashCode(entryId, matchKey, action, priority);
Carmelo Cascone17fc9e42016-05-31 11:29:21 -070087 }
88
89 @Override
90 public boolean equals(Object obj) {
91 if (this == obj) {
92 return true;
93 }
94 if (obj == null || getClass() != obj.getClass()) {
95 return false;
96 }
97 final Bmv2ParsedTableEntry other = (Bmv2ParsedTableEntry) obj;
98 return Objects.equal(this.entryId, other.entryId)
99 && Objects.equal(this.matchKey, other.matchKey)
Carmelo Cascone25f18882016-06-14 19:16:50 -0700100 && Objects.equal(this.action, other.action)
101 && Objects.equal(this.priority, other.priority);
Carmelo Cascone17fc9e42016-05-31 11:29:21 -0700102 }
103
104 @Override
105 public String toString() {
106 return MoreObjects.toStringHelper(this)
107 .add("entryId", entryId)
108 .add("matchKey", matchKey)
109 .add("action", action)
110 .toString();
111 }
112}