diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index 8e0ca2b..8b906b8 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -39,7 +39,7 @@ jobs:
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
- uses: github/codeql-action/init@v1
+ uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -65,4 +65,4 @@ jobs:
run: mvn -B clean package
- name: Perform CodeQL Analysis
- uses: github/codeql-action/analyze@v1
+ uses: github/codeql-action/analyze@v2
diff --git a/pom.xml b/pom.xml
index 512e987..1095d7e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
eBUS core library - This library handles the communication with heating engineering via the BUS specification. This protocol is used by many heating manufacturers in Europe.
de.cs-dev.ebus
ebus-core
- 1.1.9
+ 1.1.10
https://github.com/csowada/ebus
bundle
@@ -17,7 +17,7 @@
1.8
1.8
8
- 2021
+ 2023
${project.version}
csowada_ebus
csowada
@@ -63,7 +63,7 @@
com.amashchenko.maven.plugin
gitflow-maven-plugin
- 1.15.0
+ 1.19.0
master
@@ -102,7 +102,7 @@
org.apache.felix
maven-bundle-plugin
- 3.0.1
+ 3.5.1
true
@@ -336,7 +336,7 @@
com.fazecast
jSerialComm
- 2.7.0
+ 2.9.3
provided
true
diff --git a/src/main/java/de/csdev/ebus/cfg/EBusConfigurationReaderException.java b/src/main/java/de/csdev/ebus/cfg/EBusConfigurationReaderException.java
index 9de8112..01d61f4 100644
--- a/src/main/java/de/csdev/ebus/cfg/EBusConfigurationReaderException.java
+++ b/src/main/java/de/csdev/ebus/cfg/EBusConfigurationReaderException.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2017-2021 by the respective copyright holders.
+ * Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,10 +8,13 @@
*/
package de.csdev.ebus.cfg;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
/**
* @author Christian Sowada - Initial contribution
*
*/
+@NonNullByDefault
public class EBusConfigurationReaderException extends Exception {
private static final long serialVersionUID = 1L;
diff --git a/src/main/java/de/csdev/ebus/cfg/IEBusConfigurationProvider.java b/src/main/java/de/csdev/ebus/cfg/IEBusConfigurationProvider.java
index b23ea6b..0ac4894 100644
--- a/src/main/java/de/csdev/ebus/cfg/IEBusConfigurationProvider.java
+++ b/src/main/java/de/csdev/ebus/cfg/IEBusConfigurationProvider.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2017-2021 by the respective copyright holders.
+ * Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
diff --git a/src/main/java/de/csdev/ebus/cfg/IEBusConfigurationReader.java b/src/main/java/de/csdev/ebus/cfg/IEBusConfigurationReader.java
index dbd6067..ae59baa 100644
--- a/src/main/java/de/csdev/ebus/cfg/IEBusConfigurationReader.java
+++ b/src/main/java/de/csdev/ebus/cfg/IEBusConfigurationReader.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2017-2021 by the respective copyright holders.
+ * Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
diff --git a/src/main/java/de/csdev/ebus/cfg/std/EBusConfigurationReader.java b/src/main/java/de/csdev/ebus/cfg/std/EBusConfigurationReader.java
index 39cecb5..5a84a29 100644
--- a/src/main/java/de/csdev/ebus/cfg/std/EBusConfigurationReader.java
+++ b/src/main/java/de/csdev/ebus/cfg/std/EBusConfigurationReader.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2017-2021 by the respective copyright holders.
+ * Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -358,7 +358,7 @@ protected EBusCommand parseTelegramConfiguration(@NonNull IEBusCommandCollection
* @return
*/
protected @NonNull List<@NonNull EBusValueDTO> checkedList(List master) {
- List templates = new ArrayList<>();
+ List<@NonNull EBusValueDTO> templates = new ArrayList<>();
if (master != null) {
for (EBusValueDTO template : master) {
if (template != null) {
@@ -570,12 +570,16 @@ protected EBusCommand parseTelegramConfiguration(@NonNull IEBusCommandCollection
}
private void overwritePropertiesFromTemplate(@NonNull EBusCommandValue clone, @NonNull EBusValueDTO template) {
+
+ String templateLabel = template.getLabel();
+ String cloneLabel = clone.getLabel();
+
// allow placeholders in template-block mode
- if (StringUtils.isNotEmpty(template.getLabel())) {
- if (StringUtils.isNotEmpty(clone.getLabel()) && clone.getLabel().contains("%s")) {
- clone.setLabel(String.format(clone.getLabel(), template.getLabel()));
+ if (StringUtils.isNotEmpty(templateLabel)) {
+ if (StringUtils.isNotEmpty(cloneLabel) && cloneLabel.contains("%s")) {
+ clone.setLabel(String.format(cloneLabel, templateLabel));
} else {
- clone.setLabel(template.getLabel());
+ clone.setLabel(templateLabel);
}
}
}
diff --git a/src/main/java/de/csdev/ebus/cfg/std/EBusValueJsonDeserializer.java b/src/main/java/de/csdev/ebus/cfg/std/EBusValueJsonDeserializer.java
index a5c20fd..5ae0f04 100644
--- a/src/main/java/de/csdev/ebus/cfg/std/EBusValueJsonDeserializer.java
+++ b/src/main/java/de/csdev/ebus/cfg/std/EBusValueJsonDeserializer.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2017-2021 by the respective copyright holders.
+ * Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
diff --git a/src/main/java/de/csdev/ebus/cfg/std/dto/EBusCollectionDTO.java b/src/main/java/de/csdev/ebus/cfg/std/dto/EBusCollectionDTO.java
index d8a3726..4679a40 100644
--- a/src/main/java/de/csdev/ebus/cfg/std/dto/EBusCollectionDTO.java
+++ b/src/main/java/de/csdev/ebus/cfg/std/dto/EBusCollectionDTO.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2017-2021 by the respective copyright holders.
+ * Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
diff --git a/src/main/java/de/csdev/ebus/cfg/std/dto/EBusCommandDTO.java b/src/main/java/de/csdev/ebus/cfg/std/dto/EBusCommandDTO.java
index 219b2f0..9d9b48e 100644
--- a/src/main/java/de/csdev/ebus/cfg/std/dto/EBusCommandDTO.java
+++ b/src/main/java/de/csdev/ebus/cfg/std/dto/EBusCommandDTO.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2017-2021 by the respective copyright holders.
+ * Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
diff --git a/src/main/java/de/csdev/ebus/cfg/std/dto/EBusCommandMethodDTO.java b/src/main/java/de/csdev/ebus/cfg/std/dto/EBusCommandMethodDTO.java
index 63912a1..5801f7a 100644
--- a/src/main/java/de/csdev/ebus/cfg/std/dto/EBusCommandMethodDTO.java
+++ b/src/main/java/de/csdev/ebus/cfg/std/dto/EBusCommandMethodDTO.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2017-2021 by the respective copyright holders.
+ * Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
diff --git a/src/main/java/de/csdev/ebus/cfg/std/dto/EBusCommandTemplatesDTO.java b/src/main/java/de/csdev/ebus/cfg/std/dto/EBusCommandTemplatesDTO.java
index fbf3dc4..53e4023 100644
--- a/src/main/java/de/csdev/ebus/cfg/std/dto/EBusCommandTemplatesDTO.java
+++ b/src/main/java/de/csdev/ebus/cfg/std/dto/EBusCommandTemplatesDTO.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2017-2021 by the respective copyright holders.
+ * Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
diff --git a/src/main/java/de/csdev/ebus/cfg/std/dto/EBusValueDTO.java b/src/main/java/de/csdev/ebus/cfg/std/dto/EBusValueDTO.java
index 55e7433..ae35f67 100644
--- a/src/main/java/de/csdev/ebus/cfg/std/dto/EBusValueDTO.java
+++ b/src/main/java/de/csdev/ebus/cfg/std/dto/EBusValueDTO.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2017-2021 by the respective copyright holders.
+ * Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
diff --git a/src/main/java/de/csdev/ebus/client/EBusClient.java b/src/main/java/de/csdev/ebus/client/EBusClient.java
index 18f2a7b..9a59ad4 100644
--- a/src/main/java/de/csdev/ebus/client/EBusClient.java
+++ b/src/main/java/de/csdev/ebus/client/EBusClient.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2017-2021 by the respective copyright holders.
+ * Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -91,8 +91,10 @@ public void addEBusDeviceTableListener(final @NonNull IEBusDeviceTableListener l
*/
public void addEBusEventListener(final @NonNull IEBusConnectorEventListener listener) {
Objects.requireNonNull(listener, LABEL_LISTENER);
- if (controller != null) {
- controller.addEBusEventListener(listener);
+ IEBusController ctrl = this.controller;
+
+ if (ctrl != null) {
+ ctrl.addEBusEventListener(listener);
} else {
throw new IllegalStateException("Controller is not initialized!");
}
@@ -120,12 +122,13 @@ public void addEBusParserListener(final @NonNull IEBusParserListener listener) {
public @NonNull Integer addToSendQueue(final byte @NonNull [] buffer) throws EBusControllerException {
Objects.requireNonNull(buffer, "buffer");
+ IEBusController ctrl = this.controller;
- if (controller == null) {
+ if (ctrl == null) {
throw new EBusControllerException("Controller not set!");
}
- return controller.addToSendQueue(buffer);
+ return ctrl.addToSendQueue(buffer);
}
/**
@@ -139,11 +142,13 @@ public void addEBusParserListener(final @NonNull IEBusParserListener listener) {
*/
public @NonNull Integer addToSendQueue(final byte @NonNull [] buffer, final int maxAttemps) throws EBusControllerException {
- if (this.controller == null) {
+ IEBusController ctrl = this.controller;
+
+ if (ctrl == null) {
throw new EBusControllerException("Controller not set!");
}
- return this.controller.addToSendQueue(buffer, maxAttemps);
+ return ctrl.addToSendQueue(buffer, maxAttemps);
}
/**
@@ -179,31 +184,35 @@ public void connect(final @NonNull IEBusController controller, final byte master
controller.addEBusEventListener(resolverService);
deviceTable.setOwnAddress(masterAddress);
- deviceTableService = new EBusDeviceTableService(controller, commandRegistry, deviceTable);
-
+
// add device table service
- resolverService.addEBusParserListener(deviceTableService);
- deviceTable.addEBusDeviceTableListener(deviceTableService);
+ EBusDeviceTableService lDeviceTableService = new EBusDeviceTableService(controller, commandRegistry, deviceTable);
+ resolverService.addEBusParserListener(lDeviceTableService);
+ deviceTable.addEBusDeviceTableListener(lDeviceTableService);
// add metrics service
controller.addEBusEventListener(metricsService);
resolverService.addEBusParserListener(metricsService);
this.controller = controller;
+ this.deviceTableService = lDeviceTableService;
}
/**
* Disposes the eBUS client with all depended services
*/
public void dispose() {
- if (controller != null) {
- controller.interrupt();
- controller = null;
+
+ IEBusController ctrl = this.controller;
+ if (ctrl != null) {
+ ctrl.interrupt();
+ this.controller = null;
}
- if (deviceTableService != null) {
- deviceTableService.dispose();
- deviceTableService = null;
+ EBusDeviceTableService lDeviceTableService = this.deviceTableService;
+ if (lDeviceTableService != null) {
+ lDeviceTableService.dispose();
+ this.deviceTableService = null;
}
if (deviceTable != null) {
@@ -307,9 +316,12 @@ public boolean removeEBusDeviceTableListener(final @NonNull IEBusDeviceTableList
public boolean removeEBusEventListener(final @NonNull IEBusConnectorEventListener listener) {
Objects.requireNonNull(listener);
- if (controller != null) {
- return controller.removeEBusEventListener(listener);
+ IEBusController ctrl = this.controller;
+
+ if (ctrl != null) {
+ return ctrl.removeEBusEventListener(listener);
}
+
return false;
}
diff --git a/src/main/java/de/csdev/ebus/command/EBusCommand.java b/src/main/java/de/csdev/ebus/command/EBusCommand.java
index c76a67a..a0cd367 100644
--- a/src/main/java/de/csdev/ebus/command/EBusCommand.java
+++ b/src/main/java/de/csdev/ebus/command/EBusCommand.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2017-2021 by the respective copyright holders.
+ * Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -28,7 +28,7 @@
@NonNullByDefault
public class EBusCommand implements IEBusCommand {
- private Map channels = new EnumMap<>(IEBusCommandMethod.Method.class);
+ private Map channels = new EnumMap<>(IEBusCommandMethod.Method.class);
private @Nullable String configurationSource;
@@ -48,18 +48,18 @@ public void addCommandChannel(IEBusCommandMethod channel) {
}
@Override
- public @NonNull Collection getCommandChannelMethods() {
+ public Collection getCommandChannelMethods() {
return Objects.requireNonNull(Collections.unmodifiableCollection(channels.keySet()));
}
@Override
- public @Nullable IEBusCommandMethod getCommandMethod(IEBusCommandMethod.@NonNull Method channel) {
+ public @Nullable IEBusCommandMethod getCommandMethod(IEBusCommandMethod.Method channel) {
Objects.requireNonNull(channel);
return CollectionUtils.get(channels, channel);
}
@Override
- public @NonNull Collection<@NonNull IEBusCommandMethod> getCommandMethods() {
+ public @NonNull Collection getCommandMethods() {
return Objects.requireNonNull(Collections.unmodifiableCollection(channels.values()));
}
@@ -89,7 +89,7 @@ public void addCommandChannel(IEBusCommandMethod channel) {
* @see de.csdev.ebus.command.IEBusCommand#getId()
*/
@Override
- public @NonNull String getId() {
+ public String getId() {
return Objects.requireNonNull(id);
}
@@ -109,7 +109,7 @@ public IEBusCommandCollection getParentCollection() {
}
@Override
- public Map<@NonNull String, @NonNull Object> getProperties() {
+ public Map getProperties() {
return Objects.requireNonNull(CollectionUtils.unmodifiableNotNullMap(properties));
}
@@ -138,8 +138,9 @@ public void setParentCollection(IEBusCommandCollection parentCollection) {
public void setProperties(Map properties) {
Objects.requireNonNull(properties, "properties");
- this.properties = new HashMap<>();
- this.properties.putAll(properties);
+ HashMap props = new HashMap<>();
+ props.putAll(properties);
+ this.properties = props;
}
public void setProperty(String key, String value) {
diff --git a/src/main/java/de/csdev/ebus/command/EBusCommandCollection.java b/src/main/java/de/csdev/ebus/command/EBusCommandCollection.java
index 06ea76b..371e543 100644
--- a/src/main/java/de/csdev/ebus/command/EBusCommandCollection.java
+++ b/src/main/java/de/csdev/ebus/command/EBusCommandCollection.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2017-2021 by the respective copyright holders.
+ * Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -29,17 +29,17 @@
@NonNullByDefault
public class EBusCommandCollection implements IEBusCommandCollection {
- private @NonNull Map commands = new HashMap<>();
+ private Map commands = new HashMap<>();
- private @NonNull String description;
+ private String description;
- private @NonNull String id;
+ private String id;
- private @NonNull List identification = new ArrayList<>();
+ private List identification = new ArrayList<>();
- private @NonNull String label;
+ private String label;
- private @NonNull Map properties = new HashMap<>();
+ private Map properties = new HashMap<>();
private byte[] sourceHash;
@@ -54,6 +54,7 @@ public EBusCommandCollection(final String id, final String label, final String d
this.label = label;
this.description = description;
this.properties.putAll(properties);
+ this.sourceHash = new byte[]{};
}
public void addCommand(final IEBusCommand command) {
@@ -133,7 +134,7 @@ public String getLabel() {
* @see de.csdev.ebus.command.IEBusCommandCollection#getProperty(java.lang.String)
*/
@Override
- public Object getProperty(final String key) {
+ public @Nullable Object getProperty(final String key) {
return CollectionUtils.get(properties, key);
}
@@ -155,7 +156,7 @@ public String toString() {
}
@Override
- public IEBusCommand getCommand(final String id) {
+ public @Nullable IEBusCommand getCommand(final String id) {
return commands.get(id);
}
diff --git a/src/main/java/de/csdev/ebus/command/EBusCommandException.java b/src/main/java/de/csdev/ebus/command/EBusCommandException.java
index 4eeb8d0..9c085e7 100644
--- a/src/main/java/de/csdev/ebus/command/EBusCommandException.java
+++ b/src/main/java/de/csdev/ebus/command/EBusCommandException.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2017-2021 by the respective copyright holders.
+ * Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -10,10 +10,13 @@
import java.text.MessageFormat;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
/**
* @author Christian Sowada - Initial contribution
*
*/
+@NonNullByDefault
public class EBusCommandException extends Exception {
private static final long serialVersionUID = 7105215995176921667L;
diff --git a/src/main/java/de/csdev/ebus/command/EBusCommandMethod.java b/src/main/java/de/csdev/ebus/command/EBusCommandMethod.java
index c58daff..2b9117a 100644
--- a/src/main/java/de/csdev/ebus/command/EBusCommandMethod.java
+++ b/src/main/java/de/csdev/ebus/command/EBusCommandMethod.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2017-2021 by the respective copyright holders.
+ * Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -176,8 +176,9 @@ public Byte getSourceAddress() {
@Override
public @NonNull Type getType() {
- if (type != null) {
- return type;
+ Type type0 = this.type;
+ if (type0 != null) {
+ return type0;
}
if (method.equals(Method.BROADCAST)) {
diff --git a/src/main/java/de/csdev/ebus/command/EBusCommandNestedValue.java b/src/main/java/de/csdev/ebus/command/EBusCommandNestedValue.java
index 6f96b91..a32a77c 100644
--- a/src/main/java/de/csdev/ebus/command/EBusCommandNestedValue.java
+++ b/src/main/java/de/csdev/ebus/command/EBusCommandNestedValue.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2017-2021 by the respective copyright holders.
+ * Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
diff --git a/src/main/java/de/csdev/ebus/command/EBusCommandRegistry.java b/src/main/java/de/csdev/ebus/command/EBusCommandRegistry.java
index aae554d..17a2f03 100644
--- a/src/main/java/de/csdev/ebus/command/EBusCommandRegistry.java
+++ b/src/main/java/de/csdev/ebus/command/EBusCommandRegistry.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2017-2021 by the respective copyright holders.
+ * Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -31,6 +31,7 @@
import de.csdev.ebus.command.datatypes.EBusTypeException;
import de.csdev.ebus.command.datatypes.EBusTypeRegistry;
import de.csdev.ebus.core.EBusConsts;
+import de.csdev.ebus.utils.CollectionUtils;
import de.csdev.ebus.utils.EBusUtils;
/**
@@ -67,9 +68,13 @@ public EBusCommandRegistry(Class extends IEBusConfigurationReader> readerClass
try {
this.typeRegistry = new EBusTypeRegistry();
- this.reader = readerClass.getDeclaredConstructor().newInstance();
- reader.setEBusTypes(this.typeRegistry);
-
+ IEBusConfigurationReader lReader = readerClass.getDeclaredConstructor().newInstance();
+ if (lReader == null) {
+ throw new IllegalStateException("Unable to create a new eBUS Configuration Reader instance!");
+ }
+ lReader.setEBusTypes(this.typeRegistry);
+ this.reader = lReader;
+
if (loadBuildInCommands) {
loadBuildInCommandCollections();
}
@@ -140,6 +145,11 @@ public void addCommandCollection(IEBusCommandCollection collection) {
Objects.requireNonNull(data);
ByteBuffer buffer = ByteBuffer.wrap(data);
+
+ if (buffer == null) {
+ return CollectionUtils.emptyList();
+ }
+
return find(buffer);
}
@@ -242,11 +252,12 @@ public EBusTypeRegistry getTypeRegistry() {
* @param data
* @return
*/
+ @SuppressWarnings("java:S3776")
public boolean matchesCommand(@NonNull IEBusCommandMethod command, @NonNull ByteBuffer data) {
- Byte sourceAddress = (Byte) ObjectUtils.defaultIfNull(command.getSourceAddress(), Byte.valueOf((byte) 0x00));
+ Byte sourceAddress = ObjectUtils.defaultIfNull(command.getSourceAddress(), Byte.valueOf((byte) 0x00));
- Byte targetAddress = (Byte) ObjectUtils.defaultIfNull(command.getDestinationAddress(),
+ Byte targetAddress = ObjectUtils.defaultIfNull(command.getDestinationAddress(),
Byte.valueOf((byte) 0x00));
// fast check - is this the right telegram type?
diff --git a/src/main/java/de/csdev/ebus/command/EBusCommandUtils.java b/src/main/java/de/csdev/ebus/command/EBusCommandUtils.java
index aef0307..9585046 100644
--- a/src/main/java/de/csdev/ebus/command/EBusCommandUtils.java
+++ b/src/main/java/de/csdev/ebus/command/EBusCommandUtils.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2017-2021 by the respective copyright holders.
+ * Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -206,7 +206,7 @@ public static byte unescapeSymbol(byte reversedByte) {
for (byte b : masterData) {
// disable escaping the special characters as vaillant and wolf
// generates AA and A9 bytes!
- // buf.put(escapeSymbol(b));
+ // buf.put(escapeSymbol(b))
buf.put(b);
}
@@ -215,7 +215,7 @@ public static byte unescapeSymbol(byte reversedByte) {
// disable escaping the special characters as vaillant and wolf
// generates AA and A9 bytes!
- // buf.put(escapeSymbol(b));
+ // buf.put(escapeSymbol(b))
buf.put(crc8);
// set limit and reset position
@@ -272,6 +272,7 @@ public static byte unescapeSymbol(byte reversedByte) {
* @return
* @throws EBusTypeException
*/
+ @SuppressWarnings("java:S3776")
public static @NonNull ByteBuffer composeMasterData(@NonNull IEBusCommandMethod commandMethod,
@Nullable Map values) throws EBusTypeException {
@@ -376,6 +377,7 @@ public static byte unescapeSymbol(byte reversedByte) {
* @throws EBusTypeException
* @throws EBusCommandException
*/
+ @SuppressWarnings("java:S3776")
public static @NonNull ByteBuffer buildMasterTelegram(@NonNull IEBusCommandMethod commandMethod,
@Nullable Byte source, @Nullable Byte target, @Nullable Map values,
boolean skipAddressChecks) throws EBusTypeException, EBusCommandException {
@@ -489,6 +491,7 @@ public static byte unescapeSymbol(byte reversedByte) {
* @return
* @throws EBusTypeException
*/
+ @SuppressWarnings("java:S3776")
private static int decodeValueList(@Nullable List<@NonNull IEBusValue> values, byte @NonNull [] data,
@NonNull HashMap result, int pos) throws EBusTypeException {
@@ -567,6 +570,7 @@ private static int decodeValueList(@Nullable List<@NonNull IEBusValue> values, b
* @param commandChannel
* @return
*/
+ @SuppressWarnings("java:S3776")
public static @NonNull ByteBuffer getMasterTelegramMask(@NonNull IEBusCommandMethod commandChannel) {
Objects.requireNonNull(commandChannel, "Parameter command is null!");
diff --git a/src/main/java/de/csdev/ebus/command/EBusCommandValue.java b/src/main/java/de/csdev/ebus/command/EBusCommandValue.java
index 7691646..ee61d0f 100644
--- a/src/main/java/de/csdev/ebus/command/EBusCommandValue.java
+++ b/src/main/java/de/csdev/ebus/command/EBusCommandValue.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2017-2021 by the respective copyright holders.
+ * Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -34,21 +34,21 @@ public static EBusCommandValue getInstance(IEBusType> type, byte[] data) {
return value;
}
- private Object defaultValue;
+ private @Nullable Object defaultValue;
- private BigDecimal factor;
+ private @Nullable BigDecimal factor;
- private String format;
+ private @Nullable String format;
- private String label;
+ private @Nullable String label;
- private Map mapping;
+ private @Nullable Map mapping;
- private BigDecimal max;
+ private @Nullable BigDecimal max;
- private BigDecimal min;
+ private @Nullable BigDecimal min;
- private String name;
+ private @Nullable String name;
private EBusCommandMethod parent;
@@ -94,58 +94,58 @@ protected EBusCommandValue createInstance() {
}
@Override
- public Object getDefaultValue() {
- return defaultValue;
+ public @Nullable Object getDefaultValue() {
+ return this.defaultValue;
}
@Override
- public BigDecimal getFactor() {
- return factor;
+ public @Nullable BigDecimal getFactor() {
+ return this.factor;
}
@Override
- public String getFormat() {
- return format;
+ public @Nullable String getFormat() {
+ return this.format;
}
@Override
- public String getLabel() {
- return label;
+ public @Nullable String getLabel() {
+ return this.label;
}
@Override
- public Map getMapping() {
- return mapping;
+ public @Nullable Map<@NonNull String, @NonNull String> getMapping() {
+ return this.mapping;
}
@Override
- public BigDecimal getMax() {
- return max;
+ public @Nullable BigDecimal getMax() {
+ return this.max;
}
@Override
- public BigDecimal getMin() {
- return min;
+ public @Nullable BigDecimal getMin() {
+ return this.min;
}
@Override
public @Nullable String getName() {
- return name;
+ return this.name;
}
@Override
public @Nullable IEBusCommandMethod getParent() {
- return parent;
+ return this.parent;
}
@Override
- public Map getProperties() {
- return CollectionUtils.unmodifiableNotNullMap(properties);
+ public @Nullable Map<@NonNull String, @NonNull Object> getProperties() {
+ return CollectionUtils.unmodifiableNotNullMap(this.properties);
}
@Override
- public BigDecimal getStep() {
- return step;
+ public @Nullable BigDecimal getStep() {
+ return this.step;
}
@Override
@@ -153,35 +153,35 @@ public BigDecimal getStep() {
return Objects.requireNonNull(type);
}
- public void setDefaultValue(Object defaultValue) {
+ public void setDefaultValue(@Nullable Object defaultValue) {
this.defaultValue = defaultValue;
}
- public void setFactor(BigDecimal factor) {
+ public void setFactor(@Nullable BigDecimal factor) {
this.factor = factor;
}
- public void setFormat(String format) {
+ public void setFormat(@Nullable String format) {
this.format = format;
}
- public void setLabel(String label) {
+ public void setLabel(@Nullable String label) {
this.label = label;
}
- public void setMapping(Map mapping) {
+ public void setMapping(@Nullable Map mapping) {
this.mapping = mapping;
}
- public void setMax(BigDecimal max) {
+ public void setMax(@Nullable BigDecimal max) {
this.max = max;
}
- public void setMin(BigDecimal min) {
+ public void setMin(@Nullable BigDecimal min) {
this.min = min;
}
- public void setName(String name) {
+ public void setName(@Nullable String name) {
this.name = name;
}
@@ -195,15 +195,15 @@ public void setProperties(Map properties) {
}
public void setProperty(String key, String value) {
- properties = CollectionUtils.newMapIfNull(properties);
- properties.put(key, value);
+ this.properties = CollectionUtils.newMapIfNull(properties);
+ this.properties.put(key, value);
}
- public void setStep(BigDecimal step) {
+ public void setStep(@Nullable BigDecimal step) {
this.step = step;
}
- public void setType(IEBusType> type) {
+ public void setType(@Nullable IEBusType> type) {
this.type = type;
}
diff --git a/src/main/java/de/csdev/ebus/command/IEBusCommand.java b/src/main/java/de/csdev/ebus/command/IEBusCommand.java
index 2eff688..f483194 100644
--- a/src/main/java/de/csdev/ebus/command/IEBusCommand.java
+++ b/src/main/java/de/csdev/ebus/command/IEBusCommand.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2017-2021 by the respective copyright holders.
+ * Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -11,7 +11,7 @@
import java.util.Collection;
import java.util.Map;
-import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
/**
@@ -20,6 +20,7 @@
* @author Christian Sowada - Initial contribution
*
*/
+@NonNullByDefault
public interface IEBusCommand {
/**
@@ -27,7 +28,7 @@ public interface IEBusCommand {
*
* @return
*/
- public @NonNull Collection<@NonNull IEBusCommandMethod> getCommandMethods();
+ public Collection getCommandMethods();
/**
* Returns the command method if available. Returns null
if not availble.
@@ -35,14 +36,14 @@ public interface IEBusCommand {
* @param method
* @return
*/
- public @Nullable IEBusCommandMethod getCommandMethod(final IEBusCommandMethod.@NonNull Method method);
+ public @Nullable IEBusCommandMethod getCommandMethod(final IEBusCommandMethod.Method method);
/**
* Returns the available command method enums.
*
* @return
*/
- public @NonNull Collection getCommandChannelMethods();
+ public Collection getCommandChannelMethods();
/**
* Returns device information from database
@@ -70,19 +71,19 @@ public interface IEBusCommand {
*
* @return
*/
- public @NonNull String getId();
+ public String getId();
/**
* Returns a map of additional properties
*
* @return
*/
- public @NonNull Map<@NonNull String, @NonNull Object> getProperties();
+ public Map getProperties();
/**
* Returns the parent collection
*
* @return
*/
- public @NonNull IEBusCommandCollection getParentCollection();
+ public IEBusCommandCollection getParentCollection();
}
diff --git a/src/main/java/de/csdev/ebus/command/IEBusCommandCollection.java b/src/main/java/de/csdev/ebus/command/IEBusCommandCollection.java
index cdb48c2..2ced40b 100644
--- a/src/main/java/de/csdev/ebus/command/IEBusCommandCollection.java
+++ b/src/main/java/de/csdev/ebus/command/IEBusCommandCollection.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2017-2021 by the respective copyright holders.
+ * Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -12,7 +12,7 @@
import java.util.List;
import java.util.Map;
-import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
/**
@@ -21,6 +21,7 @@
* @author Christian Sowada - Initial contribution
*
*/
+@NonNullByDefault
public interface IEBusCommandCollection {
/**
@@ -28,7 +29,7 @@ public interface IEBusCommandCollection {
*
* @return
*/
- public @NonNull List getIdentification();
+ public List getIdentification();
/**
* Returns the long description
@@ -42,7 +43,7 @@ public interface IEBusCommandCollection {
*
* @return
*/
- public @NonNull String getId();
+ public String getId();
/**
* Returns the label of this collection
@@ -56,7 +57,7 @@ public interface IEBusCommandCollection {
*
* @return
*/
- public @NonNull Collection getCommands();
+ public Collection getCommands();
/**
* Returns the requested command or null
@@ -71,7 +72,7 @@ public interface IEBusCommandCollection {
*
* @return
*/
- public @NonNull Map getProperties();
+ public Map getProperties();
/**
* Returns a property value or null
diff --git a/src/main/java/de/csdev/ebus/command/IEBusCommandMethod.java b/src/main/java/de/csdev/ebus/command/IEBusCommandMethod.java
index 6c2ca11..705ec1a 100644
--- a/src/main/java/de/csdev/ebus/command/IEBusCommandMethod.java
+++ b/src/main/java/de/csdev/ebus/command/IEBusCommandMethod.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2017-2021 by the respective copyright holders.
+ * Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -11,13 +11,14 @@
import java.nio.ByteBuffer;
import java.util.List;
-import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
/**
* @author Christian Sowada - Initial contribution
*
*/
+@NonNullByDefault
public interface IEBusCommandMethod {
/**
@@ -56,21 +57,21 @@ public enum Method {
*
* @return
*/
- public IEBusCommandMethod.@NonNull Type getType();
+ public IEBusCommandMethod.Type getType();
/**
* Returns the parent command
*
* @return
*/
- public @NonNull IEBusCommand getParent();
+ public IEBusCommand getParent();
/**
* Returns the type of this command
*
* @return
*/
- public IEBusCommandMethod.@NonNull Method getMethod();
+ public IEBusCommandMethod.Method getMethod();
/**
* Returns defined destination address or null if not defined
@@ -91,27 +92,27 @@ public enum Method {
*
* @return
*/
- public @NonNull ByteBuffer getMasterTelegramMask();
+ public ByteBuffer getMasterTelegramMask();
/**
* Get ordered list of eBus data types for the master part
*
* @return
*/
- public @Nullable List<@NonNull IEBusValue> getMasterTypes();
+ public @Nullable List getMasterTypes();
/**
* Get ordered list of eBus data types for the slave part
*
* @return
*/
- public @Nullable List<@NonNull IEBusValue> getSlaveTypes();
+ public @Nullable List getSlaveTypes();
/**
* Returns the eBus command bytes
*
* @return
*/
- public byte @NonNull [] getCommand();
+ public byte[] getCommand();
}
diff --git a/src/main/java/de/csdev/ebus/command/IEBusNestedValue.java b/src/main/java/de/csdev/ebus/command/IEBusNestedValue.java
index 50009fd..1c43263 100644
--- a/src/main/java/de/csdev/ebus/command/IEBusNestedValue.java
+++ b/src/main/java/de/csdev/ebus/command/IEBusNestedValue.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2017-2021 by the respective copyright holders.
+ * Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -10,7 +10,7 @@
import java.util.List;
-import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.NonNullByDefault;
/**
* A marker of a value with child values
@@ -18,6 +18,7 @@
* @author Christian Sowada - Initial contribution
*
*/
+@NonNullByDefault
public interface IEBusNestedValue {
/**
@@ -32,6 +33,6 @@ public interface IEBusNestedValue {
*
* @return
*/
- public @NonNull List<@NonNull IEBusValue> getChildren();
+ public List getChildren();
}
diff --git a/src/main/java/de/csdev/ebus/command/IEBusValue.java b/src/main/java/de/csdev/ebus/command/IEBusValue.java
index 6c450a9..0041b58 100644
--- a/src/main/java/de/csdev/ebus/command/IEBusValue.java
+++ b/src/main/java/de/csdev/ebus/command/IEBusValue.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2017-2021 by the respective copyright holders.
+ * Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -12,6 +12,7 @@
import java.util.Map;
import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import de.csdev.ebus.command.datatypes.IEBusType;
@@ -22,6 +23,8 @@
* @author Christian Sowada - Initial contribution
*
*/
+
+@NonNullByDefault
public interface IEBusValue extends Cloneable {
/**
@@ -29,8 +32,7 @@ public interface IEBusValue extends Cloneable {
*
* @return
*/
-
- public @NonNull IEBusType> getType();
+ public IEBusType> getType();
/**
* Returns the default value if set, can be null
diff --git a/src/main/java/de/csdev/ebus/command/datatypes/EBusAbstractType.java b/src/main/java/de/csdev/ebus/command/datatypes/EBusAbstractType.java
index fa292ab..0721fff 100644
--- a/src/main/java/de/csdev/ebus/command/datatypes/EBusAbstractType.java
+++ b/src/main/java/de/csdev/ebus/command/datatypes/EBusAbstractType.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2017-2021 by the respective copyright holders.
+ * Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -19,6 +19,7 @@
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.reflect.FieldUtils;
+import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,16 +31,19 @@
* @author Christian Sowada - Initial contribution
*
*/
+@NonNullByDefault
public abstract class EBusAbstractType implements IEBusType {
- private static final Logger logger = LoggerFactory.getLogger(EBusAbstractType.class);
+ @SuppressWarnings({"null"})
+ private static final Logger logger = LoggerFactory.getLogger(EBusAbstractType.class);
- protected Map