blob: 7e4fcdaf1c889bd87bfc53dae0baf6a2fb92228d [file] [log] [blame]
FrankWang2674e452018-05-24 17:13:35 +08001/*
2 * Copyright 2018-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.PiRegisterModel;
20import org.onosproject.net.pi.model.PiRegisterId;
21
22import java.util.Objects;
23
24/**
25 * Implementation of PiRegisterModel for P4Runtime.
26 */
27final class P4RegisterModel implements PiRegisterModel {
28
29 private final PiRegisterId id;
30 private final long size;
31
32 P4RegisterModel(PiRegisterId id, long size) {
33 this.id = id;
34 this.size = size;
35 }
36
37 @Override
38 public PiRegisterId id() {
39 return id;
40 }
41
42 @Override
43 public long size() {
44 return size;
45 }
46
47 @Override
48 public int hashCode() {
49 return Objects.hash(id, size);
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 P4RegisterModel other = (P4RegisterModel) obj;
61 return Objects.equals(this.id, other.id)
62 && Objects.equals(this.size, other.size);
63 }
64}