2 * Copyright (c) 2010-2023 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;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
20 * Information about the ping result.
22 * @author Andreas Hirsch - Initial contribution
25 public class PingResult {
27 private boolean success;
28 private Optional<Double> responseTimeInMS = Optional.empty();
29 private double executionTimeInMS;
32 * @param success <code>true</code> if the device was reachable, <code>false</code> if not.
33 * @param executionTimeInMS Execution time of the ping command in ms.
35 public PingResult(boolean success, double executionTimeInMS) {
36 this.success = success;
37 this.executionTimeInMS = executionTimeInMS;
41 * @return <code>true</code> if the device was reachable, <code>false</code> if not.
43 public boolean isSuccess() {
48 * @return Response time in ms which was returned by the ping command. Optional is empty if response time provided
49 * by ping command is not available.
51 public Optional<Double> getResponseTimeInMS() {
52 return responseTimeInMS;
56 * @param responseTimeInMS Response time in ms which was returned by the ping command.
58 public void setResponseTimeInMS(double responseTimeInMS) {
59 this.responseTimeInMS = Optional.of(responseTimeInMS);
63 public String toString() {
64 return "PingResult{" + "success=" + success + ", responseTimeInMS=" + responseTimeInMS + ", executionTimeInMS="
65 + executionTimeInMS + '}';
69 * @return Execution time of the ping command in ms.
71 public double getExecutionTimeInMS() {
72 return executionTimeInMS;