Two more Equals/HashCode/StringBuilder replacements
[controller.git] / opendaylight / sal / api / src / main / java / org / opendaylight / controller / sal / core / Tier.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  * and is available at http://www.eclipse.org/legal/epl-v10.html
8  */
9
10 package org.opendaylight.controller.sal.core;
11
12 import javax.xml.bind.annotation.XmlElement;
13 import javax.xml.bind.annotation.XmlRootElement;
14
15 /**
16  * The class represents the Tier property of a node
17  *
18  *
19  */
20 @XmlRootElement
21 @SuppressWarnings("serial")
22 public class Tier extends Property {
23     @XmlElement
24     private int tierValue;
25     public static final String TierPropName = "tier";
26
27     public Tier(int tier) {
28         super(TierPropName);
29         this.tierValue = tier;
30     }
31
32     /*
33      * Private constructor used for JAXB mapping
34      */
35     private Tier() {
36         super(TierPropName);
37         this.tierValue = 0;
38     }
39
40     public Tier clone() {
41         return new Tier(this.tierValue);
42     }
43
44     public int getValue() {
45         return this.tierValue;
46     }
47
48     @Override
49     public int hashCode() {
50         final int prime = 31;
51         int result = super.hashCode();
52         result = prime * result + tierValue;
53         return result;
54     }
55
56     @Override
57     public boolean equals(Object obj) {
58         if (this == obj)
59             return true;
60         if (!super.equals(obj))
61             return false;
62         if (getClass() != obj.getClass())
63             return false;
64         Tier other = (Tier) obj;
65         if (tierValue != other.tierValue)
66             return false;
67         return true;
68     }
69
70     @Override
71     public String toString() {
72         return "Tier[" + tierValue + "]";
73     }
74 }