2 * Copyright (c) 2010-2021 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.network.internal.utils;
15 import java.util.Optional;
18 * Information about the ping result.
20 * @author Andreas Hirsch - Initial contribution
22 public class PingResult {
24 private boolean success;
25 private Double responseTimeInMS;
26 private double executionTimeInMS;
29 * @param success <code>true</code> if the device was reachable, <code>false</code> if not.
30 * @param executionTimeInMS Execution time of the ping command in ms.
32 public PingResult(boolean success, double executionTimeInMS) {
33 this.success = success;
34 this.executionTimeInMS = executionTimeInMS;
38 * @return <code>true</code> if the device was reachable, <code>false</code> if not.
40 public boolean isSuccess() {
45 * @return Response time in ms which was returned by the ping command. Optional is empty if response time provided
46 * by ping command is not available.
48 public Optional<Double> getResponseTimeInMS() {
49 return responseTimeInMS == null ? Optional.empty() : Optional.of(responseTimeInMS);
53 * @param responseTimeInMS Response time in ms which was returned by the ping command.
55 public void setResponseTimeInMS(double responseTimeInMS) {
56 this.responseTimeInMS = responseTimeInMS;
60 public String toString() {
61 return "PingResult{" + "success=" + success + ", responseTimeInMS=" + responseTimeInMS + ", executionTimeInMS="
62 + executionTimeInMS + '}';
66 * @return Execution time of the ping command in ms.
68 public double getExecutionTimeInMS() {
69 return executionTimeInMS;