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