2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.groupbasedpolicy.renderer.ofoverlay.equivalence;
11 import java.util.Objects;
13 import com.google.common.base.Equivalence;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
16 public class GroupEquivalence extends Equivalence<Group> {
22 protected boolean doEquivalent(Group a, Group b) {
24 if (!EquivalenceFabric.BUCKETS_EQUIVALENCE.equivalent(a.getBuckets(), b.getBuckets())) {
28 if (!Objects.equals(a.getContainerName(), b.getContainerName())) {
32 if (!Objects.equals(a.getGroupName(), b.getGroupName())) {
36 if (!Objects.equals(a.getGroupType(), b.getGroupType())) {
40 if (!Objects.equals(a.isBarrier(), b.isBarrier())) {
48 protected int doHash(Group group) {
52 result = prime * result + ((group.getBuckets() == null) ? 0
53 : EquivalenceFabric.BUCKETS_EQUIVALENCE.wrap(group.getBuckets()).hashCode());
54 result = prime * result + ((group.getContainerName() == null) ? 0
55 : group.getContainerName().hashCode());
56 result = prime * result + ((group.getGroupName() == null) ? 0
57 : group.getGroupName().hashCode());
58 result = prime * result + ((group.getGroupType() == null) ? 0
59 : group.getGroupType().hashCode());
60 result = prime * result + ((group.isBarrier() == null) ? 0 : group.isBarrier().hashCode());