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.HashSet;
12 import java.util.List;
15 import com.google.common.base.Equivalence;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket;
20 * Custom Equivalence for {@link Buckets}
22 * @see GroupEquivalence
24 public class BucketsEquivalence extends Equivalence<Buckets> {
26 BucketsEquivalence() {
30 protected boolean doEquivalent(Buckets a, Buckets b) {
32 Set<Bucket> setA = new HashSet<>();
33 Set<Bucket> setB = new HashSet<>();
34 if (a.getBucket() != null) {
35 setA = new HashSet<>(a.getBucket());
37 if (b.getBucket() != null) {
38 setB = new HashSet<>(b.getBucket());
40 return setA.equals(setB);
44 protected int doHash(Buckets buckets) {
48 List<Bucket> bucketList = buckets.getBucket();
49 Set<Bucket> bucketSet = new HashSet<>();
50 if (bucketList != null) {
51 bucketSet = new HashSet<>(bucketList);
53 result = prime * result + bucketSet.hashCode();