blob: 5417d4447174159e96de57beb39971efc10f9b22 [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 com.google.common.collect.ImmutableSet;
20import org.onosproject.net.pi.model.PiActionProfileId;
21import org.onosproject.net.pi.model.PiActionProfileModel;
22import org.onosproject.net.pi.model.PiTableId;
23
24import java.util.Collection;
25import java.util.Objects;
26
27/**
28 * Implementation of PiActionProfileModel for P4Runtime.
29 */
30final class P4ActionProfileModel implements PiActionProfileModel {
31
32 private final PiActionProfileId id;
33 private final ImmutableSet<PiTableId> tables;
34 private final boolean hasSelector;
35 private final long maxSize;
36
37 P4ActionProfileModel(PiActionProfileId id,
38 ImmutableSet<PiTableId> tables, boolean hasSelector, long maxSize) {
39 this.id = id;
40 this.tables = tables;
41 this.hasSelector = hasSelector;
42 this.maxSize = maxSize;
43 }
44
45 @Override
46 public PiActionProfileId id() {
47 return id;
48 }
49
50 @Override
51 public Collection<PiTableId> tables() {
52 return tables;
53 }
54
55 @Override
56 public boolean hasSelector() {
57 return hasSelector;
58 }
59
60 @Override
61 public long maxSize() {
62 return maxSize;
63 }
64
65 @Override
66 public int hashCode() {
67 return Objects.hash(id, tables, hasSelector, maxSize);
68 }
69
70 @Override
71 public boolean equals(Object obj) {
72 if (this == obj) {
73 return true;
74 }
75 if (obj == null || getClass() != obj.getClass()) {
76 return false;
77 }
78 final P4ActionProfileModel other = (P4ActionProfileModel) obj;
79 return Objects.equals(this.id, other.id)
80 && Objects.equals(this.tables, other.tables)
81 && Objects.equals(this.hasSelector, other.hasSelector)
82 && Objects.equals(this.maxSize, other.maxSize);
83 }
84}