Esin Karaman | 971fb7f | 2017-12-28 13:44:52 +0000 | [diff] [blame^] | 1 | /* |
| 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 | */ |
| 17 | |
| 18 | package org.onosproject.drivers.bmv2.api.runtime; |
| 19 | |
| 20 | |
| 21 | import com.google.common.base.Objects; |
| 22 | import com.google.common.collect.ImmutableSet; |
| 23 | |
| 24 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 25 | import static com.google.common.base.Preconditions.checkNotNull; |
| 26 | |
| 27 | /** |
| 28 | * Immutable collection of BMv2 PRE group nodes. |
| 29 | */ |
| 30 | public final class Bmv2PreNodes { |
| 31 | private final ImmutableSet<Bmv2PreNode> nodes; |
| 32 | |
| 33 | /** |
| 34 | * Creates a immutable list of group nodes. |
| 35 | * |
| 36 | * @param nodes list of group nodes |
| 37 | */ |
| 38 | public Bmv2PreNodes(ImmutableSet<Bmv2PreNode> nodes) { |
| 39 | this.nodes = checkNotNull(nodes); |
| 40 | } |
| 41 | |
| 42 | public ImmutableSet<Bmv2PreNode> nodes() { |
| 43 | return nodes; |
| 44 | } |
| 45 | |
| 46 | @Override |
| 47 | public int hashCode() { |
| 48 | return Objects.hashCode(nodes); |
| 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public boolean equals(Object obj) { |
| 53 | if (obj instanceof Bmv2PreNodes) { |
| 54 | return (this.nodes.containsAll(((Bmv2PreNodes) obj).nodes) && |
| 55 | ((Bmv2PreNodes) obj).nodes.containsAll(this.nodes)); |
| 56 | } |
| 57 | return false; |
| 58 | } |
| 59 | |
| 60 | @Override |
| 61 | public String toString() { |
| 62 | return toStringHelper(this) |
| 63 | .add("nodes", nodes) |
| 64 | .toString(); |
| 65 | } |
| 66 | } |