Merge "Randomize port to allow concurrent execution"
[bgpcep.git] / pcep / api / src / main / java / org / opendaylight / protocol / pcep / tlv / OFListTlv.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.tlv;
9
10 import java.util.List;
11
12 import org.opendaylight.protocol.pcep.PCEPOFCodes;
13 import org.opendaylight.protocol.pcep.PCEPTlv;
14
15 /**
16  * It MAY be carried within an OPEN object sent by a PCE in an Open message to a
17  * PCEP peer so as to indicate the list of supported objective functions.
18  * 
19  * @see <a href="http://tools.ietf.org/html/rfc5541#section-2.1">OF-List TLV</a>
20  */
21 public class OFListTlv implements PCEPTlv {
22         private static final long serialVersionUID = 3409582385994162451L;
23
24         private final List<PCEPOFCodes> ofCodes;
25
26         /**
27          * Constructs new objective functions list tlv
28          * 
29          * @param ofCodes
30          *            lit of objective functions
31          */
32         public OFListTlv(List<PCEPOFCodes> ofCodes) {
33                 super();
34                 this.ofCodes = ofCodes;
35         }
36
37         /**
38          * Gets list of objective functions
39          * 
40          * @return list of objective functions
41          */
42         public List<PCEPOFCodes> getOfCodes() {
43                 return this.ofCodes;
44         }
45
46         @Override
47         public int hashCode() {
48                 final int prime = 31;
49                 int result = 1;
50                 result = prime * result + ((this.ofCodes == null) ? 0 : this.ofCodes.hashCode());
51                 return result;
52         }
53
54         @Override
55         public boolean equals(Object obj) {
56                 if (this == obj)
57                         return true;
58                 if (obj == null)
59                         return false;
60                 if (this.getClass() != obj.getClass())
61                         return false;
62                 final OFListTlv other = (OFListTlv) obj;
63                 if (this.ofCodes == null) {
64                         if (other.ofCodes != null)
65                                 return false;
66                 } else if (!this.ofCodes.equals(other.ofCodes))
67                         return false;
68                 return true;
69         }
70
71         @Override
72         public String toString() {
73                 final StringBuilder builder = new StringBuilder();
74                 builder.append("OFListTlv [ofCodes=");
75                 builder.append(this.ofCodes);
76                 builder.append("]");
77                 return builder.toString();
78         }
79
80 }