Merge "Randomize port to allow concurrent execution"
[bgpcep.git] / pcep / api / src / main / java / org / opendaylight / protocol / pcep / tlv / LSPCleanupTlv.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 org.opendaylight.protocol.pcep.PCEPTlv;
11
12 /**
13  * Structure of LSP Cleanup Tlv
14  *
15  * @see <a href="http://www.ietf.org/id/draft-crabbe-pce-pce-initiated-lsp-00.txt#section-6.2.1">LSP-CLEANUP TLV</a>
16  */
17 public class LSPCleanupTlv implements PCEPTlv {
18
19         private static final long serialVersionUID = -2540695596612553355L;
20
21         private final int timeout;
22
23         /**
24          * Creates new LSP Cleanup Tlv.
25          *
26          */
27         public LSPCleanupTlv(int timeout) {
28                 if (timeout < 0 || timeout > Integer.MAX_VALUE)
29                         throw new IllegalArgumentException("Timeout (" + timeout + ") cannot be negative or bigger than 2^31 -1.");
30                 this.timeout = timeout;
31         }
32
33         /**
34          * @return the timeout
35          */
36         public final int getTimeout() {
37                 return this.timeout;
38         }
39
40         /* (non-Javadoc)
41          * @see java.lang.Object#hashCode()
42          */
43         @Override
44         public int hashCode() {
45                 final int prime = 31;
46                 int result = 1;
47                 result = prime * result + this.timeout;
48                 return result;
49         }
50
51         /* (non-Javadoc)
52          * @see java.lang.Object#equals(java.lang.Object)
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 (!(obj instanceof LSPCleanupTlv))
61                         return false;
62                 final LSPCleanupTlv other = (LSPCleanupTlv) obj;
63                 if (this.timeout != other.timeout)
64                         return false;
65                 return true;
66         }
67
68         /* (non-Javadoc)
69          * @see java.lang.Object#toString()
70          */
71         @Override
72         public String toString() {
73                 final StringBuilder builder = new StringBuilder();
74                 builder.append("LSPCleanupTlv [timeout=");
75                 builder.append(this.timeout);
76                 builder.append("]");
77                 return builder.toString();
78         }
79 }