Class JsonStorable

java.lang.Object
io.vertx.core.json.JsonObject
com.codingchili.core.storage.JsonStorable
All Implemented Interfaces:
Storable, io.vertx.core.shareddata.impl.ClusterSerializable, io.vertx.core.shareddata.Shareable, Serializable, Cloneable, Comparable, Iterable<Map.Entry<String,​Object>>

public class JsonStorable extends io.vertx.core.json.JsonObject implements Storable
Extends the JsonObject making it storable.
See Also:
Serialized Form
  • Field Summary

    Fields inherited from interface com.codingchili.core.storage.Storable

    idField
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new storable JsonObject by setting its object ID to an UUID.
    JsonStorable​(io.vertx.core.json.JsonObject json)
     
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    Get the id of the storable item, used as a key to the map api.

    Methods inherited from class io.vertx.core.json.JsonObject

    clear, containsKey, copy, copy, encode, encodePrettily, equals, fieldNames, getBinary, getBinary, getBoolean, getBoolean, getBuffer, getBuffer, getDouble, getDouble, getFloat, getFloat, getInstant, getInstant, getInteger, getInteger, getJsonArray, getJsonArray, getJsonObject, getJsonObject, getLong, getLong, getMap, getNumber, getNumber, getString, getString, getValue, getValue, hashCode, isEmpty, iterator, mapFrom, mapTo, mergeIn, mergeIn, mergeIn, put, putNull, readFromBuffer, remove, size, stream, toBuffer, toString, writeToBuffer

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator

    Methods inherited from interface io.vertx.core.shareddata.Shareable

    copy

    Methods inherited from interface com.codingchili.core.storage.Storable

    compareTo, compareToAttribute
  • Constructor Details

    • JsonStorable

      public JsonStorable()
      Creates a new storable JsonObject by setting its object ID to an UUID.
    • JsonStorable

      public JsonStorable(String id)
      Parameters:
      id - the id of the storable to set, cannot be null.
    • JsonStorable

      public JsonStorable(io.vertx.core.json.JsonObject json)
      Parameters:
      json - creates a storable from the given json, if the given json does not contain an 'id' field one will be added using uuid.
  • Method Details

    • copyNew

      public JsonStorable copyNew()
      Returns:
      creates a copy of the backing json object and assigns a new id.
    • getId

      public String getId()
      Description copied from interface: Storable
      Get the id of the storable item, used as a key to the map api. This field is not included when serializing to JSON. When serializing to json the id must be kept separately.

      instead of implementing this method, to avoid duplicate values in values as keys; implement hashCode based on an unique attribute combination.

      Specified by:
      getId in interface Storable
      Returns:
      an id that is unique to this storable item.