BUG-3888 : fix comparing ASnumbers
[bgpcep.git] / bgp / rib-impl / src / main / java / org / opendaylight / protocol / bgp / rib / impl / spi / BGPSessionPreferences.java
1 /*
2  * Copyright (c) 2013 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.spi;
9
10 import java.util.List;
11 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
12 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.open.message.BgpParameters;
14
15 /**
16  * DTO for BGP Session preferences, that contains BGP Open message.
17  */
18 public final class BGPSessionPreferences {
19
20     private final AsNumber as;
21
22     private final int hold;
23
24     private final Ipv4Address bgpId;
25
26     private final List<BgpParameters> params;
27
28     private final AsNumber remoteAs;
29
30     /**
31      * Creates a new DTO for Open message.
32      *
33      * @param as local AS number
34      * @param hold preferred hold timer value, in seconds
35      * @param bgpId local BGP Identifier
36      * @param remoteAs expected remote As Number
37      * @param params list of advertised parameters
38      */
39     public BGPSessionPreferences(final AsNumber as, final int hold, final Ipv4Address bgpId, final AsNumber remoteAs,
40         final List<BgpParameters> params) {
41         this.as = as;
42         this.hold = hold;
43         this.bgpId = bgpId;
44         this.remoteAs = remoteAs;
45         this.params = params;
46     }
47
48     /**
49      * Returns my AS number.
50      *
51      * @return AS number
52      */
53     public AsNumber getMyAs() {
54         return this.as;
55     }
56
57     /**
58      * Returns initial value of HoldTimer.
59      *
60      * @return initial value of HoldTimer
61      */
62     public int getHoldTime() {
63         return this.hold;
64     }
65
66     /**
67      * Returns my BGP Identifier.
68      *
69      * @return BGP identifier
70      */
71     public Ipv4Address getBgpId() {
72         return this.bgpId;
73     }
74
75     /**
76      * Returns expected remote AS number.
77      *
78      * @return AS number
79      */
80     public AsNumber getExpectedRemoteAs() {
81         return this.remoteAs;
82     }
83
84     /**
85      * Gets a list of advertised bgp parameters.
86      *
87      * @return a list of advertised bgp parameters
88      */
89     public List<BgpParameters> getParams() {
90         return this.params;
91     }
92 }