Interface Storable

All Superinterfaces:
Cloneable, Comparable, Serializable, io.vertx.core.shareddata.Shareable
All Known Subinterfaces:
NestedStorable, Session
All Known Implementing Classes:
Account, JsonStorable, NestedObject, StorageObject

public interface Storable extends Serializable, Cloneable, Comparable, io.vertx.core.shareddata.Shareable
All classes using the storage system must implement storable.

If not errors such as "Not serializable" or "Illegal argument exception" will occur.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static String
     
  • Method Summary

    Modifier and Type
    Method
    Description
    default int
    compareTo​(Object other)
    Provides a default implementation for compareTo that uses the storables id.
    default int
    compareToAttribute​(Storable other, String attribute)
    compares this storable to another storable, with an attribute specified.
    default String
    Get the id of the storable item, used as a key to the map api.

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

    copy
  • Field Details

  • Method Details

    • getId

      default String getId()
      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.

      Returns:
      an id that is unique to this storable item.
    • compareTo

      default int compareTo(Object other)
      Provides a default implementation for compareTo that uses the storables id.
      Specified by:
      compareTo in interface Comparable
      Parameters:
      other - the object to compare to.
      Returns:
      see Comparable#compareTo(Object)
    • compareToAttribute

      default int compareToAttribute(Storable other, String attribute)
      compares this storable to another storable, with an attribute specified. this method must be implemented by the storable to allow ordering. Only required for storages utilizing comparators for ordering. The implementation may be based on attribute names mapped to getter lambdas, or a simple switch.

      Only required when ordering by attribute with HazelMap

      Parameters:
      other - the other object to compare to.
      attribute - handler of the attribute that should be tested.
      Returns:
      integer that matches implementation of @see Comparable#compareTo(Object)