Interface Instruction

All Superinterfaces:
net.solarnetwork.domain.Instruction
All Known Implementing Classes:
BasicInstruction

public interface Instruction extends net.solarnetwork.domain.Instruction
API for a single, immutable instruction with associated parameters.

An instruction is like a single name (the topic) with an arbitrary number of named key/value parameters. All parameter names and values are Strings. Each parameter can have any number of associated values.

An Instruction is considered equal to another Instruction only if the instructionId and instructorId values are equal.

Version:
2.2
Author:
matt
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    An ID to use for locally-initiated instructions, in getInstructorId().
    static final String
    The name of an instruction parameter that represents the desired execution date for the instruction.
    static final String
    The task instruction parameter for a "parent" instruction ID.
    static final String
    The task instruction parameter for the "parent" instructor ID.
  • Method Summary

    Modifier and Type
    Method
    Description
    default Instant
    Get the instruction execution date, if available.
    default String
    Get an identifier for this instruction.
    Get the unique ID for the sender of the instruction, for example the DN of the sender's certificate.
    Get the instruction state.
    default boolean
    Test if this instruction is a local instruction.
    default Instant
    Get a date parameter value, if available.

    Methods inherited from interface net.solarnetwork.domain.Instruction

    getAllParameterValues, getId, getInstructionDate, getInstructionState, getParameterMap, getParameterMultiMap, getParameterNames, getParameterValue, getTopic, isParameterAvailable
  • Field Details

    • LOCAL_INSTRUCTION_ID

      static final String LOCAL_INSTRUCTION_ID
      An ID to use for locally-initiated instructions, in getInstructorId().
      See Also:
    • PARAM_EXECUTION_DATE

      static final String PARAM_EXECUTION_DATE
      The name of an instruction parameter that represents the desired execution date for the instruction.

      The parameter value can be either a long epoch millisecond value or an ISO 8601 instant.

      Since:
      2.1
      See Also:
    • PARAM_PARENT_INSTRUCTION_ID

      static final String PARAM_PARENT_INSTRUCTION_ID
      The task instruction parameter for a "parent" instruction ID.

      This parameter can be used to track instructions created by other instructions.

      Since:
      2.2
      See Also:
    • PARAM_PARENT_INSTRUCTOR_ID

      static final String PARAM_PARENT_INSTRUCTOR_ID
      The task instruction parameter for the "parent" instructor ID.

      This parameter can be used to track instructions created by other instructions.

      Since:
      2.2
      See Also:
  • Method Details

    • getIdentifier

      default String getIdentifier()
      Get an identifier for this instruction.

      This can be used for logging, display, etc.

      Returns:
      an identifier, never null
    • getInstructorId

      String getInstructorId()
      Get the unique ID for the sender of the instruction, for example the DN of the sender's certificate.
      Returns:
      the instructor ID
    • getStatus

      InstructionStatus getStatus()
      Get the instruction state.
      Specified by:
      getStatus in interface net.solarnetwork.domain.Instruction
      Returns:
      the state, or null if none available
    • getExecutionDate

      default Instant getExecutionDate()
      Get the instruction execution date, if available.

      This method looks for the PARAM_EXECUTION_DATE parameter and tries to parse that as a date. The parameter value can be either a long epoch millisecond value or an ISO 8601 instant.

      Returns:
      the instruction execution date, or null if one is not available or cannot be parsed
      Since:
      2.1
      See Also:
    • timestampParameterValue

      default Instant timestampParameterValue(String parameterName)
      Get a date parameter value, if available.

      This method supports the same date format as described in the PARAM_EXECUTION_DATE parameter: the parameter value can be either a long epoch millisecond value or an ISO 8601 instant.

      Parameters:
      parameterName - the name of the parameter to parse as a timestamp
      Returns:
      the parameter value parsed as a timestamp, or null if one is not available or cannot be parsed
      Since:
      2.2
      See Also:
    • isLocal

      default boolean isLocal()
      Test if this instruction is a local instruction.
      Returns:
      true if getInstructorId() is LOCAL_INSTRUCTION_ID
      Since:
      2.2