Skip to content

Package: DeviceNotConnectedException

DeviceNotConnectedException

nameinstructionbranchcomplexitylinemethod
DeviceNotConnectedException(KapuaId)
M: 20 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
DeviceNotConnectedException(KapuaId, DeviceConnectionStatus)
M: 20 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
getCurrentConnectionStatus()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getDeviceId()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2019, 2022 Eurotech and/or its affiliates and others
3: *
4: * This program and the accompanying materials are made
5: * available under the terms of the Eclipse Public License 2.0
6: * which is available at https://www.eclipse.org/legal/epl-2.0/
7: *
8: * SPDX-License-Identifier: EPL-2.0
9: *
10: * Contributors:
11: * Eurotech - initial API and implementation
12: *******************************************************************************/
13: package org.eclipse.kapua.service.device.management.exception;
14:
15: import org.eclipse.kapua.model.id.KapuaId;
16: import org.eclipse.kapua.service.device.registry.Device;
17: import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionStatus;
18:
19: import javax.validation.constraints.NotNull;
20:
21: /**
22: * The {@link DeviceManagementException} to throw when the {@link Device} is not connected.
23: *
24: * @since 1.1.0
25: */
26: public class DeviceNotConnectedException extends DeviceManagementException {
27:
28: private static final long serialVersionUID = 1216557444738236796L;
29:
30: private final KapuaId deviceId;
31: private final DeviceConnectionStatus currentConnectionStatus;
32:
33: /**
34: * Constructor.
35: *
36: * @param deviceId The {@link Device#getId()} which is not {@link DeviceConnectionStatus#CONNECTED}
37: * @since 1.1.0
38: */
39: protected DeviceNotConnectedException(@NotNull KapuaId deviceId) {
40: super(DeviceManagementErrorCodes.DEVICE_NOT_CONNECTED, deviceId, null);
41:
42: this.deviceId = deviceId;
43: this.currentConnectionStatus = null;
44: }
45:
46: /**
47: * Constructor.
48: *
49: * @param deviceId The {@link Device#getId()} which is not {@link DeviceConnectionStatus#CONNECTED}
50: * @param currentConnectionStatus The current {@link DeviceConnectionStatus} of the {@link Device}
51: * @since 1.1.0
52: */
53: public DeviceNotConnectedException(@NotNull KapuaId deviceId, @NotNull DeviceConnectionStatus currentConnectionStatus) {
54: super(DeviceManagementErrorCodes.DEVICE_NOT_CONNECTED, deviceId, currentConnectionStatus);
55:
56: this.deviceId = deviceId;
57: this.currentConnectionStatus = currentConnectionStatus;
58: }
59:
60: /**
61: * Gets the {@link Device#getId()} which is not {@link DeviceConnectionStatus#CONNECTED}
62: *
63: * @return The {@link Device#getId()} which is not {@link DeviceConnectionStatus#CONNECTED}
64: * @since 1.1.0
65: */
66: public KapuaId getDeviceId() {
67: return deviceId;
68: }
69:
70: /**
71: * Gets the current {@link DeviceConnectionStatus} of the {@link Device}
72: *
73: * @return The current {@link DeviceConnectionStatus} of the {@link Device}
74: * @since 1.1.0
75: */
76: public DeviceConnectionStatus getCurrentConnectionStatus() {
77: return currentConnectionStatus;
78: }
79: }