Code Clean Up
[bgpcep.git] / bgp / rib-impl / src / main / java / org / opendaylight / protocol / bgp / rib / impl / RouteUpdateKey.java
1 /*
2  * Copyright (c) 2015 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.protocol.bgp.rib.impl;
9
10 import com.google.common.base.Preconditions;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.PeerId;
12 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
13
14 /**
15  * Combined key formed as a concatenation of source peer and route identifiers.
16  * This is used to internally track updates which need to be processed.
17  */
18 final class RouteUpdateKey {
19     private final PeerId peerId;
20     private final PathArgument routeId;
21
22     RouteUpdateKey(final PeerId peerId, final PathArgument routeId) {
23         this.peerId = Preconditions.checkNotNull(peerId);
24         this.routeId = Preconditions.checkNotNull(routeId);
25     }
26
27     PeerId getPeerId() {
28         return this.peerId;
29     }
30
31     PathArgument getRouteId() {
32         return this.routeId;
33     }
34
35     @Override
36     public int hashCode() {
37         final int prime = 31;
38         int result = 1;
39         result = prime * result + this.peerId.hashCode();
40         result = prime * result + this.routeId.hashCode();
41         return result;
42     }
43
44     @Override
45     public boolean equals(final Object obj) {
46         if (this == obj) {
47             return true;
48         }
49         if (!(obj instanceof RouteUpdateKey)) {
50             return false;
51         }
52         RouteUpdateKey other = (RouteUpdateKey) obj;
53         if (!this.peerId.equals(other.peerId)) {
54             return false;
55         }
56         if (!this.routeId.equals(other.routeId)) {
57             return false;
58         }
59         return true;
60     }
61 }