Class ExpressionRoot

java.lang.Object
java.util.AbstractMap<String,Object>
net.solarnetwork.domain.datum.DatumSamplesExpressionRoot
net.solarnetwork.node.domain.ExpressionRoot
All Implemented Interfaces:
Map<String,Object>, net.solarnetwork.domain.datum.DatumExpressionRoot, net.solarnetwork.domain.datum.DatumMathFunctions

public class ExpressionRoot extends net.solarnetwork.domain.datum.DatumSamplesExpressionRoot
An object to use as the "root" for ExpressionService evaluation.

This object extends DatumSamplesExpressionRoot to allow all datum sample properties to be exposed as top-level expression properties (via the Map API).

Since:
1.79
Version:
2.1
Author:
matt
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.util.AbstractMap

    AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>

    Nested classes/interfaces inherited from interface java.util.Map

    Map.Entry<K extends Object,V extends Object>
  • Constructor Summary

    Constructors
    Constructor
    Description
    ExpressionRoot(Map<String,?> data, net.solarnetwork.domain.datum.Datum datum)
    Constructor.
    ExpressionRoot(net.solarnetwork.domain.datum.Datum datum)
    Constructor.
    ExpressionRoot(net.solarnetwork.domain.datum.Datum datum, net.solarnetwork.domain.datum.DatumSamplesOperations samples)
    Constructor.
    ExpressionRoot(net.solarnetwork.domain.datum.Datum datum, net.solarnetwork.domain.datum.DatumSamplesOperations samples, Map<String,?> parameters, DatumService datumService)
    Constructor.
    ExpressionRoot(net.solarnetwork.domain.datum.Datum datum, net.solarnetwork.domain.datum.DatumSamplesOperations samples, Map<String,?> parameters, DatumService datumService, OperationalModesService opModesService)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    net.solarnetwork.domain.datum.DatumMetadataOperations
    Get the metadata for the getSourceId() datum stream.
    Get the datum's source ID.
    Get the datum's timestamp.
    boolean
    hasLatest(String sourceId)
    Test if a "latest" datum is available for a given source ID.
    boolean
    hasLatestMatching(String sourceIdPattern)
    Test if a "latest" datum is available for a given source ID.
    boolean
    Test if a "latest" datum is available for a given source ID, excluding the getSourceId() source ID.
    boolean
    Test if metadata for the getSourceId() datum stream is available.
    boolean
    hasMeta(String sourceId)
    Test if metadata for a given datum stream is available.
    boolean
    hasOffset(int offset)
    Test if an offset from a "latest" datum is available for the DatumSamplesExpressionRoot.getDatum() source ID and timestamp.
    boolean
    hasOffset(String sourceId, int offset)
    Test if an offset from a "latest" datum is available for a given source ID.
    boolean
    hasOffset(String sourceId, Instant timestamp, int offset)
    Test if a datum offset from a given timestamp is available for a given source ID.
    boolean
    Test if an operational mode is active.
    net.solarnetwork.domain.datum.DatumExpressionRoot
    latest(String sourceId)
    Get the latest available datum for a given source ID, as an DatumExpressionRoot.
    Collection<net.solarnetwork.domain.datum.DatumExpressionRoot>
    latestMatching(String sourceIdPattern)
    Get the latest available datum matching a given source ID pattern, as DatumExpressionRoot instances.
    Collection<net.solarnetwork.domain.datum.DatumExpressionRoot>
    latestOthersMatching(String sourceIdPattern)
    Get the latest available datum matching a given source ID pattern, excluding the getSourceId() source ID, as DatumExpressionRoot instances.
    net.solarnetwork.domain.datum.DatumMetadataOperations
    meta(String sourceId)
    Get the metadata for a given datum stream.
    Collection<net.solarnetwork.domain.datum.DatumMetadataOperations>
    metaMatching(String sourceIdFilter)
    Get the metadata for a set of datum streams matching a filter.
    net.solarnetwork.domain.datum.DatumExpressionRoot
    offset(int offset)
    Get an offset from latest available datum for the DatumSamplesExpressionRoot.getDatum() source ID and timestamp, as an DatumExpressionRoot.
    net.solarnetwork.domain.datum.DatumExpressionRoot
    offset(String sourceId, int offset)
    Get an offset from latest available datum for a given source ID, as an DatumExpressionRoot.
    net.solarnetwork.domain.datum.DatumExpressionRoot
    offset(String sourceId, Instant timestamp, int offset)
    Get a datum offset from a given timestamp for a given source ID, as an DatumExpressionRoot.
    Collection<net.solarnetwork.domain.datum.DatumExpressionRoot>
    selfAndLatestMatching(String sourceIdPattern)
    Get the latest available datum matching a given source ID pattern, including this instance, as DatumExpressionRoot instances.
     

    Methods inherited from class net.solarnetwork.domain.datum.DatumSamplesExpressionRoot

    containsKey, entrySet, get, getData, getDatum, getParameters, getProps, getSamples, group, has

    Methods inherited from class java.util.AbstractMap

    clear, clone, containsValue, equals, hashCode, isEmpty, keySet, put, putAll, remove, size, values

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface net.solarnetwork.domain.datum.DatumMathFunctions

    and, andNot, avg, ceil, ceil, decimal, down, down, floor, floor, integer, max, max, min, min, mround, narrow, narrow16, narrow32, narrow64, narrow8, not, or, round, round, roundDown, roundUp, shiftLeft, shiftRight, sum, testBit, up, up, xor
  • Constructor Details

    • ExpressionRoot

      public ExpressionRoot(net.solarnetwork.domain.datum.Datum datum)
      Constructor.
      Parameters:
      datum - the datum currently being populated
    • ExpressionRoot

      public ExpressionRoot(net.solarnetwork.domain.datum.Datum datum, net.solarnetwork.domain.datum.DatumSamplesOperations samples)
      Constructor.
      Parameters:
      datum - the datum currently being populated
      samples - the samples
    • ExpressionRoot

      public ExpressionRoot(Map<String,?> data, net.solarnetwork.domain.datum.Datum datum)
      Constructor.
      Parameters:
      data - the map data
      datum - the datum currently being populated
      Since:
      1.2
    • ExpressionRoot

      public ExpressionRoot(net.solarnetwork.domain.datum.Datum datum, net.solarnetwork.domain.datum.DatumSamplesOperations samples, Map<String,?> parameters, DatumService datumService)
      Constructor.
      Parameters:
      datum - the datum currently being populated
      samples - the samples
      parameters - the parameters
      datumService - the optional datum service
    • ExpressionRoot

      public ExpressionRoot(net.solarnetwork.domain.datum.Datum datum, net.solarnetwork.domain.datum.DatumSamplesOperations samples, Map<String,?> parameters, DatumService datumService, OperationalModesService opModesService)
      Constructor.
      Parameters:
      datum - the datum currently being populated
      samples - the samples
      parameters - the parameters
      datumService - the optional datum service
      opModesService - the optional operational modes service
      Since:
      2.1
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class AbstractMap<String,Object>
    • hasLatest

      public boolean hasLatest(String sourceId)
      Test if a "latest" datum is available for a given source ID.

      This can be used to test if latest(String) will return a non-null value.

      Parameters:
      sourceId - the source ID of the datum to look for
      Returns:
      true if latest(String) for the given sourceId will return a non-null value
    • latest

      public net.solarnetwork.domain.datum.DatumExpressionRoot latest(String sourceId)
      Get the latest available datum for a given source ID, as an DatumExpressionRoot.

      Note a non-null DatumService instance must have been provided to the constructor of this instance for this method to work.

      Parameters:
      sourceId - the source ID of the datum to look for
      Returns:
      the latest datum, or null if sourceId is null, the DatumService provided to this instance's constructor was null, or DatumService.latest(java.util.Set, Class) returns null for the given sourceId
    • hasLatestMatching

      public boolean hasLatestMatching(String sourceIdPattern)
      Test if a "latest" datum is available for a given source ID.

      This can be used to test if latestMatching(String) will return a non-null value.

      Parameters:
      sourceIdPattern - the Ant-style source ID pattern of the datum to look for
      Returns:
      true if latestMatching(String) for the given sourceIdPattern will return a non-null value
    • latestMatching

      public Collection<net.solarnetwork.domain.datum.DatumExpressionRoot> latestMatching(String sourceIdPattern)
      Get the latest available datum matching a given source ID pattern, as DatumExpressionRoot instances.

      Note a non-null DatumService instance must have been provided to the constructor of this instance for this method to work.

      Parameters:
      sourceIdPattern - the Ant-style source ID pattern of the datum to look for
      Returns:
      the matching datum, never null
    • hasLatestOthersMatching

      public boolean hasLatestOthersMatching(String sourceIdPattern)
      Test if a "latest" datum is available for a given source ID, excluding the getSourceId() source ID.

      This can be used to test if latestOthersMatching(String) will return a non-null value.

      Parameters:
      sourceIdPattern - the Ant-style source ID pattern of the datum to look for
      Returns:
      true if latestMatching(String) for the given sourceIdPattern will return a non-null value
    • latestOthersMatching

      public Collection<net.solarnetwork.domain.datum.DatumExpressionRoot> latestOthersMatching(String sourceIdPattern)
      Get the latest available datum matching a given source ID pattern, excluding the getSourceId() source ID, as DatumExpressionRoot instances.

      Note a non-null DatumService instance must have been provided to the constructor of this instance for this method to work.

      Parameters:
      sourceIdPattern - the Ant-style source ID pattern of the datum to look for
      Returns:
      the matching datum, never null
    • selfAndLatestMatching

      public Collection<net.solarnetwork.domain.datum.DatumExpressionRoot> selfAndLatestMatching(String sourceIdPattern)
      Get the latest available datum matching a given source ID pattern, including this instance, as DatumExpressionRoot instances.

      Note a non-null DatumService instance must have been provided to the constructor of this instance for this method to work.

      Parameters:
      sourceIdPattern - the Ant-style source ID pattern of the datum to look for
      Returns:
      the matching datum, never null and always having at least one value (this instance)
    • getSourceId

      public String getSourceId()
      Get the datum's source ID.
      Returns:
      the source ID, or null
      Since:
      2.1
    • getTimestamp

      public Instant getTimestamp()
      Get the datum's timestamp.
      Returns:
      the timestamp, or null
      Since:
      2.1
    • hasOffset

      public boolean hasOffset(int offset)
      Test if an offset from a "latest" datum is available for the DatumSamplesExpressionRoot.getDatum() source ID and timestamp.

      This can be used to test if offset(int) will return a non-null value.

      Parameters:
      offset - the offset from the latest, 0 being the latest and 1 the next later, and so on
      Returns:
      true if offset(String, Instant, int) will return a non-null value
      Since:
      2.1
      See Also:
    • offset

      public net.solarnetwork.domain.datum.DatumExpressionRoot offset(int offset)
      Get an offset from latest available datum for the DatumSamplesExpressionRoot.getDatum() source ID and timestamp, as an DatumExpressionRoot.

      Note a non-null DatumService instance must have been provided to the constructor of this instance for this method to work.

      Parameters:
      offset - the offset from the latest, 0 being the latest and 1 the next later, and so on
      Returns:
      the offset from the latest datum, or null if getSourceId() or getTimestamp() are null, the DatumService provided to this instance's constructor was null, or DatumService.offset(java.util.Set, int, Class) returns null for getSourceId()
      Since:
      2.1
      See Also:
    • hasOffset

      public boolean hasOffset(String sourceId, int offset)
      Test if an offset from a "latest" datum is available for a given source ID.

      This can be used to test if offset(String,int) will return a non-null value.

      Parameters:
      sourceId - the source ID of the datum to look for
      offset - the offset from the latest, 0 being the latest and 1 the next later, and so on
      Returns:
      true if offset(String, int) for the given sourceId will return a non-null value
      Since:
      2.1
    • offset

      public net.solarnetwork.domain.datum.DatumExpressionRoot offset(String sourceId, int offset)
      Get an offset from latest available datum for a given source ID, as an DatumExpressionRoot.

      Note a non-null DatumService instance must have been provided to the constructor of this instance for this method to work.

      Parameters:
      sourceId - the source ID of the datum to look for
      offset - the offset from the latest, 0 being the latest and 1 the next later, and so on
      Returns:
      the offset from the latest datum, or null if sourceId is null, the DatumService provided to this instance's constructor was null, or DatumService.offset(java.util.Set, int, Class) returns null for the given sourceId
      Since:
      2.1
    • hasOffset

      public boolean hasOffset(String sourceId, Instant timestamp, int offset)
      Test if a datum offset from a given timestamp is available for a given source ID.

      This can be used to test if offset(String,Instant,int) will return a non-null value.

      Parameters:
      sourceId - the source ID of the datum to look for
      timestamp - the timestamp refernce point
      offset - the offset from the latest, 0 being the latest and 1 the next later, and so on
      Returns:
      true if offset(String, int) for the given sourceId will return a non-null value
      Since:
      2.1
    • offset

      public net.solarnetwork.domain.datum.DatumExpressionRoot offset(String sourceId, Instant timestamp, int offset)
      Get a datum offset from a given timestamp for a given source ID, as an DatumExpressionRoot.

      Note a non-null DatumService instance must have been provided to the constructor of this instance for this method to work.

      Parameters:
      sourceId - the source ID of the datum to look for
      timestamp - the timestamp reference point
      offset - the offset from the latest, 0 being the latest and 1 the next later, and so on
      Returns:
      the offset from the latest datum, or null if sourceId is null, the DatumService provided to this instance's constructor was null, or DatumService.offset(java.util.Set, int, Class) returns null for the given sourceId
      Since:
      2.1
    • isOpMode

      public boolean isOpMode(String mode)
      Test if an operational mode is active.
      Parameters:
      mode - the mode to test
      Returns:
      true if the OperationalModesService provided to this instance's constructor was not null and OperationalModesService.isOperationalModeActive(String) returns true for the given mode
      Since:
      2.1
      See Also:
    • hasMeta

      public boolean hasMeta()
      Test if metadata for the getSourceId() datum stream is available.
      Returns:
      true if metadata for getSourceId() is available
      Since:
      2.1
    • getMeta

      public net.solarnetwork.domain.datum.DatumMetadataOperations getMeta()
      Get the metadata for the getSourceId() datum stream.
      Returns:
      the metadata, or null if no such metadata is available
      Since:
      2.1
    • hasMeta

      public boolean hasMeta(String sourceId)
      Test if metadata for a given datum stream is available.
      Parameters:
      sourceId - the source ID of the datum metadata to get
      Returns:
      true if metadata for sourceId is available
      Since:
      2.1
    • meta

      public net.solarnetwork.domain.datum.DatumMetadataOperations meta(String sourceId)
      Get the metadata for a given datum stream.
      Parameters:
      sourceId - the source ID of the datum metadata to get
      Returns:
      the metadata, or null if no such metadata is available
      Since:
      2.1
    • metaMatching

      public Collection<net.solarnetwork.domain.datum.DatumMetadataOperations> metaMatching(String sourceIdFilter)
      Get the metadata for a set of datum streams matching a filter.
      Parameters:
      sourceIdFilter - an optional Ant-style source ID pattern to filter by; use null to return metadata for all available sources
      Returns:
      the matching metadata, never null
      Since:
      2.1