blob: d4a6c4dbe9f4f6ad193ca72fe4ede910b7032298 [file] [log] [blame]
Carmelo Cascone87892e22017-11-13 16:01:29 -08001/*
2 * Copyright 2017-present Open Networking Foundation
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.p4runtime.model;
18
19import org.onosproject.net.pi.model.PiActionParamId;
20import org.onosproject.net.pi.model.PiActionParamModel;
21
22import java.util.Objects;
23
pierventre4d2a5422021-01-10 17:29:03 -080024import static com.google.common.base.MoreObjects.toStringHelper;
25
Carmelo Cascone87892e22017-11-13 16:01:29 -080026/**
27 * Implementation of PiActionParamModel for P4Runtime.
28 */
29final class P4ActionParamModel implements PiActionParamModel {
30
31 private final PiActionParamId id;
32 private final int bitWidth;
33
34 P4ActionParamModel(PiActionParamId id, int bitWidth) {
35 this.id = id;
36 this.bitWidth = bitWidth;
37 }
38
39 @Override
40 public PiActionParamId id() {
41 return id;
42 }
43
44 @Override
45 public int bitWidth() {
46 return bitWidth;
47 }
48
49 @Override
50 public int hashCode() {
51 return Objects.hash(id, bitWidth);
52 }
53
54 @Override
55 public boolean equals(Object obj) {
56 if (this == obj) {
57 return true;
58 }
59 if (obj == null || getClass() != obj.getClass()) {
60 return false;
61 }
62 final P4ActionParamModel other = (P4ActionParamModel) obj;
63 return Objects.equals(this.id, other.id)
64 && Objects.equals(this.bitWidth, other.bitWidth);
65 }
pierventre4d2a5422021-01-10 17:29:03 -080066
67 @Override
68 public String toString() {
69 return toStringHelper(this)
70 .add("id", id)
71 .add("bitWidth", bitWidth)
72 .toString();
73 }
Carmelo Cascone87892e22017-11-13 16:01:29 -080074}