com.h3c.sdn.misc.dsync

## Class AbstractSyncObj<T>

- java.lang.Object
- - com.h3c.sdn.misc.dsync.AbstractSyncObj<T>

- Type Parameters:
    `T` - the type of sync object
  All Implemented Interfaces:
    SyncObj<T>, Serializable
  Direct Known Subclasses:
    BroadcastTreeSyncObj, DpSuppressedPortsSyncObj, LinkSyncObj, MsgContextSyncObj, NodeMessageSyncObj, TopologyClusterSyncObj

      public abstract class AbstractSyncObj<T>
      extends Object
      implements SyncObj<T>

  Default implementation of SyncObj abstraction, which uses Jackson's Smile data format, the "binary json" data interchange. (https://github.com/FasterXML/jackson-dataformat-smile). This offers 30-50% time and space improvements over jackson's default dataformat and thus translates to big saving when used in HA workflows related to ZK/Keystore.
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractSyncObj()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract SyncObj<T>` | `decode(com.fasterxml.jackson.databind.node.ObjectNode jsonNode)` Convert a given raw ObjectNode to required SyncObject.
    `abstract com.fasterxml.jackson.databind.node.ObjectNode` | `encode(com.fasterxml.jackson.databind.node.ObjectNode rawNode)` Stuffs an empty ObjectNode with desired form of the SyncObj.
    `static boolean` | `isNull(Object obj)` Checks if given object is null.
    `static com.fasterxml.jackson.databind.ObjectMapper` | `mapper()`
    `byte[]` | `marshal()` Converts this object into byte format ready for transmission.
    `SyncObj<T>` | `unmarshal(byte[] payload)` Synthesizes the object from the given bytes that were retrieved from the transmitted medium.

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AbstractSyncObj

          public AbstractSyncObj()

  - ### Method Detail

    - #### mapper

          public static com.fasterxml.jackson.databind.ObjectMapper mapper()

      Returns:
        the mapper

    - #### decode

          public abstract SyncObj<T> decode(com.fasterxml.jackson.databind.node.ObjectNode jsonNode)

      Convert a given raw ObjectNode to required SyncObject.
      Parameters:
        `jsonNode` - the raw ObjectNode synthesized from the bytes retrieved from the HA infrastructure.
      Returns:
        the decoded SyncObject

    - #### unmarshal

          public SyncObj<T> unmarshal(byte[] payload)

      Synthesizes the object from the given bytes that were retrieved from the transmitted medium.
      Specified by:
        `unmarshal` in interface `SyncObj<T>`
      Parameters:
        `payload` - the object in bytes form retrieved from the HA medium.
      Returns:
        the synthesized object

    - #### encode

          public abstract com.fasterxml.jackson.databind.node.ObjectNode encode(com.fasterxml.jackson.databind.node.ObjectNode rawNode)

      Stuffs an empty ObjectNode with desired form of the SyncObj. at this point.
      Parameters:
        `rawNode` - the empty ObjectNode that needs to be built on.
      Returns:
        the fully dressed ObjectNode that represents the SyncObj.

    - #### marshal

          public byte[] marshal()

      Converts this object into byte format ready for transmission. Construct bytes for sending across the channel(bus) from the object.
      Specified by:
        `marshal` in interface `SyncObj<T>`
      Returns:
        the object in byte format ready for transmission over the medium.

    - #### isNull

          public static boolean isNull(Object obj)

      Checks if given object is null.
      Parameters:
        `obj` - object that needs to be checked
      Returns:
        true if object is null, false otherwise

Copyright © 2014. All Rights Reserved.