Class BasicIdentifiable

java.lang.Object
net.solarnetwork.service.support.BasicIdentifiable
All Implemented Interfaces:
Identifiable
Direct Known Subclasses:
SimpleTemporalRangesTariffEvaluator

public class BasicIdentifiable extends Object implements Identifiable
Basic implementation of Identifiable.
Since:
1.56
Version:
2.1
Author:
matt
  • Constructor Details

    • BasicIdentifiable

      public BasicIdentifiable()
  • Method Details

    • basicIdentifiableSettings

      public static List<SettingSpecifier> basicIdentifiableSettings()
      Get settings for the configurable properties of BasicIdentifiable.

      Empty strings are used for the prefix, default uid and default groupUid setting values.

      Returns:
      the settings
      Since:
      1.1
      See Also:
    • basicIdentifiableSettings

      public static List<SettingSpecifier> basicIdentifiableSettings(String prefix)
      Get settings for the configurable uid/groupUid properties of BasicIdentifiable.

      Empty strings are used for the default uid and groupUid setting values.

      Parameters:
      prefix - an optional prefix to include in all setting keys
      Returns:
      the settings
      Since:
      1.1
      See Also:
    • basicIdentifiableSettings

      public static List<SettingSpecifier> basicIdentifiableSettings(String prefix, String defaultUid, String defaultGroupUid)
      Get settings for the configurable uid/groupUid properties of BasicIdentifiable.
      Parameters:
      prefix - an optional prefix to include in all setting keys
      defaultUid - the default uid value to use
      defaultGroupUid - the default groupUid value to use
      Returns:
      the settings
      Since:
      1.1
    • basicIdentifiableMetadataSettings

      public static List<SettingSpecifier> basicIdentifiableMetadataSettings(String prefix, KeyValuePair[] metadata)
      Get settings for the configurable metadata list property.
      Parameters:
      prefix - an optional prefix to include in all setting keys
      metadata - the metadata to get settings for
      Returns:
      the settings
      Since:
      2.1
      See Also:
    • metadataValue

      public String metadataValue(String key)
      Get a specific metadata value for a given key.
      Parameters:
      key - the metadata key to get the value for
      Returns:
      the value found on the first matching metadata key, or null if not found
      Since:
      2.1
    • smartMetadataValue

      public Object smartMetadataValue(String key)
      Get a specific metadata value for a given key, coerced to a number if possible.
      Parameters:
      key - the metadata key to get the value for
      Returns:
      the value found on the first matching metadata key, or null if not found
      Since:
      2.1
    • numberMetadataValue

      public Number numberMetadataValue(String key)
      Get a specific metadata value for a given key as a number.
      Parameters:
      key - the metadata key to get the value for
      Returns:
      the value found on the first matching metadata key, or null if not found or the value cannot be coerced to a number
      Since:
      2.1
    • integerMetadataValue

      public Integer integerMetadataValue(String key)
      Get a specific metadata value for a given key as an integer.
      Parameters:
      key - the metadata key to get the value for
      Returns:
      the value found on the first matching metadata key, or null if not found or the value cannot be coerced to an integer
      Since:
      2.1
    • doubleMetadataValue

      public Double doubleMetadataValue(String key)
      Get a specific metadata value for a given key as a double.
      Parameters:
      key - the metadata key to get the value for
      Returns:
      the value found on the first matching metadata key, or null if not found or the value cannot be coerced to a double
      Since:
      2.1
    • saveMetadataValue

      public void saveMetadataValue(String key, Object value, boolean create)
      Save a specific metadata value for a given key, optionally adding a new KeyValuePair if not found.
      Parameters:
      key - the metadata key to get the value for
      value - the value to save
      create - true if a new KeyValuePair instance should be added if one with key does not already exist
      Since:
      2.1
    • saveMetadataValue

      public void saveMetadataValue(int index, String key, Object value, boolean create)
      Save a specific metadata value for a given key, optionally adding a new KeyValuePair if not found.
      Parameters:
      index - a specific index to save the metadata to
      key - the metadata key to use
      value - the value to save
      create - true if a new KeyValuePair instance should be added if one with key does not already exist
      Since:
      2.1
    • getUid

      public String getUid()
      Description copied from interface: Identifiable
      Get a unique identifier for this service.

      This should be meaningful to the service implementation, and should be minimally unique between instances of the same service interface.

      Specified by:
      getUid in interface Identifiable
      Returns:
      unique identifier (should never be null)
    • setUid

      public void setUid(String uid)
      Set the UID.
      Parameters:
      uid - the UID to set
    • getGroupUid

      public String getGroupUid()
      Description copied from interface: Identifiable
      Get a grouping identifier for this service.

      This should be meaningful to the service implementation.

      Specified by:
      getGroupUid in interface Identifiable
      Returns:
      a group identifier, or null if not part of any group
    • setGroupUid

      public void setGroupUid(String groupUid)
      Set the group UID.
      Parameters:
      groupUid - the group UID to set
    • getDisplayName

      public String getDisplayName()
      Description copied from interface: Identifiable
      Get a friendly display name for this service.
      Specified by:
      getDisplayName in interface Identifiable
      Returns:
      a display name
    • setDisplayName

      public void setDisplayName(String displayName)
      Set the display name.
      Parameters:
      displayName - the displayName to set
    • getMessageSource

      public org.springframework.context.MessageSource getMessageSource()
      Get a message source, to use for localizing this service with.
      Returns:
      a message source
    • setMessageSource

      public void setMessageSource(org.springframework.context.MessageSource messageSource)
      Set a message source, to use for localizing this service with.
      Parameters:
      messageSource - the message source to use
    • getUID

      @Deprecated public String getUID()
      Deprecated.
      since 2.0, use getUid()
      Alias for getUid().
      Returns:
      the UID
    • setUID

      @Deprecated public void setUID(String uid)
      Deprecated.
      since 2.0, use setUid(String)
      Set the UID.

      This is an alias for setUid(String), but only if a value has not already been set.

      Parameters:
      uid - the UID to set
    • getGroupUID

      @Deprecated public String getGroupUID()
      Deprecated.
      since 2.0, use getGroupUid()
      Alias for getGroupUid().
      Returns:
      the group UID
    • setGroupUID

      @Deprecated public void setGroupUID(String groupUid)
      Deprecated.
      since 2.0, use setGroupUid(String)
      Set the group UID.

      This is an alias for setGroupUid(String), but only if a value has not already been set.

      Parameters:
      groupUid - the group UID to set
    • getMetadata

      public KeyValuePair[] getMetadata()
      Get a list of metadata values.
      Returns:
      the metadata, or null
      Since:
      2.1
    • setMetadata

      public void setMetadata(KeyValuePair[] metadata)
      Set a list of metadata values.
      Parameters:
      metadata - the metadata to set, or null
      Since:
      2.1
    • getMetadataCount

      public int getMetadataCount()
      Get the number of configured metadata elements.
      Returns:
      the number of metadata elements
      Since:
      2.1
    • setMetadataCount

      public void setMetadataCount(int count)
      Adjust the number of configured metadata elements.

      Any newly added element values will be set to new KeyValuePair instances.

      Parameters:
      count - the desired number of metadata elements
      Since:
      2.1