blob: 443d4074910c73164290ea2dee097a26fb345137 [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;
Carmelo Cascone99c59db2019-01-17 15:39:35 -080035 private final long size;
36 private final int maxGroupSize;
Carmelo Cascone87892e22017-11-13 16:01:29 -080037
38 P4ActionProfileModel(PiActionProfileId id,
Carmelo Cascone99c59db2019-01-17 15:39:35 -080039 ImmutableSet<PiTableId> tables, boolean hasSelector,
40 long size, int maxGroupSize) {
Carmelo Cascone87892e22017-11-13 16:01:29 -080041 this.id = id;
42 this.tables = tables;
43 this.hasSelector = hasSelector;
Carmelo Cascone99c59db2019-01-17 15:39:35 -080044 this.size = size;
45 this.maxGroupSize = maxGroupSize;
Carmelo Cascone87892e22017-11-13 16:01:29 -080046 }
47
48 @Override
49 public PiActionProfileId id() {
50 return id;
51 }
52
53 @Override
54 public Collection<PiTableId> tables() {
55 return tables;
56 }
57
58 @Override
59 public boolean hasSelector() {
60 return hasSelector;
61 }
62
63 @Override
Carmelo Cascone99c59db2019-01-17 15:39:35 -080064 public long size() {
65 return size;
66 }
67
68 @Override
69 public int maxGroupSize() {
70 return maxGroupSize;
Carmelo Cascone87892e22017-11-13 16:01:29 -080071 }
72
73 @Override
74 public int hashCode() {
Carmelo Cascone99c59db2019-01-17 15:39:35 -080075 return Objects.hash(id, tables, hasSelector, size, maxGroupSize);
Carmelo Cascone87892e22017-11-13 16:01:29 -080076 }
77
78 @Override
79 public boolean equals(Object obj) {
80 if (this == obj) {
81 return true;
82 }
83 if (obj == null || getClass() != obj.getClass()) {
84 return false;
85 }
86 final P4ActionProfileModel other = (P4ActionProfileModel) obj;
87 return Objects.equals(this.id, other.id)
88 && Objects.equals(this.tables, other.tables)
89 && Objects.equals(this.hasSelector, other.hasSelector)
Carmelo Cascone99c59db2019-01-17 15:39:35 -080090 && Objects.equals(this.size, other.size)
91 && Objects.equals(this.maxGroupSize, other.maxGroupSize);
Carmelo Cascone87892e22017-11-13 16:01:29 -080092 }
93}