Package net.solarnetwork.node.reactor
Class InstructionUtils
java.lang.Object
net.solarnetwork.node.reactor.InstructionUtils
Utilities for dealing with common Instruction patterns.
- Since:
- 2.0
- Version:
- 1.2
- Author:
- matt
-
Method Summary
Modifier and TypeMethodDescriptioncreateErrorResultParameters(String message, String code) Create a result parameter map for an error message and/or code.static InstructioncreateLocalInstruction(String topic, String paramName, String paramValue) Create a new local instruction with an optional parameter.static InstructioncreateLocalInstruction(String topic, Map<String, String> params) Create a new local instruction with an optional parameter.static InstructioncreateSetControlValueLocalInstruction(String controlId, Object controlValue) Create a new local instruction forstatic InstructionStatuscreateStatus(Instruction instruction, net.solarnetwork.domain.InstructionStatus.InstructionState state) Create a new status for a given instruction.static InstructionStatuscreateStatus(Instruction instruction, net.solarnetwork.domain.InstructionStatus.InstructionState state, Instant date, Map<String, ?> resultParameters) Create a new status for a given instruction.static InstructionStatuscreateStatus(Instruction instruction, net.solarnetwork.domain.InstructionStatus.InstructionState state, Map<String, ?> resultParameters) Create a new status for a given instruction.static InstructionlocalInstructionFrom(net.solarnetwork.domain.Instruction instr) Create a local instruction from another instruction.
-
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 nullstate- 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 nullstate- the new stateresultParameters- 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 nullstate- the new statedate- the status dateresultParameters- the optional result parameters- Returns:
- the status, never null
-
createLocalInstruction
Create a new local instruction with an optional parameter.The returned
Instruction.getInstructorId()value will beInstruction.LOCAL_INSTRUCTION_ID.- Parameters:
topic- the instruction topicparams- an optional map of parameters- Returns:
- the new instruction, never null
-
createLocalInstruction
Create a new local instruction with an optional parameter.The returned
Instruction.getInstructorId()value will beInstruction.LOCAL_INSTRUCTION_ID.- Parameters:
topic- the instruction topicparamName- an optional parameter nameparamValue- ifparamNameprovided 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 forThe returned
Instruction.getInstructorId()value will beInstruction.LOCAL_INSTRUCTION_ID.- Parameters:
controlId- the ID of the control to set the control value tocontrolValue- the value to set the control to- Returns:
- the new instruction, never null
-
createErrorResultParameters
Create a result parameter map for an error message and/or code.- Parameters:
message- the messagecode- the code- Returns:
- the map, never null
- Since:
- 1.1
-
localInstructionFrom
Create a local instruction from another instruction.- Parameters:
instr- the instruction- Returns:
- the new instruction with a local ID assigned
- Since:
- 1.2
-