/** * Creates a command response for a reply-to ID, correlation ID and status. * * @param payload The command response payload. * @param contentType The content-type of the response payload. * @param status The HTTP status code indicating the outcome of executing the command on the device. * @param correlationId The identifier used to correlate this response with the command request. * @param address The address that the command response is to be sent to. * * @return The command response or {@code null} if any of correlationId, replyTo and status is null or if the * status code is < 200 or >= 600. */ public static CommandResponse from(final Buffer payload, final String contentType, final Integer status, final String correlationId, final ResourceIdentifier address) { if (correlationId == null || address == null || status == null) { return null; } else if (INVALID_STATUS_CODE.test(status)) { return null; } else { return new CommandResponse(payload, contentType, status, correlationId, address.getPathWithoutBase()); } }
final int lengthStringOne = Integer.parseInt(requestId.substring(1, 3), 16); final String replyId = requestId.substring(3 + lengthStringOne); return new CommandResponse( payload, contentType,