Merge "Randomize port to allow concurrent execution"
[bgpcep.git] / pcep / api / src / main / java / org / opendaylight / protocol / pcep / object / PCEPLoadBalancingObject.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.pcep.object;
9
10 import org.opendaylight.protocol.pcep.PCEPObject;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nps.concepts.rev130930.Bandwidth;
12
13 import com.google.common.base.Objects.ToStringHelper;
14
15 /**
16  * Structure for PCEP Load Balancing Object.
17  * 
18  * @see <a href="http://tools.ietf.org/html/rfc5440#section-7.16">PCEP Load Balancing Object</a>
19  */
20 public class PCEPLoadBalancingObject extends PCEPObject {
21
22         private final int maxLSP;
23
24         private final Bandwidth minBandwidth;
25
26         /**
27          * Constructs Load Balancing Object.
28          * 
29          * @param maxLSP int
30          * @param minBandwidth Bandwidth
31          * @param processed boolean
32          */
33         public PCEPLoadBalancingObject(final int maxLSP, final Bandwidth minBandwidth, final boolean processed) {
34                 super(processed, false);
35                 this.maxLSP = maxLSP;
36                 this.minBandwidth = minBandwidth;
37         }
38
39         /**
40          * Gets Maximum LSP.
41          * 
42          * @return int
43          */
44         public int getMaxLSP() {
45                 return this.maxLSP;
46         }
47
48         /**
49          * Gets Minimal bandwidth.
50          * 
51          * @return Bandwidth
52          */
53         public Bandwidth getMinBandwidth() {
54                 return this.minBandwidth;
55         }
56
57         @Override
58         public int hashCode() {
59                 final int prime = 31;
60                 int result = super.hashCode();
61                 result = prime * result + this.maxLSP;
62                 result = prime * result + ((this.minBandwidth == null) ? 0 : this.minBandwidth.hashCode());
63                 return result;
64         }
65
66         @Override
67         public boolean equals(final Object obj) {
68                 if (this == obj)
69                         return true;
70                 if (!super.equals(obj))
71                         return false;
72                 if (this.getClass() != obj.getClass())
73                         return false;
74                 final PCEPLoadBalancingObject other = (PCEPLoadBalancingObject) obj;
75                 if (this.maxLSP != other.maxLSP)
76                         return false;
77                 if (this.minBandwidth == null) {
78                         if (other.minBandwidth != null)
79                                 return false;
80                 } else if (!this.minBandwidth.equals(other.minBandwidth))
81                         return false;
82                 return true;
83         }
84
85         @Override
86         protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
87                 toStringHelper.add("maxLSP", this.maxLSP);
88                 toStringHelper.add("minBandwidth", this.minBandwidth);
89                 return super.addToStringAttributes(toStringHelper);
90         }
91 }