Coverage Report - net.sf.snmpadaptor4j.SnmpManagerConfiguration
 
Classes in this File Line Coverage Branch Coverage Complexity
SnmpManagerConfiguration
100 %
30/30
100 %
28/28
2,25
 
 1  
 package net.sf.snmpadaptor4j;
 2  
 
 3  
 import java.io.Serializable;
 4  
 
 5  
 /**
 6  
  * Object containing all parameters to connect to a SNMP manager for trap sending.
 7  
  * @author <a href="http://fr.linkedin.com/in/jpminetti/">Jean-Philippe MINETTI</a>
 8  
  */
 9  
 public final class SnmpManagerConfiguration
 10  
                 implements Serializable {
 11  
 
 12  
         /**
 13  
          * Serial number.
 14  
          */
 15  
         private static final long serialVersionUID = 923122651757199428L;
 16  
 
 17  
         /**
 18  
          * IP address of SNMP manager responsible of traps handling.
 19  
          */
 20  
         private final String address;
 21  
 
 22  
         /**
 23  
          * UDP port of SNMP manager responsible of traps handling.
 24  
          */
 25  
         private final int port;
 26  
 
 27  
         /**
 28  
          * Protocol version of SNMP manager.
 29  
          */
 30  
         private final int version;
 31  
 
 32  
         /**
 33  
          * Community of SNMP manager.
 34  
          */
 35  
         private final String community;
 36  
 
 37  
         /**
 38  
          * Constructor.
 39  
          * @param address IP address of SNMP manager responsible of traps handling.
 40  
          * @param port UDP port of SNMP manager responsible of traps handling.
 41  
          * @param version Protocol version of SNMP manager.
 42  
          * @param community Community of SNMP manager.
 43  
          */
 44  
         public SnmpManagerConfiguration (final String address, final int port, final int version, final String community) {
 45  111
                 super();
 46  111
                 this.address = address;
 47  111
                 this.port = port;
 48  111
                 this.version = version;
 49  111
                 this.community = community;
 50  111
         }
 51  
 
 52  
         /**
 53  
          * Returns the IP address of SNMP manager responsible of traps handling.
 54  
          * @return IP address of SNMP manager.
 55  
          */
 56  
         public String getAddress () {
 57  42
                 return this.address;
 58  
         }
 59  
 
 60  
         /**
 61  
          * Returns the UDP port of SNMP manager responsible of traps handling.
 62  
          * @return UDP port of SNMP manager.
 63  
          */
 64  
         public int getPort () {
 65  42
                 return this.port;
 66  
         }
 67  
 
 68  
         /**
 69  
          * Returns the protocol version of SNMP manager.
 70  
          * @return Protocol version of SNMP manager.
 71  
          */
 72  
         public int getVersion () {
 73  42
                 return this.version;
 74  
         }
 75  
 
 76  
         /**
 77  
          * Returns the community of SNMP manager.
 78  
          * @return Community of SNMP manager.
 79  
          */
 80  
         public String getCommunity () {
 81  42
                 return this.community;
 82  
         }
 83  
 
 84  
         /*
 85  
          * {@inheritDoc}
 86  
          * @see java.lang.Object#hashCode()
 87  
          */
 88  
         @Override
 89  
         public int hashCode () {
 90  
                 final int prime = 31;
 91  30
                 int result = 1;
 92  30
                 result = prime * result + ((this.address == null) ? 0 : this.address.hashCode());
 93  30
                 result = prime * result + ((this.community == null) ? 0 : this.community.hashCode());
 94  30
                 result = prime * result + this.port;
 95  30
                 result = prime * result + this.version;
 96  30
                 return result;
 97  
         }
 98  
 
 99  
         /*
 100  
          * {@inheritDoc}
 101  
          * @see java.lang.Object#equals(java.lang.Object)
 102  
          */
 103  
         @Override
 104  
         public boolean equals (final Object obj) {
 105  21
                 boolean result = false;
 106  21
                 if (obj == this) {
 107  3
                         result = true;
 108  
                 }
 109  18
                 else if ((obj != null) && (getClass().equals(obj.getClass()))) {
 110  16
                         final SnmpManagerConfiguration other = (SnmpManagerConfiguration) obj;
 111  16
                         result = (this.address != null ? this.address.equals(other.address) : (other.address == null));
 112  16
                         if (result) {
 113  13
                                 result = (this.port == other.port);
 114  
                         }
 115  16
                         if (result) {
 116  12
                                 result = (this.version == other.version);
 117  
                         }
 118  16
                         if (result) {
 119  11
                                 result = (this.community != null ? this.community.equals(other.community) : (other.community == null));
 120  
                         }
 121  
                 }
 122  21
                 return result;
 123  
         }
 124  
 
 125  
         /*
 126  
          * {@inheritDoc}
 127  
          * @see java.lang.Object#toString()
 128  
          */
 129  
         @Override
 130  
         public String toString () {
 131  1
                 return this.address + ":" + this.port + "/" + this.community;
 132  
         }
 133  
 
 134  
 }