Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
UserDataEntryDataMapTrapMapping |
|
| 2.4285714285714284;2,429 |
1 | package net.sf.snmpadaptor4j.core.mapping; | |
2 | ||
3 | import java.io.Serializable; | |
4 | import net.sf.snmpadaptor4j.object.SnmpDataType; | |
5 | import net.sf.snmpadaptor4j.object.SnmpOid; | |
6 | ||
7 | /** | |
8 | * Mapping to build an entry of the map in <code>dataMap</code> field of {@link net.sf.snmpadaptor4j.object.SnmpTrap SnmpTrap} from an entry of map in | |
9 | * <code>userData</code> field of JMX notification. | |
10 | * @author <a href="http://fr.linkedin.com/in/jpminetti/">Jean-Philippe MINETTI</a> | |
11 | * @see MapDataMapTrapMapping | |
12 | */ | |
13 | public final class UserDataEntryDataMapTrapMapping | |
14 | implements Serializable { | |
15 | ||
16 | /** | |
17 | * Serial number. | |
18 | */ | |
19 | private static final long serialVersionUID = -520862990459987242L; | |
20 | ||
21 | /** | |
22 | * Key for find the entry in the map of <code>userData</code> field of JMX notification. | |
23 | */ | |
24 | private final String key; | |
25 | ||
26 | /** | |
27 | * SNMP data type of entry in the map of <code>userData</code> field of JMX notification. | |
28 | */ | |
29 | private final SnmpDataType type; | |
30 | ||
31 | /** | |
32 | * OID of entry in the map of <code>userData</code> field of JMX notification. | |
33 | */ | |
34 | private final SnmpOid oid; | |
35 | ||
36 | /** | |
37 | * Hidden constructor. | |
38 | * @param key Key for find the entry in the map of <code>userData</code> field of JMX notification (must not be <code>NULL</code>). | |
39 | * @param type SNMP data type of entry in the map of <code>userData</code> field of JMX notification (must not be <code>NULL</code>). | |
40 | * @param oid OID of entry in the map of <code>userData</code> field of JMX notification (must not be <code>NULL</code>). | |
41 | * @see XmlMappingParser#newSnmpTrapMappingMap(String) | |
42 | * @see MapDataMapTrapMapping#addUserDataEntry(String, SnmpDataType, SnmpOid) | |
43 | */ | |
44 | UserDataEntryDataMapTrapMapping (final String key, final SnmpDataType type, final SnmpOid oid) { | |
45 | 240 | super(); |
46 | 240 | this.key = key; |
47 | 240 | this.type = type; |
48 | 240 | this.oid = oid; |
49 | 240 | } |
50 | ||
51 | /** | |
52 | * Returns the key for find the entry in the map of <code>userData</code> field of JMX notification. | |
53 | * @return Key for find the entry in the map of <code>userData</code> field of JMX notification. | |
54 | */ | |
55 | public String getKey () { | |
56 | 89 | return this.key; |
57 | } | |
58 | ||
59 | /** | |
60 | * Returns the SNMP data type of entry in the map of <code>userData</code> field of JMX notification. | |
61 | * @return SNMP data type of entry in the map of <code>userData</code> field of JMX notification. | |
62 | */ | |
63 | public SnmpDataType getType () { | |
64 | 85 | return this.type; |
65 | } | |
66 | ||
67 | /** | |
68 | * Returns the OID of entry in the map of <code>userData</code> field of JMX notification. | |
69 | * @return OID of entry in the map of <code>userData</code> field of JMX notification. | |
70 | */ | |
71 | public SnmpOid getOid () { | |
72 | 85 | return this.oid; |
73 | } | |
74 | ||
75 | /* | |
76 | * {@inheritDoc} | |
77 | * @see java.lang.Object#hashCode() | |
78 | */ | |
79 | @Override | |
80 | public int hashCode () { | |
81 | final int prime = 31; | |
82 | 76 | int result = 1; |
83 | 76 | result = prime * result + ((this.key == null) ? 0 : this.key.hashCode()); |
84 | 76 | result = prime * result + ((this.oid == null) ? 0 : this.oid.hashCode()); |
85 | 76 | result = prime * result + ((this.type == null) ? 0 : this.type.hashCode()); |
86 | 76 | return result; |
87 | } | |
88 | ||
89 | /* | |
90 | * {@inheritDoc} | |
91 | * @see java.lang.Object#equals(java.lang.Object) | |
92 | */ | |
93 | @Override | |
94 | public boolean equals (final Object obj) { | |
95 | 64 | boolean result = false; |
96 | 64 | if (obj == this) { |
97 | 1 | result = true; |
98 | } | |
99 | 63 | else if ((obj != null) && getClass().equals(obj.getClass())) { |
100 | 61 | final UserDataEntryDataMapTrapMapping other = (UserDataEntryDataMapTrapMapping) obj; |
101 | 61 | result = (this.type == other.type); |
102 | 61 | if (result) { |
103 | 57 | result = (this.oid != null ? this.oid.equals(other.oid) : other.oid == null); |
104 | } | |
105 | 61 | if (result) { |
106 | 54 | result = (this.key != null ? this.key.equals(other.key) : other.key == null); |
107 | } | |
108 | } | |
109 | 64 | return result; |
110 | } | |
111 | ||
112 | /* | |
113 | * {@inheritDoc} | |
114 | * @see java.lang.Object#toString() | |
115 | */ | |
116 | @Override | |
117 | public String toString () { | |
118 | 1 | return "UserDataEntryDataMapTrapMapping[key=" + this.key + "; type=" + this.type + "; oid=" + this.oid + "]"; |
119 | } | |
120 | ||
121 | } |