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 | */ | ||||
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 14 | public CallerId() { |
15 | } | ||||
16 | |||||
Jonathan Hart | 0444d93 | 2014-01-22 15:06:17 -0800 | [diff] [blame] | 17 | /** |
18 | * Copy constructor | ||||
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 19 | * |
Jonathan Hart | 0444d93 | 2014-01-22 15:06:17 -0800 | [diff] [blame] | 20 | * @param otherCallerId |
21 | */ | ||||
22 | public CallerId(CallerId otherCallerId) { | ||||
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 23 | // Note: make a full copy if we change value to a mutable type |
24 | value = otherCallerId.value; | ||||
Jonathan Hart | 0444d93 | 2014-01-22 15:06:17 -0800 | [diff] [blame] | 25 | } |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 26 | |
27 | /** | ||||
28 | * Constructor from a string value. | ||||
29 | * | ||||
30 | * @param value the value to use. | ||||
31 | */ | ||||
32 | public CallerId(String value) { | ||||
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 33 | this.value = value; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 34 | } |
35 | |||||
36 | /** | ||||
37 | * Get the value of the Caller ID. | ||||
38 | * | ||||
39 | * @return the value of the Caller ID. | ||||
40 | */ | ||||
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 41 | @JsonProperty("value") |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 42 | public String value() { |
43 | return value; | ||||
44 | } | ||||
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 45 | |
46 | /** | ||||
47 | * Set the value of the Caller ID. | ||||
48 | * | ||||
49 | * @param value the value to set. | ||||
50 | */ | ||||
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 51 | @JsonProperty("value") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 52 | public void setValue(String value) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 53 | this.value = value; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 54 | } |
55 | |||||
56 | /** | ||||
57 | * Convert the Caller ID value to a string. | ||||
58 | * | ||||
59 | * @return the Caller ID value to a string. | ||||
60 | */ | ||||
61 | @Override | ||||
62 | public String toString() { | ||||
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 63 | return value; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 64 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 65 | |
Jonathan Hart | 0444d93 | 2014-01-22 15:06:17 -0800 | [diff] [blame] | 66 | @Override |
67 | public boolean equals(Object other) { | ||||
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 68 | if (!(other instanceof CallerId)) { |
69 | return false; | ||||
70 | } | ||||
71 | |||||
72 | CallerId otherCallerId = (CallerId) other; | ||||
73 | |||||
74 | return value.equals(otherCallerId.value); | ||||
Jonathan Hart | 0444d93 | 2014-01-22 15:06:17 -0800 | [diff] [blame] | 75 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 76 | |
Jonathan Hart | 0444d93 | 2014-01-22 15:06:17 -0800 | [diff] [blame] | 77 | @Override |
78 | public int hashCode() { | ||||
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 79 | return value.hashCode(); |
Jonathan Hart | 0444d93 | 2014-01-22 15:06:17 -0800 | [diff] [blame] | 80 | } |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 81 | } |