]> git.basschouten.com Git - openhab-addons.git/blob
b5b3a4eda55ffa74969883a1f917606d31f06cb7
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.io.transport.modbus;
14
15 import java.util.Objects;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18
19 /**
20  * Encapsulates result of modbus write operations
21  *
22  * @author Sami Salonen - Initial contribution
23  */
24 @NonNullByDefault
25 public class AsyncModbusWriteResult {
26
27     private final ModbusWriteRequestBlueprint request;
28
29     private final ModbusResponse response;
30
31     public AsyncModbusWriteResult(ModbusWriteRequestBlueprint request, ModbusResponse response) {
32         Objects.requireNonNull(request, "Request must not be null!");
33         Objects.requireNonNull(response, "Response must not be null!");
34         this.request = request;
35         this.response = response;
36     }
37
38     /**
39      * Get request matching this response
40      *
41      * @return request object
42      */
43     public ModbusWriteRequestBlueprint getRequest() {
44         return request;
45     }
46
47     /**
48      * Get response
49      *
50      * @return response
51      */
52     public ModbusResponse getResponse() {
53         return response;
54     }
55
56     @Override
57     public String toString() {
58         StringBuilder builder = new StringBuilder("AsyncModbusWriteResult(");
59         builder.append("request = ");
60         builder.append(request);
61         builder.append(", response = ");
62         builder.append(response);
63         builder.append(")");
64         return builder.toString();
65     }
66 }