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