Interface Identity<PK>

Type Parameters:
PK - the primary data type that uniquely identifies the object
All Superinterfaces:
Comparable<PK>
All Known Subinterfaces:
ConfigurableLocalizedServiceInfo, Entity<K>, LocalizedServiceInfo, TemplateRenderer
All Known Implementing Classes:
BaseLocalizedServiceInfoProvider, BaseSettingsSpecifierLocalizedServiceInfoProvider, BasicConfigurableLocalizedServiceInfo, BasicEntity, BasicIdentity, BasicIdentity, BasicLocalizedServiceInfo, BasicLongEntity, BasicStringEntity, BasicUuidEntity, GeneralDatum

public interface Identity<PK> extends Comparable<PK>
Common API for identity information in SolarNetwork participating services.
Since:
1.43
Version:
1.2
Author:
matt
  • Method Summary

    Modifier and Type
    Method
    Description
    Get the primary identifier of the object
    default boolean
    Test if this object has a valid identifier.
    static <T extends Identity<PK>, PK extends Comparable<PK>>
    Comparator<T>
    Sort instances by their ID values.

    Methods inherited from interface java.lang.Comparable

    compareTo
  • Method Details

    • getId

      PK getId()
      Get the primary identifier of the object
      Returns:
      the primary identifier
    • hasId

      default boolean hasId()
      Test if this object has a valid identifier.

      This method must only return true if the object returned from getId() is a valid identifier for objects of this type.

      This implementation simply tests if getId() is not null. Extending classes, such as those with composite keys where nested properties must be defined for the key to be valid, can override this implementation as needed.

      Returns:
      true if this object has a valid identifier
      Since:
      1.1
    • sortByIdentity

      static <T extends Identity<PK>, PK extends Comparable<PK>> Comparator<T> sortByIdentity()
      Sort instances by their ID values.
      Type Parameters:
      T - the Identity type
      PK - the Identity ID type
      Returns:
      the comparator
      Since:
      1.2