1 package net.sf.snmpadaptor4j.object;
2
3 import java.util.Map;
4 import java.util.Map.Entry;
5 import org.apache.log4j.Logger;
6
7
8
9
10
11 public final class SpecificSnmpTrap
12 extends SnmpTrap {
13
14
15
16
17 private static final long serialVersionUID = 2590666174837567870L;
18
19
20
21
22 private final int type;
23
24
25
26
27
28
29
30
31
32 protected SpecificSnmpTrap (final long timeStamp, final SnmpOid source, final int type, final Map<SnmpOid, SnmpTrapData> dataMap) {
33 super(timeStamp, source, dataMap);
34 this.type = type;
35 }
36
37
38
39
40
41 public int getType () {
42 return this.type;
43 }
44
45
46
47
48
49 @Override
50 public void traceTo (final Logger logger) {
51 logger.trace("enterprise = " + getSource());
52 logger.trace("generic-trap = enterpriseSpecific");
53 logger.trace("specific-trap = " + this.type);
54 logger.trace("time-stamp = " + getTimeStamp());
55 for (final Entry<SnmpOid, SnmpTrapData> data : getDataMap().entrySet()) {
56 logger.trace("variable-bindings: " + data.getKey() + " = " + data.getValue());
57 }
58 }
59
60
61
62
63
64 @Override
65 public int hashCode () {
66 final int prime = 31;
67 int result = super.hashCode();
68 result = prime * result + this.type;
69 return result;
70 }
71
72
73
74
75
76 @Override
77 public boolean equals (final Object obj) {
78 boolean result = false;
79 if (obj == this) {
80 result = true;
81 }
82 else {
83 result = super.equals(obj);
84 if (result) {
85 final SpecificSnmpTrap other = (SpecificSnmpTrap) obj;
86 result = (this.type == other.type);
87 }
88 }
89 return result;
90 }
91
92
93
94
95
96 @Override
97 public String toString () {
98 return "SNMP trap " + getSource() + " - Type enterpriseSpecific/" + this.type;
99 }
100
101 }