blob: 9a32a7065f2ce4aa07b628f942f081dc5f2464ec [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
19import com.google.common.base.MoreObjects;
20import com.google.common.base.Objects;
21
22/**
Carmelo Cascone25f18882016-06-14 19:16:50 -070023 * Representation of a table entry installed on a BMv2 device.
Carmelo Cascone17fc9e42016-05-31 11:29:21 -070024 */
25public final class Bmv2ParsedTableEntry {
26 private final long entryId;
27 private final Bmv2MatchKey matchKey;
28 private final Bmv2Action action;
Carmelo Cascone25f18882016-06-14 19:16:50 -070029 private final int priority;
Carmelo Cascone17fc9e42016-05-31 11:29:21 -070030
31 /**
32 * Creates a new parsed table entry.
33 *
Carmelo Cascone25f18882016-06-14 19:16:50 -070034 * @param entryId a long value
Carmelo Cascone17fc9e42016-05-31 11:29:21 -070035 * @param matchKey a match key
36 * @param action an action
Carmelo Cascone25f18882016-06-14 19:16:50 -070037 * @param priority an integer value
Carmelo Cascone17fc9e42016-05-31 11:29:21 -070038 */
Carmelo Cascone25f18882016-06-14 19:16:50 -070039 public Bmv2ParsedTableEntry(long entryId, Bmv2MatchKey matchKey, Bmv2Action action, int priority) {
Carmelo Cascone17fc9e42016-05-31 11:29:21 -070040 this.entryId = entryId;
41 this.matchKey = matchKey;
42 this.action = action;
Carmelo Cascone25f18882016-06-14 19:16:50 -070043 this.priority = priority;
Carmelo Cascone17fc9e42016-05-31 11:29:21 -070044 }
45
46 /**
47 * Returns the entry ID.
48 *
49 * @return a long value
50 */
51 public long entryId() {
52 return entryId;
53 }
54
55 /**
56 * Returns the match key.
57 *
58 * @return a match key object
59 */
60 public Bmv2MatchKey matchKey() {
61 return matchKey;
62 }
63
64 /**
65 * Returns the action.
66 *
67 * @return an action object
68 */
69 public Bmv2Action action() {
70 return action;
71 }
72
Carmelo Cascone25f18882016-06-14 19:16:50 -070073 /**
74 * Returns the priority.
75 *
76 * @return an integer value
77 */
78 public int getPriority() {
79 return priority;
80 }
81
Carmelo Cascone17fc9e42016-05-31 11:29:21 -070082 @Override
83 public int hashCode() {
Carmelo Cascone25f18882016-06-14 19:16:50 -070084 return Objects.hashCode(entryId, matchKey, action, priority);
Carmelo Cascone17fc9e42016-05-31 11:29:21 -070085 }
86
87 @Override
88 public boolean equals(Object obj) {
89 if (this == obj) {
90 return true;
91 }
92 if (obj == null || getClass() != obj.getClass()) {
93 return false;
94 }
95 final Bmv2ParsedTableEntry other = (Bmv2ParsedTableEntry) obj;
96 return Objects.equal(this.entryId, other.entryId)
97 && Objects.equal(this.matchKey, other.matchKey)
Carmelo Cascone25f18882016-06-14 19:16:50 -070098 && Objects.equal(this.action, other.action)
99 && Objects.equal(this.priority, other.priority);
Carmelo Cascone17fc9e42016-05-31 11:29:21 -0700100 }
101
102 @Override
103 public String toString() {
104 return MoreObjects.toStringHelper(this)
105 .add("entryId", entryId)
106 .add("matchKey", matchKey)
107 .add("action", action)
108 .toString();
109 }
110}