Package net.solarnetwork.service.support
Class BasicIdentifiable
java.lang.Object
net.solarnetwork.service.support.BasicIdentifiable
- All Implemented Interfaces:
Identifiable
- Direct Known Subclasses:
SimpleTemporalRangesTariffEvaluator
Basic implementation of
Identifiable.- Since:
- 1.56
- Version:
- 2.1
- Author:
- matt
-
Field Summary
Fields inherited from interface net.solarnetwork.service.Identifiable
GROUP_UID_PROPERTY, UID_PROPERTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic List<SettingSpecifier>basicIdentifiableMetadataSettings(String prefix, KeyValuePair[] metadata) Get settings for the configurablemetadatalist property.static List<SettingSpecifier>Get settings for the configurable properties ofBasicIdentifiable.static List<SettingSpecifier>basicIdentifiableSettings(String prefix) static List<SettingSpecifier>basicIdentifiableSettings(String prefix, String defaultUid, String defaultGroupUid) Get a specific metadata value for a given key as a double.Get a friendly display name for this service.Get a grouping identifier for this service.Deprecated.org.springframework.context.MessageSourceGet a message source, to use for localizing this service with.Get a list of metadata values.intGet the number of configuredmetadataelements.getUid()Get a unique identifier for this service.getUID()Deprecated.since 2.0, usegetUid()Get a specific metadata value for a given key as an integer.metadataValue(String key) Get a specific metadata value for a given key.Get a specific metadata value for a given key as a number.voidsaveMetadataValue(int index, String key, Object value, boolean create) Save a specific metadata value for a given key, optionally adding a newKeyValuePairif not found.voidsaveMetadataValue(String key, Object value, boolean create) Save a specific metadata value for a given key, optionally adding a newKeyValuePairif not found.voidsetDisplayName(String displayName) Set the display name.voidsetGroupUid(String groupUid) Set the group UID.voidsetGroupUID(String groupUid) Deprecated.since 2.0, usesetGroupUid(String)voidsetMessageSource(org.springframework.context.MessageSource messageSource) Set a message source, to use for localizing this service with.voidsetMetadata(KeyValuePair[] metadata) Set a list of metadata values.voidsetMetadataCount(int count) Adjust the number of configuredmetadataelements.voidSet the UID.voidDeprecated.since 2.0, usesetUid(String)smartMetadataValue(String key) Get a specific metadata value for a given key, coerced to a number if possible.
-
Constructor Details
-
BasicIdentifiable
public BasicIdentifiable()
-
-
Method Details
-
basicIdentifiableSettings
Get settings for the configurable properties ofBasicIdentifiable.Empty strings are used for the
prefix, defaultuidand defaultgroupUidsetting values.- Returns:
- the settings
- Since:
- 1.1
- See Also:
-
basicIdentifiableSettings
Get settings for the configurableuid/groupUidproperties ofBasicIdentifiable.Empty strings are used for the default
uidandgroupUidsetting 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) - Parameters:
prefix- an optional prefix to include in all setting keysdefaultUid- the defaultuidvalue to usedefaultGroupUid- the defaultgroupUidvalue to use- Returns:
- the settings
- Since:
- 1.1
-
basicIdentifiableMetadataSettings
public static List<SettingSpecifier> basicIdentifiableMetadataSettings(String prefix, KeyValuePair[] metadata) Get settings for the configurablemetadatalist property.- Parameters:
prefix- an optional prefix to include in all setting keysmetadata- the metadata to get settings for- Returns:
- the settings
- Since:
- 2.1
- See Also:
-
metadataValue
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
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
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
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
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
Save a specific metadata value for a given key, optionally adding a newKeyValuePairif not found.- Parameters:
key- the metadata key to get the value forvalue- the value to savecreate- true if a newKeyValuePairinstance should be added if one withkeydoes not already exist- Since:
- 2.1
-
saveMetadataValue
Save a specific metadata value for a given key, optionally adding a newKeyValuePairif not found.- Parameters:
index- a specific index to save the metadata tokey- the metadata key to usevalue- the value to savecreate- true if a newKeyValuePairinstance should be added if one withkeydoes not already exist- Since:
- 2.1
-
getUid
Description copied from interface:IdentifiableGet 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:
getUidin interfaceIdentifiable- Returns:
- unique identifier (should never be null)
-
setUid
Set the UID.- Parameters:
uid- the UID to set
-
getGroupUid
Description copied from interface:IdentifiableGet a grouping identifier for this service.This should be meaningful to the service implementation.
- Specified by:
getGroupUidin interfaceIdentifiable- Returns:
- a group identifier, or null if not part of any group
-
setGroupUid
Set the group UID.- Parameters:
groupUid- the group UID to set
-
getDisplayName
Description copied from interface:IdentifiableGet a friendly display name for this service.- Specified by:
getDisplayNamein interfaceIdentifiable- Returns:
- a display name
-
setDisplayName
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.since 2.0, usegetUid()Alias forgetUid().- Returns:
- the UID
-
setUID
Deprecated.since 2.0, usesetUid(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.since 2.0, usegetGroupUid()Alias forgetGroupUid().- Returns:
- the group UID
-
setGroupUID
Deprecated.since 2.0, usesetGroupUid(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
Get a list of metadata values.- Returns:
- the metadata, or null
- Since:
- 2.1
-
setMetadata
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 configuredmetadataelements.- Returns:
- the number of
metadataelements - Since:
- 2.1
-
setMetadataCount
public void setMetadataCount(int count) Adjust the number of configuredmetadataelements.Any newly added element values will be set to new
KeyValuePairinstances.- Parameters:
count- the desired number ofmetadataelements- Since:
- 2.1
-
getGroupUid()