Jonathan Hart | 23701d1 | 2014-04-03 10:45:48 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.util; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 2 | |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 3 | import org.codehaus.jackson.annotate.JsonProperty; |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 4 | |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 5 | /** |
| 6 | * The class representing a Caller ID for an ONOS component. |
| 7 | */ |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 8 | public class CallerId { |
| 9 | private String value; |
| 10 | |
| 11 | /** |
| 12 | * Default constructor. |
| 13 | */ |
| 14 | public CallerId() {} |
Jonathan Hart | 0444d93 | 2014-01-22 15:06:17 -0800 | [diff] [blame] | 15 | |
| 16 | /** |
| 17 | * Copy constructor |
| 18 | * @param otherCallerId |
| 19 | */ |
| 20 | public CallerId(CallerId otherCallerId) { |
Jonathan Hart | 84198d3 | 2014-01-22 17:14:37 -0800 | [diff] [blame] | 21 | // Note: make a full copy if we change value to a mutable type |
Jonathan Hart | 0444d93 | 2014-01-22 15:06:17 -0800 | [diff] [blame] | 22 | value = otherCallerId.value; |
| 23 | } |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 24 | |
| 25 | /** |
| 26 | * Constructor from a string value. |
| 27 | * |
| 28 | * @param value the value to use. |
| 29 | */ |
| 30 | public CallerId(String value) { |
| 31 | this.value = value; |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Get the value of the Caller ID. |
| 36 | * |
| 37 | * @return the value of the Caller ID. |
| 38 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 39 | @JsonProperty("value") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 40 | public String value() { return value; } |
| 41 | |
| 42 | /** |
| 43 | * Set the value of the Caller ID. |
| 44 | * |
| 45 | * @param value the value to set. |
| 46 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 47 | @JsonProperty("value") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 48 | public void setValue(String value) { |
| 49 | this.value = value; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Convert the Caller ID value to a string. |
| 54 | * |
| 55 | * @return the Caller ID value to a string. |
| 56 | */ |
| 57 | @Override |
| 58 | public String toString() { |
| 59 | return value; |
| 60 | } |
Jonathan Hart | 0444d93 | 2014-01-22 15:06:17 -0800 | [diff] [blame] | 61 | |
| 62 | @Override |
| 63 | public boolean equals(Object other) { |
| 64 | if (!(other instanceof CallerId)) { |
| 65 | return false; |
| 66 | } |
| 67 | |
| 68 | CallerId otherCallerId = (CallerId) other; |
| 69 | |
| 70 | return value.equals(otherCallerId.value); |
| 71 | } |
| 72 | |
| 73 | @Override |
| 74 | public int hashCode() { |
| 75 | return value.hashCode(); |
| 76 | } |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 77 | } |