com.h3c.util.ip

## Class ICMPv4Type

- java.lang.Object
- - com.h3c.util.cache.CacheableDataType
  - - com.h3c.util.ip.ICMPv4Type

- All Implemented Interfaces:
    Serializable, Comparable<ICMPv4Type>

      public final class ICMPv4Type
      extends CacheableDataType
      implements Comparable<ICMPv4Type>

  Represents an ICMPv4 message type.

  All constructors for this class are private. Creating instances of `ICMPv4Type` is done via the static methods on the class.

  Instances of this class are immutable, making them inherently threadsafe.

  This class overrides `equals(java.lang.Object)` and `hashCode()` so that instances play nicely with the Collection classes.

  This class implements the `Comparable` interface to ensure that a sorted list of types is presented in an intuitive order.

  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static ICMPv4Type` | `ECHO_REP` The instance representing Echo reply.
    `static ICMPv4Type` | `ECHO_REQ` The instance representing Echo request.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `compareTo(ICMPv4Type o)` Implements the Comparable interface, to return ICMPv4 message types in natural order.
    `boolean` | `equals(Object o)`
    `int` | `getCode()` Returns the ICMPv4 message type code.
    `String` | `getDescription()` Returns the description of the ICMPv4 message type.
    `String` | `getName()` Returns the (short) name of the message type.
    `int` | `hashCode()`
    `boolean` | `isReserved()` Returns true if the message type code is one of the reserved values.
    `boolean` | `isUnknown()` Returns true if the message type code is not one of the "named" types.
    `String` | `toString()` Returns a string representing the ICMPv4 message type.
    `static ICMPv4Type` | `valueOf(int typeCode)` Returns an object that represents the value of the ICMPv4 message type identified by the specified type code.
    `static ICMPv4Type` | `valueOf(String value)` Returns an object that represents the value of the ICMPv4 message type identified by the specified string.

    - ### Methods inherited from class com.h3c.util.cache.CacheableDataType

      `getRefQ, keyFromBytes`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### ECHO_REQ

          public static final ICMPv4Type ECHO_REQ

      The instance representing Echo request.

    - #### ECHO_REP

          public static final ICMPv4Type ECHO_REP

      The instance representing Echo reply.

  - ### Method Detail

    - #### toString

          public String toString()

      Returns a string representing the ICMPv4 message type.
      Overrides:
        `toString` in class `Object`
      Returns:
        the message type code and name

    - #### getDescription

          public String getDescription()

      Returns the description of the ICMPv4 message type. E.g. "DEST_UNR : Destination unreachable"
      Returns:
        the description

    - #### getName

          public String getName()

      Returns the (short) name of the message type. E.g. "DEST_UNR"
      Returns:
        the (short) name

    - #### getCode

          public int getCode()

      Returns the ICMPv4 message type code.
      Returns:
        the message type code

    - #### isUnknown

          public boolean isUnknown()

      Returns true if the message type code is not one of the "named" types. More specifically, the type is not defined in the ICMPv4Type resource bundle and is not `reserved`.
      Returns:
        true if unknown

    - #### isReserved

          public boolean isReserved()

      Returns true if the message type code is one of the reserved values.
      Returns:
        true if this message type is a reserved value

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### compareTo

          public int compareTo(ICMPv4Type o)

      Implements the Comparable interface, to return ICMPv4 message types in natural order.
      Specified by:
        `compareTo` in interface `Comparable<ICMPv4Type>`
      Parameters:
        `o` - the other IP Protocol instance
      Returns:
        an integer value indicating relative ordering
      See Also:
        `Comparable.compareTo(T)`

    - #### valueOf

          public static ICMPv4Type valueOf(String value)

      Returns an object that represents the value of the ICMPv4 message type identified by the specified string. For example:

             ICMPv4Type rs = ICMPv4Type.valueOf("rtr_sol");
             String s = rs.getDescription(); // "RTR_SOL : Router Solicitation"
             ICMPv4Type rsAlso = ICMPv4Type.valueOf(s);
             assert rsAlso.equals(rs);

      Parameters:
        `value` - the message type identifier
      Returns:
        an object representing the specified message type

    - #### valueOf

          public static ICMPv4Type valueOf(int typeCode)

      Returns an object that represents the value of the ICMPv4 message type identified by the specified type code.
      Parameters:
        `typeCode` - the ICMPv4 message type code
      Returns:
        an object representing the specified protocol
      Throws:
        `IllegalArgumentException` - if the parameter is < 0 or > 255

Copyright © 2014. All Rights Reserved.