Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
GenericSnmpTrapMapping |
|
| 1.6;1,6 |
1 | package net.sf.snmpadaptor4j.core.mapping; | |
2 | ||
3 | import net.sf.snmpadaptor4j.object.SnmpOid; | |
4 | import net.sf.snmpadaptor4j.object.GenericSnmpTrapType; | |
5 | ||
6 | /** | |
7 | * Object containing the mapping to build <b>generic</b> SNMP traps from JMX notifications. | |
8 | * @author <a href="http://fr.linkedin.com/in/jpminetti/">Jean-Philippe MINETTI</a> | |
9 | */ | |
10 | public final class GenericSnmpTrapMapping | |
11 | extends SnmpTrapMapping { | |
12 | ||
13 | /** | |
14 | * Serial number. | |
15 | */ | |
16 | private static final long serialVersionUID = -3515283428235197553L; | |
17 | ||
18 | /** | |
19 | * <code>type</code> field of {@link net.sf.snmpadaptor4j.object.GenericSnmpTrap GenericSnmpTrap}. | |
20 | */ | |
21 | private final GenericSnmpTrapType type; | |
22 | ||
23 | /** | |
24 | * Hidden constructor. | |
25 | * @param source <code>source</code> field of {@link net.sf.snmpadaptor4j.object.GenericSnmpTrap GenericSnmpTrap}. | |
26 | * @param dataMap Mapping to build the <code>dataMap</code> field of {@link net.sf.snmpadaptor4j.object.GenericSnmpTrap GenericSnmpTrap} from a JMX notification. | |
27 | * @param type <code>type</code> field of {@link net.sf.snmpadaptor4j.object.GenericSnmpTrap GenericSnmpTrap}. | |
28 | * @see XmlMappingParser#newSnmpTrapMappingMap(String) | |
29 | */ | |
30 | GenericSnmpTrapMapping (final SnmpOid source, final DataMapTrapMapping dataMap, final GenericSnmpTrapType type) { | |
31 | 170 | super(source, dataMap); |
32 | 170 | this.type = type; |
33 | 170 | } |
34 | ||
35 | /** | |
36 | * Returns the <code>type</code> field of {@link net.sf.snmpadaptor4j.object.GenericSnmpTrap GenericSnmpTrap}. | |
37 | * @return <code>type</code> field of {@link net.sf.snmpadaptor4j.object.GenericSnmpTrap GenericSnmpTrap}. | |
38 | */ | |
39 | public GenericSnmpTrapType getType () { | |
40 | 2 | return this.type; |
41 | } | |
42 | ||
43 | /* | |
44 | * {@inheritDoc} | |
45 | * @see net.sf.snmpadaptor4j.core.mapping.SnmpTrapMapping#hashCode() | |
46 | */ | |
47 | @Override | |
48 | public int hashCode () { | |
49 | final int prime = 31; | |
50 | 20 | int result = super.hashCode(); |
51 | 20 | result = prime * result + ((this.type == null) ? 0 : this.type.hashCode()); |
52 | 20 | return result; |
53 | } | |
54 | ||
55 | /* | |
56 | * {@inheritDoc} | |
57 | * @see net.sf.snmpadaptor4j.core.mapping.SnmpTrapMapping#equals(java.lang.Object) | |
58 | */ | |
59 | @Override | |
60 | public boolean equals (final Object obj) { | |
61 | 46 | boolean result = false; |
62 | 46 | if (obj == this) { |
63 | 1 | result = true; |
64 | } | |
65 | else { | |
66 | 45 | result = super.equals(obj); |
67 | 45 | if (result) { |
68 | 37 | final GenericSnmpTrapMapping other = (GenericSnmpTrapMapping) obj; |
69 | 37 | result = (this.type == other.type); |
70 | } | |
71 | } | |
72 | 46 | return result; |
73 | } | |
74 | ||
75 | /* | |
76 | * {@inheritDoc} | |
77 | * @see java.lang.Object#toString() | |
78 | */ | |
79 | @Override | |
80 | public String toString () { | |
81 | 9 | return "SNMP trap " + getSource() + " - Type " + this.type + "/0"; |
82 | } | |
83 | ||
84 | } |