BUG-6650: ep-ip/sgt, update/rename models and yangs for sxp-ise-adapter
[groupbasedpolicy.git] / sxp-mapper / src / main / java / org / opendaylight / groupbasedpolicy / sxp / mapper / impl / util / SubnetInfoKeyDecorator.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.groupbasedpolicy.sxp.mapper.impl.util;
9
10 import org.apache.commons.net.util.SubnetUtils;
11
12 /**
13  * Purpose: wraps {@link SubnetUtils.SubnetInfo} and overwrites hashcode and equals methods in order to
14  * be applicable as map key
15  *
16  */
17 public class SubnetInfoKeyDecorator {
18
19     private final SubnetUtils.SubnetInfo delegate;
20
21     public SubnetInfoKeyDecorator(final SubnetUtils.SubnetInfo delegate) {
22         this.delegate = delegate;
23     }
24
25     public SubnetUtils.SubnetInfo getDelegate() {
26         return delegate;
27     }
28
29     @Override
30     public boolean equals(final Object o) {
31         if (this == o) return true;
32         if (o == null || getClass() != o.getClass()) return false;
33
34         final SubnetInfoKeyDecorator that = (SubnetInfoKeyDecorator) o;
35
36         return delegate.getCidrSignature().equals(that.delegate.getCidrSignature());
37
38     }
39
40     @Override
41     public int hashCode() {
42         return delegate.getCidrSignature().hashCode();
43     }
44 }