Coverage Report - net.sf.snmpadaptor4j.core.mapping.SpecificSnmpTrapMapping
 
Classes in this File Line Coverage Branch Coverage Complexity
SpecificSnmpTrapMapping
100 %
16/16
100 %
6/6
1,4
 
 1  
 package net.sf.snmpadaptor4j.core.mapping;
 2  
 
 3  
 import net.sf.snmpadaptor4j.object.SnmpOid;
 4  
 
 5  
 /**
 6  
  * Object containing the mapping to build <b>specific</b> SNMP traps from JMX notifications.
 7  
  * @author <a href="http://fr.linkedin.com/in/jpminetti/">Jean-Philippe MINETTI</a>
 8  
  */
 9  
 public final class SpecificSnmpTrapMapping
 10  
                 extends SnmpTrapMapping {
 11  
 
 12  
         /**
 13  
          * Serial number.
 14  
          */
 15  
         private static final long serialVersionUID = -708977968210447637L;
 16  
 
 17  
         /**
 18  
          * <code>type</code> field of {@link net.sf.snmpadaptor4j.object.SpecificSnmpTrap SpecificSnmpTrap}.
 19  
          */
 20  
         private final int type;
 21  
 
 22  
         /**
 23  
          * Hidden constructor.
 24  
          * @param source <code>source</code> field of {@link net.sf.snmpadaptor4j.object.SpecificSnmpTrap SpecificSnmpTrap}.
 25  
          * @param dataMap Mapping to build the <code>dataMap</code> field of {@link net.sf.snmpadaptor4j.object.SpecificSnmpTrap SpecificSnmpTrap} from a JMX
 26  
          *            notification.
 27  
          * @param type <code>type</code> field of {@link net.sf.snmpadaptor4j.object.SpecificSnmpTrap SpecificSnmpTrap}.
 28  
          * @see XmlMappingParser#newSnmpTrapMappingMap(String)
 29  
          */
 30  
         SpecificSnmpTrapMapping (final SnmpOid source, final DataMapTrapMapping dataMap, final int type) {
 31  132
                 super(source, dataMap);
 32  132
                 this.type = type;
 33  132
         }
 34  
 
 35  
         /**
 36  
          * Returns the <code>type</code> field of {@link net.sf.snmpadaptor4j.object.SpecificSnmpTrap SpecificSnmpTrap}.
 37  
          * @return <code>type</code> field of {@link net.sf.snmpadaptor4j.object.SpecificSnmpTrap SpecificSnmpTrap}.
 38  
          */
 39  
         public int 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;
 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  36
                 boolean result = false;
 62  36
                 if (obj == this) {
 63  1
                         result = true;
 64  
                 }
 65  
                 else {
 66  35
                         result = super.equals(obj);
 67  35
                         if (result) {
 68  27
                                 final SpecificSnmpTrapMapping other = (SpecificSnmpTrapMapping) obj;
 69  27
                                 result = (this.type == other.type);
 70  
                         }
 71  
                 }
 72  36
                 return result;
 73  
         }
 74  
 
 75  
         /*
 76  
          * {@inheritDoc}
 77  
          * @see java.lang.Object#toString()
 78  
          */
 79  
         @Override
 80  
         public String toString () {
 81  7
                 return "SNMP trap " + getSource() + " - Type enterpriseSpecific/" + this.type;
 82  
         }
 83  
 
 84  
 }