1 package net.sf.snmpadaptor4j.core.mapping; 2 3 import java.util.ArrayList; 4 import java.util.Collections; 5 import java.util.List; 6 import net.sf.snmpadaptor4j.object.SnmpDataType; 7 import net.sf.snmpadaptor4j.object.SnmpOid; 8 9 /** 10 * Object containing the mapping to build the <code>dataMap</code> field of {@link net.sf.snmpadaptor4j.object.SnmpTrap SnmpTrap} from a <code>userData</code> field 11 * of JMX notification and as <b>map object</b>. 12 * @author <a href="http://fr.linkedin.com/in/jpminetti/">Jean-Philippe MINETTI</a> 13 */ 14 public final class MapDataMapTrapMapping 15 extends DataMapTrapMapping { 16 17 /** 18 * Serial number. 19 */ 20 private static final long serialVersionUID = -6097834534568446556L; 21 22 /** 23 * List of mappings to build entries of the map in <code>dataMap</code> field of {@link net.sf.snmpadaptor4j.object.SnmpTrap SnmpTrap} from all entries of map in 24 * <code>userData</code> field of JMX notification. 25 */ 26 private final List<UserDataEntryDataMapTrapMapping> userDataEntryList = new ArrayList<UserDataEntryDataMapTrapMapping>(); 27 28 /** 29 * Hidden constructor. 30 * @param sequenceNumberOid OID of <code>sequenceNumber</code> field of JMX notification. Is NULL if the <code>sequenceNumber</code> should not be present in 31 * <code>dataMap</code> field of {@link net.sf.snmpadaptor4j.object.SnmpTrap SnmpTrap}. 32 * @param messageOid OID of <code>message</code> field of JMX notification. Is NULL if the <code>message</code> should not be present in <code>dataMap</code> 33 * field of {@link net.sf.snmpadaptor4j.object.SnmpTrap SnmpTrap}. 34 * @param hasSystemInfo <code>TRUE</code> for put all system information attributes in the <code>dataMap</code> field of 35 * {@link net.sf.snmpadaptor4j.object.SnmpTrap SnmpTrap}. 36 * @see XmlMappingParser#newSnmpTrapMappingMap(String) 37 */ 38 MapDataMapTrapMapping (final SnmpOid sequenceNumberOid, final SnmpOid messageOid, final boolean hasSystemInfo) { 39 super(sequenceNumberOid, messageOid, hasSystemInfo); 40 } 41 42 /** 43 * Adds a 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 44 * <code>userData</code> field of JMX notification. 45 * @param userDataKey Key for find the entry in the map of <code>userData</code> field of JMX notification (must not be <code>NULL</code>). 46 * @param userDataType SNMP data type of entry in the map of <code>userData</code> field of JMX notification (must not be <code>NULL</code>). 47 * @param userDataOid OID of entry in the map of <code>userData</code> field of JMX notification (must not be <code>NULL</code>). 48 * @see XmlMappingParser#newSnmpTrapMappingMap(String) 49 */ 50 void addUserDataEntry (final String userDataKey, final SnmpDataType userDataType, final SnmpOid userDataOid) { 51 this.userDataEntryList.add(new UserDataEntryDataMapTrapMapping(userDataKey, userDataType, userDataOid)); 52 } 53 54 /** 55 * Returns the list of mappings to build entries of the map in <code>dataMap</code> field of {@link net.sf.snmpadaptor4j.object.SnmpTrap SnmpTrap} from all 56 * entries of map in <code>userData</code> field of JMX notification. 57 * @return List of mappings to build entries of the map in <code>dataMap</code> field of {@link net.sf.snmpadaptor4j.object.SnmpTrap SnmpTrap} from all entries 58 * of map in <code>userData</code> field of JMX notification (never <code>NULL</code>). 59 */ 60 public List<UserDataEntryDataMapTrapMapping> getUserDataEntryList () { 61 return Collections.unmodifiableList(this.userDataEntryList); 62 } 63 64 /* 65 * {@inheritDoc} 66 * @see net.sf.snmpadaptor4j.core.mapping.DataMapTrapMapping#hashCode() 67 */ 68 @Override 69 public int hashCode () { 70 final int prime = 31; 71 int result = super.hashCode(); 72 result = prime * result + this.userDataEntryList.hashCode(); 73 return result; 74 } 75 76 /* 77 * {@inheritDoc} 78 * @see net.sf.snmpadaptor4j.core.mapping.DataMapTrapMapping#equals(java.lang.Object) 79 */ 80 @Override 81 public boolean equals (final Object obj) { 82 boolean result = false; 83 if (obj == this) { 84 result = true; 85 } 86 else { 87 result = super.equals(obj); 88 if (result) { 89 final MapDataMapTrapMapping other = (MapDataMapTrapMapping) obj; 90 result = this.userDataEntryList.equals(other.userDataEntryList); 91 } 92 } 93 return result; 94 } 95 96 /* 97 * {@inheritDoc} 98 * @see java.lang.Object#toString() 99 */ 100 @Override 101 public String toString () { 102 return "MapDataMapTrapMapping[sequenceNumberOid=" + getSequenceNumberOid() + "; messageOid=" + getMessageOid() + "; hasSystemInfo=" + isHasSystemInfo() 103 + "; userDataEntryList=" + this.userDataEntryList + "]"; 104 } 105 106 }