Remove Map null annotation workarounds (#8916)
These workarounds to prevent false positives can be removed now the EEAs allow for proper null analysis. Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
@@ -17,7 +17,6 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.core.thing.ThingTypeUID;
|
||||
|
||||
/**
|
||||
@@ -82,7 +81,7 @@ public class PLCLogoBindingConstants {
|
||||
public static final String NI_ANALOG = "NAI"; // Network analog input
|
||||
public static final String NQ_ANALOG = "NAQ"; // Network analog output
|
||||
|
||||
private static final Map<Integer, @Nullable String> LOGO_STATES_0BA7;
|
||||
private static final Map<Integer, String> LOGO_STATES_0BA7;
|
||||
static {
|
||||
Map<Integer, String> buffer = new HashMap<>();
|
||||
// buffer.put(???, "Network access error"); // Netzwerkzugriffsfehler
|
||||
@@ -92,7 +91,7 @@ public class PLCLogoBindingConstants {
|
||||
LOGO_STATES_0BA7 = Collections.unmodifiableMap(buffer);
|
||||
}
|
||||
|
||||
private static final Map<Integer, @Nullable String> LOGO_STATES_0BA8;
|
||||
private static final Map<Integer, String> LOGO_STATES_0BA8;
|
||||
static {
|
||||
Map<Integer, String> buffer = new HashMap<>();
|
||||
buffer.put(1, "Ethernet link error"); // Netzwerk Verbindungsfehler
|
||||
@@ -104,9 +103,9 @@ public class PLCLogoBindingConstants {
|
||||
LOGO_STATES_0BA8 = Collections.unmodifiableMap(buffer);
|
||||
}
|
||||
|
||||
public static final Map<String, @Nullable Map<Integer, @Nullable String>> LOGO_STATES;
|
||||
public static final Map<String, Map<Integer, String>> LOGO_STATES;
|
||||
static {
|
||||
Map<String, @Nullable Map<Integer, @Nullable String>> buffer = new HashMap<>();
|
||||
Map<String, Map<Integer, String>> buffer = new HashMap<>();
|
||||
buffer.put(LOGO_0BA7, LOGO_STATES_0BA7);
|
||||
buffer.put(LOGO_0BA8, LOGO_STATES_0BA8);
|
||||
LOGO_STATES = Collections.unmodifiableMap(buffer);
|
||||
@@ -122,18 +121,18 @@ public class PLCLogoBindingConstants {
|
||||
}
|
||||
}
|
||||
|
||||
public static final Map<String, @Nullable Layout> LOGO_CHANNELS;
|
||||
public static final Map<String, Layout> LOGO_CHANNELS;
|
||||
static {
|
||||
Map<String, @Nullable Layout> buffer = new HashMap<>();
|
||||
Map<String, Layout> buffer = new HashMap<>();
|
||||
buffer.put(DAIGNOSTICS_CHANNEL, new Layout(984, 1)); // Diagnostics starts at 984 for 1 byte
|
||||
buffer.put(RTC_CHANNEL, new Layout(985, 6)); // RTC starts at 985 for 6 bytes: year month day hour minute second
|
||||
buffer.put(DAY_OF_WEEK_CHANNEL, new Layout(998, 1)); // Diagnostics starts at 998 for 1 byte
|
||||
LOGO_CHANNELS = Collections.unmodifiableMap(buffer);
|
||||
}
|
||||
|
||||
public static final Map<Integer, @Nullable String> DAY_OF_WEEK;
|
||||
public static final Map<Integer, String> DAY_OF_WEEK;
|
||||
static {
|
||||
Map<Integer, @Nullable String> buffer = new HashMap<>();
|
||||
Map<Integer, String> buffer = new HashMap<>();
|
||||
buffer.put(1, "SUNDAY");
|
||||
buffer.put(2, "MONDAY");
|
||||
buffer.put(3, "TUEsDAY");
|
||||
@@ -144,9 +143,9 @@ public class PLCLogoBindingConstants {
|
||||
DAY_OF_WEEK = Collections.unmodifiableMap(buffer);
|
||||
}
|
||||
|
||||
private static final Map<String, @Nullable Layout> LOGO_MEMORY_0BA7;
|
||||
private static final Map<String, Layout> LOGO_MEMORY_0BA7;
|
||||
static {
|
||||
Map<String, @Nullable Layout> buffer = new HashMap<>();
|
||||
Map<String, Layout> buffer = new HashMap<>();
|
||||
buffer.put(MEMORY_BYTE, new Layout(0, 850));
|
||||
buffer.put(MEMORY_DWORD, new Layout(0, 850));
|
||||
buffer.put(MEMORY_WORD, new Layout(0, 850));
|
||||
@@ -160,9 +159,9 @@ public class PLCLogoBindingConstants {
|
||||
LOGO_MEMORY_0BA7 = Collections.unmodifiableMap(buffer);
|
||||
}
|
||||
|
||||
private static final Map<String, @Nullable Layout> LOGO_MEMORY_0BA8;
|
||||
private static final Map<String, Layout> LOGO_MEMORY_0BA8;
|
||||
static {
|
||||
Map<String, @Nullable Layout> buffer = new HashMap<>();
|
||||
Map<String, Layout> buffer = new HashMap<>();
|
||||
buffer.put(MEMORY_BYTE, new Layout(0, 850));
|
||||
buffer.put(MEMORY_DWORD, new Layout(0, 850));
|
||||
buffer.put(MEMORY_WORD, new Layout(0, 850));
|
||||
@@ -180,9 +179,9 @@ public class PLCLogoBindingConstants {
|
||||
LOGO_MEMORY_0BA8 = Collections.unmodifiableMap(buffer);
|
||||
}
|
||||
|
||||
public static final Map<String, @Nullable Map<String, @Nullable Layout>> LOGO_MEMORY_BLOCK;
|
||||
public static final Map<String, Map<String, Layout>> LOGO_MEMORY_BLOCK;
|
||||
static {
|
||||
Map<String, @Nullable Map<String, @Nullable Layout>> buffer = new HashMap<>();
|
||||
Map<String, Map<String, Layout>> buffer = new HashMap<>();
|
||||
buffer.put(LOGO_0BA7, LOGO_MEMORY_0BA7);
|
||||
buffer.put(LOGO_0BA8, LOGO_MEMORY_0BA8);
|
||||
LOGO_MEMORY_BLOCK = Collections.unmodifiableMap(buffer);
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.plclogo.internal.PLCLogoClient;
|
||||
import org.openhab.binding.plclogo.internal.config.PLCAnalogConfiguration;
|
||||
import org.openhab.core.config.core.Configuration;
|
||||
@@ -59,18 +58,18 @@ public class PLCAnalogHandler extends PLCCommonHandler {
|
||||
private final Logger logger = LoggerFactory.getLogger(PLCAnalogHandler.class);
|
||||
private AtomicReference<PLCAnalogConfiguration> config = new AtomicReference<>();
|
||||
|
||||
private static final Map<String, @Nullable Integer> LOGO_BLOCKS_0BA7;
|
||||
private static final Map<String, Integer> LOGO_BLOCKS_0BA7;
|
||||
static {
|
||||
Map<String, @Nullable Integer> buffer = new HashMap<>();
|
||||
Map<String, Integer> buffer = new HashMap<>();
|
||||
buffer.put(I_ANALOG, 8); // 8 analog inputs
|
||||
buffer.put(Q_ANALOG, 2); // 2 analog outputs
|
||||
buffer.put(M_ANALOG, 16); // 16 analog markers
|
||||
LOGO_BLOCKS_0BA7 = Collections.unmodifiableMap(buffer);
|
||||
}
|
||||
|
||||
private static final Map<String, @Nullable Integer> LOGO_BLOCKS_0BA8;
|
||||
private static final Map<String, Integer> LOGO_BLOCKS_0BA8;
|
||||
static {
|
||||
Map<String, @Nullable Integer> buffer = new HashMap<>();
|
||||
Map<String, Integer> buffer = new HashMap<>();
|
||||
buffer.put(I_ANALOG, 8); // 8 analog inputs
|
||||
buffer.put(Q_ANALOG, 8); // 8 analog outputs
|
||||
buffer.put(M_ANALOG, 64); // 64 analog markers
|
||||
@@ -79,9 +78,9 @@ public class PLCAnalogHandler extends PLCCommonHandler {
|
||||
LOGO_BLOCKS_0BA8 = Collections.unmodifiableMap(buffer);
|
||||
}
|
||||
|
||||
private static final Map<String, @Nullable Map<String, @Nullable Integer>> LOGO_BLOCK_NUMBER;
|
||||
private static final Map<String, Map<String, Integer>> LOGO_BLOCK_NUMBER;
|
||||
static {
|
||||
Map<String, @Nullable Map<String, @Nullable Integer>> buffer = new HashMap<>();
|
||||
Map<String, Map<String, Integer>> buffer = new HashMap<>();
|
||||
buffer.put(LOGO_0BA7, LOGO_BLOCKS_0BA7);
|
||||
buffer.put(LOGO_0BA8, LOGO_BLOCKS_0BA8);
|
||||
LOGO_BLOCK_NUMBER = Collections.unmodifiableMap(buffer);
|
||||
@@ -217,7 +216,7 @@ public class PLCAnalogHandler extends PLCCommonHandler {
|
||||
String family = getLogoFamily();
|
||||
logger.debug("Get block number of {} LOGO! for {} blocks.", family, kind);
|
||||
|
||||
Map<?, @Nullable Integer> blocks = LOGO_BLOCK_NUMBER.get(family);
|
||||
Map<?, Integer> blocks = LOGO_BLOCK_NUMBER.get(family);
|
||||
Integer number = (blocks != null) ? blocks.get(kind) : null;
|
||||
return (number != null) ? number.intValue() : 0;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class PLCBridgeHandler extends BaseBridgeHandler {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(PLCBridgeHandler.class);
|
||||
|
||||
private Map<ChannelUID, @Nullable String> oldValues = new HashMap<>();
|
||||
private Map<ChannelUID, String> oldValues = new HashMap<>();
|
||||
|
||||
@Nullable
|
||||
private volatile PLCLogoClient client; // S7 client used for communication with Logo!
|
||||
@@ -94,7 +94,7 @@ public class PLCBridgeHandler extends BaseBridgeHandler {
|
||||
@Override
|
||||
public void run() {
|
||||
PLCLogoClient localClient = client;
|
||||
Map<?, @Nullable Layout> memory = LOGO_MEMORY_BLOCK.get(getLogoFamily());
|
||||
Map<?, Layout> memory = LOGO_MEMORY_BLOCK.get(getLogoFamily());
|
||||
Layout layout = (memory != null) ? memory.get(MEMORY_SIZE) : null;
|
||||
if ((layout != null) && (localClient != null)) {
|
||||
try {
|
||||
@@ -172,7 +172,7 @@ public class PLCBridgeHandler extends BaseBridgeHandler {
|
||||
rtc.set(clock);
|
||||
updateState(channelUID, new DateTimeType(clock));
|
||||
} else if (DAIGNOSTICS_CHANNEL.equals(channelId)) {
|
||||
Map<Integer, @Nullable String> states = LOGO_STATES.get(getLogoFamily());
|
||||
Map<Integer, String> states = LOGO_STATES.get(getLogoFamily());
|
||||
if (states != null) {
|
||||
for (Integer key : states.keySet()) {
|
||||
String message = states.get(buffer[0] & key.intValue());
|
||||
|
||||
@@ -96,7 +96,7 @@ public abstract class PLCCommonHandler extends BaseThingHandler {
|
||||
String family = getLogoFamily();
|
||||
logger.debug("Get start address of {} LOGO! for {} blocks.", family, kind);
|
||||
|
||||
Map<?, @Nullable Layout> memory = LOGO_MEMORY_BLOCK.get(family);
|
||||
Map<?, Layout> memory = LOGO_MEMORY_BLOCK.get(family);
|
||||
Layout layout = (memory != null) ? memory.get(kind) : null;
|
||||
return layout != null ? layout.address : INVALID;
|
||||
}
|
||||
@@ -111,7 +111,7 @@ public abstract class PLCCommonHandler extends BaseThingHandler {
|
||||
String family = getLogoFamily();
|
||||
logger.debug("Get data buffer length of {} LOGO! for {} blocks.", family, kind);
|
||||
|
||||
Map<?, @Nullable Layout> memory = LOGO_MEMORY_BLOCK.get(family);
|
||||
Map<?, Layout> memory = LOGO_MEMORY_BLOCK.get(family);
|
||||
Layout layout = (memory != null) ? memory.get(kind) : null;
|
||||
return layout != null ? layout.length : 0;
|
||||
}
|
||||
@@ -186,7 +186,7 @@ public abstract class PLCCommonHandler extends BaseThingHandler {
|
||||
logger.debug("Get base address of {} LOGO! for block {} .", family, name);
|
||||
|
||||
String block = name.split("\\.")[0];
|
||||
Map<?, @Nullable Layout> memory = LOGO_MEMORY_BLOCK.get(family);
|
||||
Map<?, Layout> memory = LOGO_MEMORY_BLOCK.get(family);
|
||||
if (isValid(name) && !block.isEmpty() && (memory != null)) {
|
||||
if (Character.isDigit(block.charAt(1))) {
|
||||
layout = memory.get(block.substring(0, 1));
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.plclogo.internal.PLCLogoClient;
|
||||
import org.openhab.binding.plclogo.internal.config.PLCDigitalConfiguration;
|
||||
import org.openhab.core.config.core.Configuration;
|
||||
@@ -61,18 +60,18 @@ public class PLCDigitalHandler extends PLCCommonHandler {
|
||||
private final Logger logger = LoggerFactory.getLogger(PLCDigitalHandler.class);
|
||||
private AtomicReference<PLCDigitalConfiguration> config = new AtomicReference<>();
|
||||
|
||||
private static final Map<String, @Nullable Integer> LOGO_BLOCKS_0BA7;
|
||||
private static final Map<String, Integer> LOGO_BLOCKS_0BA7;
|
||||
static {
|
||||
Map<String, @Nullable Integer> buffer = new HashMap<>();
|
||||
Map<String, Integer> buffer = new HashMap<>();
|
||||
buffer.put(I_DIGITAL, 24); // 24 digital inputs
|
||||
buffer.put(Q_DIGITAL, 16); // 16 digital outputs
|
||||
buffer.put(M_DIGITAL, 27); // 27 digital markers
|
||||
LOGO_BLOCKS_0BA7 = Collections.unmodifiableMap(buffer);
|
||||
}
|
||||
|
||||
private static final Map<String, @Nullable Integer> LOGO_BLOCKS_0BA8;
|
||||
private static final Map<String, Integer> LOGO_BLOCKS_0BA8;
|
||||
static {
|
||||
Map<String, @Nullable Integer> buffer = new HashMap<>();
|
||||
Map<String, Integer> buffer = new HashMap<>();
|
||||
buffer.put(I_DIGITAL, 24); // 24 digital inputs
|
||||
buffer.put(Q_DIGITAL, 20); // 20 digital outputs
|
||||
buffer.put(M_DIGITAL, 64); // 64 digital markers
|
||||
@@ -81,9 +80,9 @@ public class PLCDigitalHandler extends PLCCommonHandler {
|
||||
LOGO_BLOCKS_0BA8 = Collections.unmodifiableMap(buffer);
|
||||
}
|
||||
|
||||
private static final Map<String, @Nullable Map<String, @Nullable Integer>> LOGO_BLOCK_NUMBER;
|
||||
private static final Map<String, Map<String, Integer>> LOGO_BLOCK_NUMBER;
|
||||
static {
|
||||
Map<String, @Nullable Map<String, @Nullable Integer>> buffer = new HashMap<>();
|
||||
Map<String, Map<String, Integer>> buffer = new HashMap<>();
|
||||
buffer.put(LOGO_0BA7, LOGO_BLOCKS_0BA7);
|
||||
buffer.put(LOGO_0BA8, LOGO_BLOCKS_0BA8);
|
||||
LOGO_BLOCK_NUMBER = Collections.unmodifiableMap(buffer);
|
||||
@@ -227,7 +226,7 @@ public class PLCDigitalHandler extends PLCCommonHandler {
|
||||
String family = getLogoFamily();
|
||||
logger.debug("Get block number of {} LOGO! for {} blocks.", family, kind);
|
||||
|
||||
Map<?, @Nullable Integer> blocks = LOGO_BLOCK_NUMBER.get(family);
|
||||
Map<?, Integer> blocks = LOGO_BLOCK_NUMBER.get(family);
|
||||
Integer number = (blocks != null) ? blocks.get(kind) : null;
|
||||
return (number != null) ? number.intValue() : 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user