blob: f58d69fc8cdaa842a5fce14ff7cff39aab052ba8 [file] [log] [blame]
Jonathan Hart23701d12014-04-03 10:45:48 -07001package net.onrc.onos.core.util;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -08002
Pavlin Radoslavovad008e02013-02-21 18:42:42 -08003import org.codehaus.jackson.annotate.JsonProperty;
Pavlin Radoslavovad008e02013-02-21 18:42:42 -08004
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -08005/**
6 * The class representing a Caller ID for an ONOS component.
7 */
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -08008public class CallerId {
9 private String value;
10
11 /**
12 * Default constructor.
13 */
Ray Milkey269ffb92014-04-03 14:43:30 -070014 public CallerId() {
15 }
16
Jonathan Hart0444d932014-01-22 15:06:17 -080017 /**
18 * Copy constructor
Ray Milkey269ffb92014-04-03 14:43:30 -070019 *
Jonathan Hart0444d932014-01-22 15:06:17 -080020 * @param otherCallerId
21 */
22 public CallerId(CallerId otherCallerId) {
Ray Milkey269ffb92014-04-03 14:43:30 -070023 // Note: make a full copy if we change value to a mutable type
24 value = otherCallerId.value;
Jonathan Hart0444d932014-01-22 15:06:17 -080025 }
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080026
27 /**
28 * Constructor from a string value.
29 *
30 * @param value the value to use.
31 */
32 public CallerId(String value) {
Ray Milkey269ffb92014-04-03 14:43:30 -070033 this.value = value;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080034 }
35
36 /**
37 * Get the value of the Caller ID.
38 *
39 * @return the value of the Caller ID.
40 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080041 @JsonProperty("value")
Ray Milkey269ffb92014-04-03 14:43:30 -070042 public String value() {
43 return value;
44 }
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080045
46 /**
47 * Set the value of the Caller ID.
48 *
49 * @param value the value to set.
50 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080051 @JsonProperty("value")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080052 public void setValue(String value) {
Ray Milkey269ffb92014-04-03 14:43:30 -070053 this.value = value;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080054 }
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 Milkey269ffb92014-04-03 14:43:30 -070063 return value;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080064 }
Ray Milkey269ffb92014-04-03 14:43:30 -070065
Jonathan Hart0444d932014-01-22 15:06:17 -080066 @Override
67 public boolean equals(Object other) {
Ray Milkey269ffb92014-04-03 14:43:30 -070068 if (!(other instanceof CallerId)) {
69 return false;
70 }
71
72 CallerId otherCallerId = (CallerId) other;
73
74 return value.equals(otherCallerId.value);
Jonathan Hart0444d932014-01-22 15:06:17 -080075 }
Ray Milkey269ffb92014-04-03 14:43:30 -070076
Jonathan Hart0444d932014-01-22 15:06:17 -080077 @Override
78 public int hashCode() {
Ray Milkey269ffb92014-04-03 14:43:30 -070079 return value.hashCode();
Jonathan Hart0444d932014-01-22 15:06:17 -080080 }
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080081}