Class InstructionUtils

java.lang.Object
net.solarnetwork.node.reactor.InstructionUtils

public final class InstructionUtils extends Object
Utilities for dealing with common Instruction patterns.
Since:
2.0
Version:
1.2
Author:
matt
  • Method Details

    • createStatus

      public static InstructionStatus createStatus(Instruction instruction, net.solarnetwork.domain.InstructionStatus.InstructionState state)
      Create a new status for a given instruction.
      Parameters:
      instruction - the instruction, or null
      state - the new state
      Returns:
      the status, never null
    • createStatus

      public static InstructionStatus createStatus(Instruction instruction, net.solarnetwork.domain.InstructionStatus.InstructionState state, Map<String,?> resultParameters)
      Create a new status for a given instruction.
      Parameters:
      instruction - the instruction, or null
      state - the new state
      resultParameters - the optional result parameters
      Returns:
      the status, never null
    • createStatus

      public static InstructionStatus createStatus(Instruction instruction, net.solarnetwork.domain.InstructionStatus.InstructionState state, Instant date, Map<String,?> resultParameters)
      Create a new status for a given instruction.
      Parameters:
      instruction - the instruction, or null
      state - the new state
      date - the status date
      resultParameters - the optional result parameters
      Returns:
      the status, never null
    • createLocalInstruction

      public static Instruction createLocalInstruction(String topic, Map<String,String> params)
      Create a new local instruction with an optional parameter.

      The returned Instruction.getInstructorId() value will be Instruction.LOCAL_INSTRUCTION_ID.

      Parameters:
      topic - the instruction topic
      params - an optional map of parameters
      Returns:
      the new instruction, never null
    • createLocalInstruction

      public static Instruction createLocalInstruction(String topic, String paramName, String paramValue)
      Create a new local instruction with an optional parameter.

      The returned Instruction.getInstructorId() value will be Instruction.LOCAL_INSTRUCTION_ID.

      Parameters:
      topic - the instruction topic
      paramName - an optional parameter name
      paramValue - if paramName provided then the corresponding parameter value
      Returns:
      the new instruction, never null
    • createSetControlValueLocalInstruction

      public static Instruction createSetControlValueLocalInstruction(String controlId, Object controlValue)
      Create a new local instruction for

      The returned Instruction.getInstructorId() value will be Instruction.LOCAL_INSTRUCTION_ID.

      Parameters:
      controlId - the ID of the control to set the control value to
      controlValue - the value to set the control to
      Returns:
      the new instruction, never null
    • createErrorResultParameters

      public static Map<String,Object> createErrorResultParameters(String message, String code)
      Create a result parameter map for an error message and/or code.
      Parameters:
      message - the message
      code - the code
      Returns:
      the map, never null
      Since:
      1.1
    • localInstructionFrom

      public static Instruction localInstructionFrom(net.solarnetwork.domain.Instruction instr)
      Create a local instruction from another instruction.
      Parameters:
      instr - the instruction
      Returns:
      the new instruction with a local ID assigned
      Since:
      1.2