blob: 45e7edc8ad658115ae16b517418172f3e18983cc [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.PiControlMetadataId;
20import org.onosproject.net.pi.model.PiControlMetadataModel;
21
22import java.util.Objects;
23
24/**
25 * Implementation of PiControlMetadataModel for P4Runtime.
26 */
27final class P4ControlMetadataModel implements PiControlMetadataModel {
28
29 private final PiControlMetadataId id;
30 private final int bitWidth;
31
32 P4ControlMetadataModel(PiControlMetadataId id, int bitWidth) {
33 this.id = id;
34 this.bitWidth = bitWidth;
35 }
36
37 @Override
38 public PiControlMetadataId id() {
39 return id;
40 }
41
42 @Override
43 public int bitWidth() {
44 return bitWidth;
45 }
46
47 @Override
48 public int hashCode() {
49 return Objects.hash(id, bitWidth);
50 }
51
52 @Override
53 public boolean equals(Object obj) {
54 if (this == obj) {
55 return true;
56 }
57 if (obj == null || getClass() != obj.getClass()) {
58 return false;
59 }
60 final P4ControlMetadataModel other = (P4ControlMetadataModel) obj;
61 return Objects.equals(this.id, other.id)
62 && Objects.equals(this.bitWidth, other.bitWidth);
63 }
64}