Class SerializedRecord

java.lang.Object
com.norconex.crawler.core.cluster.SerializedRecord

public final class SerializedRecord extends Object
Backend-agnostic envelope for storing arbitrary objects as a pair of: - className: fully qualified class name of the original object - serialized: JSON representation of the original object This type intentionally has no backend-specific annotations so it can be used in any storage path (e.g., String caches, DB) and adapted by backend-specific wrappers (e.g., Protostream-annotated classes).
  • Constructor Details

    • SerializedRecord

      public SerializedRecord(Object object)
    • SerializedRecord

      public SerializedRecord()
  • Method Details

    • wrap

      public static SerializedRecord wrap(Object object)
      Creates an envelope for the given object.
      Parameters:
      object - object to wrap
      Returns:
      serialized envelope
    • unwrap

      public <T> T unwrap()
      Reconstructs the original object instance using the stored className and JSON payload. Returns null if the payload is null/empty. Throws CrawlerException if the class cannot be resolved.
      Type Parameters:
      T - the type of the returned object
      Returns:
      the deserialized object
    • getClassName

      public String getClassName()
    • getSerialized

      public String getSerialized()
    • setClassName

      public void setClassName(String className)
    • setSerialized

      public void setSerialized(String serialized)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object