Enum MagicBytes

java.lang.Object
java.lang.Enum<MagicBytes>
org.refcodes.serial.MagicBytes
All Implemented Interfaces:
Serializable, Comparable<MagicBytes>, java.lang.constant.Constable, org.refcodes.mixin.MagicBytesAccessor, MagicBytesAccessor

public enum MagicBytes extends Enum<MagicBytes> implements MagicBytesAccessor
The MagicBytes enumeration provides various predefined magic bytes for common use cases. Some magic bytes may be combined using the MagicBytesAccessor.toMagicBytes() method to create magic bytes with more semantic information.
  • Enum Constant Details

    • ACKNOWLEDGE

      public static final MagicBytes ACKNOWLEDGE
      Magic bytes identifying a transmission acknowledge, same as Ascii.ACK.
    • CLEAR_TO_SEND

      public static final MagicBytes CLEAR_TO_SEND
      Magic bytes identifying a Clear-to-Send transmission, same as Ascii.ACK.
    • LAST_PACKET

      public static final MagicBytes LAST_PACKET
      Magic bytes identifying a last transmission package, same as Ascii.ETX.
    • PACKET

      public static final MagicBytes PACKET
      Magic bytes identifying an transmission package, same as Ascii.STX.
    • READY_TO_RECEIVE

      public static final MagicBytes READY_TO_RECEIVE
      Magic bytes identifying a Ready-to-Receive transmission, same as Ascii.ENQ.
    • READY_TO_SEND

      public static final MagicBytes READY_TO_SEND
      Magic bytes identifying a Ready-to-Send transmission, same as Ascii.ENQ.
    • TRANSMISSION

      public static final MagicBytes TRANSMISSION
      Identifies a fire-and-forget transmission (no acknowledge sent).
    • REQUEST

      public static final MagicBytes REQUEST
      Identifies a request expecting a fire-and-forget response (no acknowledge to be sent for the succeeding response).
    • RESPONSE

      public static final MagicBytes RESPONSE
      Identifies a fire-and-forget response in reply to a request (no acknowledge to be sent for the response).
    • RESPONSE_ACKNOWLEDGE

      public static final MagicBytes RESPONSE_ACKNOWLEDGE
      Identifies an acknowledge in reply to a response.
    • ACKNOWLEDGEABLE_TRANSMISSION

      public static final MagicBytes ACKNOWLEDGEABLE_TRANSMISSION
      Identifies an acknowledgeable transmission (acknowledge to be sent).
    • ACKNOWLEDGEABLE_REQUEST

      public static final MagicBytes ACKNOWLEDGEABLE_REQUEST
      Identifies a request expecting an acknowledgeable response (acknowledge to be sent sent for the succeeding response).
    • ACKNOWLEDGEABLE_RESPONSE

      public static final MagicBytes ACKNOWLEDGEABLE_RESPONSE
      Identifies an acknowledgeable response in reply to a request (acknowledge to be sent for the response).
    • TRANSMISSION_DISMISSED

      public static final MagicBytes TRANSMISSION_DISMISSED
      Sent in case a transmission was received and dismissed by a receiver.
    • REQUEST_DISMISSED

      public static final MagicBytes REQUEST_DISMISSED
      Sent when a request was received but dismissed by a receiver .
    • PING

      public static final MagicBytes PING
      Identifies a simple ping request to be responded by a fire-and-forget PONG (not to be acknowledged).
    • PONG

      public static final MagicBytes PONG
      Identifies a a fire-and-forget pong (not to be acknowledged) reply in response to a simple PING request.
  • Method Details

    • values

      public static MagicBytes[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static MagicBytes valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • getMagicBytes

      public byte[] getMagicBytes()
      Specified by:
      getMagicBytes in interface org.refcodes.mixin.MagicBytesAccessor
    • toMagicBytes

      public static byte[] toMagicBytes(MagicBytes... aMagicBytes)
      Constructs magic bytes from the provided MagicBytes elements to be concatenated to a single magic bytes sequence.
      Parameters:
      aMagicBytes - The MagicBytes elements from which to create the magic bytes.
      Returns:
      The accordingly created magic bytes.