Warning and codeanalysis (#15828)
Signed-off-by: Leo Siepel <leosiepel@gmail.com>
This commit is contained in:
parent
7724f16e7c
commit
fddacb4c80
@ -28,7 +28,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class BluetoothUtils {
|
public class BluetoothUtils {
|
||||||
|
|
||||||
public static final Logger logger = LoggerFactory.getLogger(BluetoothUtils.class);
|
public static final Logger LOGGER = LoggerFactory.getLogger(BluetoothUtils.class);
|
||||||
|
|
||||||
public static final int FORMAT_UINT8 = 0x11;
|
public static final int FORMAT_UINT8 = 0x11;
|
||||||
public static final int FORMAT_UINT16 = 0x12;
|
public static final int FORMAT_UINT16 = 0x12;
|
||||||
@ -47,9 +47,7 @@ public class BluetoothUtils {
|
|||||||
*/
|
*/
|
||||||
public static int[] toIntArray(byte[] value) {
|
public static int[] toIntArray(byte[] value) {
|
||||||
int[] ret = new int[value.length];
|
int[] ret = new int[value.length];
|
||||||
for (int i = 0; i < value.length; i++) {
|
System.arraycopy(value, 0, ret, 0, value.length);
|
||||||
ret[i] = value[i];
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +88,7 @@ public class BluetoothUtils {
|
|||||||
return unsignedToSigned(
|
return unsignedToSigned(
|
||||||
unsignedBytesToInt(value[offset], value[offset + 1], value[offset + 2], value[offset + 3]), 32);
|
unsignedBytesToInt(value[offset], value[offset + 1], value[offset + 2], value[offset + 3]), 32);
|
||||||
default:
|
default:
|
||||||
logger.error("Unknown format type {} - no int value can be provided for it.", formatType);
|
LOGGER.error("Unknown format type {} - no int value can be provided for it.", formatType);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -111,7 +109,7 @@ public class BluetoothUtils {
|
|||||||
case FORMAT_FLOAT:
|
case FORMAT_FLOAT:
|
||||||
return bytesToFloat(value[offset], value[offset + 1], value[offset + 2], value[offset + 3]);
|
return bytesToFloat(value[offset], value[offset + 1], value[offset + 2], value[offset + 3]);
|
||||||
default:
|
default:
|
||||||
logger.error("Unknown format type {} - no float value can be provided for it.", formatType);
|
LOGGER.error("Unknown format type {} - no float value can be provided for it.", formatType);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@ -165,7 +165,6 @@ public class BluetoothDeviceSnapshot extends BluetoothDiscoveryDevice {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("PMD.SimplifyBooleanReturns")
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(@Nullable Object obj) {
|
public boolean equals(@Nullable Object obj) {
|
||||||
if (this == obj) {
|
if (this == obj) {
|
||||||
|
|||||||
@ -153,7 +153,9 @@ public class BluetoothDiscoveryService extends AbstractDiscoveryService implemen
|
|||||||
logger.debug("Discovered bluetooth device '{}': {}", device.getName(), device);
|
logger.debug("Discovered bluetooth device '{}': {}", device.getName(), device);
|
||||||
|
|
||||||
DiscoveryCache cache = discoveryCaches.computeIfAbsent(device.getAddress(), addr -> new DiscoveryCache());
|
DiscoveryCache cache = discoveryCaches.computeIfAbsent(device.getAddress(), addr -> new DiscoveryCache());
|
||||||
cache.handleDiscovery(device);
|
if (cache != null) {
|
||||||
|
cache.handleDiscovery(device);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ThingUID createThingUIDWithBridge(DiscoveryResult result, BluetoothAdapter adapter) {
|
private static ThingUID createThingUIDWithBridge(DiscoveryResult result, BluetoothAdapter adapter) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user