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 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> otherInstances = new HashMap<>(); + protected Map> otherInstances = new HashMap<>(); - protected byte[] replaceValue = null; + protected byte @Nullable [] replaceValue = null; protected boolean reverseByteOrder = false; + @SuppressWarnings({"null"}) protected EBusTypeRegistry types; /** @@ -48,8 +52,9 @@ public abstract class EBusAbstractType implements IEBusType { * @param data * @return */ - protected byte[] applyByteOrder(byte[] data) { + protected byte @Nullable [] applyByteOrder(byte @Nullable [] data) { + // @SuppressWarnings({}) data = ArrayUtils.clone(data); // reverse the byte order immutable @@ -65,13 +70,16 @@ protected byte[] applyByteOrder(byte[] data) { * * @return */ - private EBusAbstractType createNewInstance() { + private @Nullable EBusAbstractType createNewInstance() { try { - @SuppressWarnings({ "unchecked"}) + @SuppressWarnings({ "unchecked" }) EBusAbstractType newInstance = this.getClass().getDeclaredConstructor().newInstance(); - newInstance.types = this.types; - return newInstance; + if (newInstance != null) { + newInstance.setTypesParent(types); + return newInstance; + } + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { logger.error(EBusConsts.LOG_ERR_DEF, e); @@ -150,7 +158,7 @@ public byte[] encode(@Nullable Object data) throws EBusTypeException { * @return * @throws EBusTypeException */ - public byte[] encodeInt(@Nullable Object data) throws EBusTypeException { + public byte @Nullable [] encodeInt(@Nullable Object data) throws EBusTypeException { throw new UnsupportedOperationException("Must be overwritten by superclass!"); } @@ -160,8 +168,8 @@ public byte[] encodeInt(@Nullable Object data) throws EBusTypeException { * @param data * @return */ - protected boolean equalsReplaceValue(byte[] data) { - return ArrayUtils.isEquals(data, getReplaceValue()); + protected boolean equalsReplaceValue(byte @Nullable [] data) { + return Objects.deepEquals(data, getReplaceValue()); } /* @@ -170,7 +178,7 @@ protected boolean equalsReplaceValue(byte[] data) { * @see de.csdev.ebus.command.datatypes.IEBusType#getInstance(java.util.Map) */ @Override - public IEBusType getInstance(@Nullable Map properties) { + public @Nullable IEBusType getInstance(@Nullable Map properties) { // use default instance if no properties are set if (properties == null || properties.isEmpty()) { @@ -204,15 +212,17 @@ public IEBusType getInstance(@Nullable Map properties) { * * @return */ - public byte[] getReplaceValue() { + public byte @Nullable [] getReplaceValue() { int length = getTypeLength(); - if (replaceValue == null || replaceValue.length == 0) { - replaceValue = new byte[length]; - Arrays.fill(replaceValue, (byte) 0xFF); + byte[] repValue = this.replaceValue; + if (repValue == null || repValue.length == 0) { + repValue = new byte[length]; + Arrays.fill(repValue, (byte) 0xFF); + this.replaceValue = repValue; } - return replaceValue; + return repValue; } /* @@ -268,6 +278,7 @@ protected void setInstanceProperty(@Nullable EBusAbstractType instance, @Null * @param replaceValue * @throws EBusTypeException */ + @SuppressWarnings("java:S1130") public void setReplaceValue(byte[] replaceValue) throws EBusTypeException { this.replaceValue = applyByteOrder(replaceValue); } diff --git a/src/main/java/de/csdev/ebus/command/datatypes/EBusTypeException.java b/src/main/java/de/csdev/ebus/command/datatypes/EBusTypeException.java index 38f719a..5dde879 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/EBusTypeException.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/EBusTypeException.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/datatypes/EBusTypeRegistry.java b/src/main/java/de/csdev/ebus/command/datatypes/EBusTypeRegistry.java index 6b63e50..7415969 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/EBusTypeRegistry.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/EBusTypeRegistry.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 @@ -64,7 +64,7 @@ public EBusTypeRegistry() throws EBusTypeException { * @throws EBusTypeException */ protected void init() throws EBusTypeException { - types = new HashMap>(); + types = new HashMap<>(); // primary types add(EBusTypeBit.class); @@ -102,7 +102,7 @@ protected void init() throws EBusTypeException { * @param properties * @return */ - public IEBusType getType(String type, Map properties) { + public @Nullable IEBusType getType(String type, Map properties) { IEBusType ebusType = getType(type); if (ebusType != null) { @@ -117,7 +117,7 @@ public IEBusType getType(String type, Map properties) { * @param propertiesArguments * @return */ - public IEBusType getType(String type, Object... propertiesArguments) { + public @Nullable IEBusType getType(String type, Object... propertiesArguments) { Map properties = CollectionUtils.createProperties(propertiesArguments); return this.getType(type, properties); } @@ -128,7 +128,7 @@ public IEBusType getType(String type, Object... propertiesArguments) { * @param type * @return */ - public IEBusType getType(String type) { + public @Nullable IEBusType getType(String type) { @SuppressWarnings("unchecked") IEBusType eBusType = (IEBusType) types.get(type); @@ -157,7 +157,7 @@ public Set getTypesNames() { * @return * @throws EBusTypeException */ - public byte[] encode(String type, Object data) throws EBusTypeException { + public byte @Nullable [] encode(String type, Object data) throws EBusTypeException { IEBusType eBusType = types.get(type); diff --git a/src/main/java/de/csdev/ebus/command/datatypes/IEBusComplexType.java b/src/main/java/de/csdev/ebus/command/datatypes/IEBusComplexType.java index fb7cedd..d9309c1 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/IEBusComplexType.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/IEBusComplexType.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,14 @@ */ package de.csdev.ebus.command.datatypes; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; + /** * @author Christian Sowada - Initial contribution * */ +@NonNullByDefault public interface IEBusComplexType { /** @@ -22,7 +26,7 @@ public interface IEBusComplexType { * @return * @throws EBusTypeException */ - public T decodeComplex(byte[] rawData, int pos) throws EBusTypeException; + public @Nullable T decodeComplex(byte[] rawData, int pos) throws EBusTypeException; /** * ??? diff --git a/src/main/java/de/csdev/ebus/command/datatypes/IEBusType.java b/src/main/java/de/csdev/ebus/command/datatypes/IEBusType.java index 9aa51d7..9e98d7a 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/IEBusType.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/IEBusType.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,12 +10,14 @@ import java.util.Map; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; /** * @author Christian Sowada - Initial contribution * */ +@NonNullByDefault public interface IEBusType { public static final String LENGTH = "length"; @@ -72,6 +74,6 @@ public interface IEBusType { * @param properties * @return */ - public IEBusType getInstance(@Nullable Map properties); + public @Nullable IEBusType getInstance(@Nullable Map properties); } diff --git a/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeBytes.java b/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeBytes.java index e2f73c6..0767a43 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeBytes.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeBytes.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,6 +11,8 @@ import java.util.Map; import java.util.Objects; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import de.csdev.ebus.command.datatypes.EBusAbstractType; @@ -20,6 +22,7 @@ * @author Christian Sowada - Initial contribution * */ +@NonNullByDefault public class EBusTypeBytes extends EBusAbstractType { public static String TYPE_BYTES = "bytes"; @@ -43,7 +46,7 @@ public byte[] encodeInt(@Nullable Object data) { byte[] b = new byte[length]; - if (data != null && data instanceof byte[]) { + if (data instanceof byte[]) { System.arraycopy(data, 0, b, 0, b.length); } @@ -56,7 +59,7 @@ public int getTypeLength() { } @Override - public IEBusType getInstance(@Nullable Map properties) { + public @NonNull IEBusType getInstance(@Nullable Map properties) { Objects.requireNonNull(properties); if (properties.containsKey(IEBusType.LENGTH)) { diff --git a/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeDate.java b/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeDate.java index 27122e5..4fd1c57 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeDate.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeDate.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 @@ -15,6 +15,7 @@ import java.util.Objects; import org.apache.commons.lang3.StringUtils; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import de.csdev.ebus.command.datatypes.EBusAbstractType; @@ -29,6 +30,7 @@ * @author Christian Sowada - Initial contribution * */ +@NonNullByDefault public class EBusTypeDate extends EBusAbstractType { public static String TYPE_DATE = "date"; @@ -69,7 +71,8 @@ public int getTypeLength() { } @Override - public EBusDateTime decodeInt(byte @Nullable [] data) throws EBusTypeException { + @SuppressWarnings("java:S3776") + public @Nullable EBusDateTime decodeInt(byte @Nullable [] data) throws EBusTypeException { Objects.requireNonNull(data); @@ -77,6 +80,10 @@ public EBusDateTime decodeInt(byte @Nullable [] data) throws EBusTypeException { IEBusType wordType = types.getType(EBusTypeWord.TYPE_WORD); IEBusType charType = types.getType(EBusTypeChar.TYPE_CHAR); + if (bcdType == null || wordType == null || charType == null ) { + throw new EBusTypeException("Unable to get all required EBusTyp's types!"); + } + Calendar calendar = new GregorianCalendar(); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); @@ -153,12 +160,16 @@ public EBusDateTime decodeInt(byte @Nullable [] data) throws EBusTypeException { } @Override - public byte[] encodeInt(@Nullable Object data) throws EBusTypeException { + public byte @Nullable [] encodeInt(@Nullable Object data) throws EBusTypeException { IEBusType bcdType = types.getType(EBusTypeBCD.TYPE_BCD); IEBusType wordType = types.getType(EBusTypeWord.TYPE_WORD); IEBusType charType = types.getType(EBusTypeChar.TYPE_CHAR); + if (bcdType == null || wordType == null || charType == null) { + throw new EBusTypeException("Unable to get all required EBusTyp's type!"); + } + Calendar calendar = null; byte[] result = new byte[this.getTypeLength()]; @@ -180,51 +191,51 @@ public byte[] encodeInt(@Nullable Object data) throws EBusTypeException { calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); - if (calendar != null) { - if (StringUtils.equals(variant, DEFAULT)) { - int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); - dayOfWeek = dayOfWeek == 1 ? 7 : dayOfWeek - 1; + if (StringUtils.equals(variant, DEFAULT)) { + + int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); + dayOfWeek = dayOfWeek == 1 ? 7 : dayOfWeek - 1; - result = new byte[] { bcdType.encode(calendar.get(Calendar.DAY_OF_MONTH))[0], - bcdType.encode(calendar.get(Calendar.MONTH) + 1)[0], bcdType.encode(dayOfWeek)[0], - bcdType.encode(calendar.get(Calendar.YEAR) % 100)[0] }; + result = new byte[] { bcdType.encode(calendar.get(Calendar.DAY_OF_MONTH))[0], + bcdType.encode(calendar.get(Calendar.MONTH) + 1)[0], bcdType.encode(dayOfWeek)[0], + bcdType.encode(calendar.get(Calendar.YEAR) % 100)[0] }; - } else if (StringUtils.equals(variant, SHORT)) { + } else if (StringUtils.equals(variant, SHORT)) { - result = new byte[] { bcdType.encode(calendar.get(Calendar.DAY_OF_MONTH))[0], - bcdType.encode(calendar.get(Calendar.MONTH) + 1)[0], - bcdType.encode(calendar.get(Calendar.YEAR) % 100)[0] }; + result = new byte[] { bcdType.encode(calendar.get(Calendar.DAY_OF_MONTH))[0], + bcdType.encode(calendar.get(Calendar.MONTH) + 1)[0], + bcdType.encode(calendar.get(Calendar.YEAR) % 100)[0] }; - } else if (StringUtils.equals(variant, HEX)) { + } else if (StringUtils.equals(variant, HEX)) { - int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); - dayOfWeek = dayOfWeek == 1 ? 7 : dayOfWeek - 1; + int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); + dayOfWeek = dayOfWeek == 1 ? 7 : dayOfWeek - 1; - result = new byte[] { charType.encode(calendar.get(Calendar.DAY_OF_MONTH))[0], - charType.encode(calendar.get(Calendar.MONTH) + 1)[0], charType.encode(dayOfWeek)[0], - charType.encode(calendar.get(Calendar.YEAR) % 100)[0] }; + result = new byte[] { charType.encode(calendar.get(Calendar.DAY_OF_MONTH))[0], + charType.encode(calendar.get(Calendar.MONTH) + 1)[0], charType.encode(dayOfWeek)[0], + charType.encode(calendar.get(Calendar.YEAR) % 100)[0] }; - } else if (StringUtils.equals(variant, HEX_SHORT)) { + } else if (StringUtils.equals(variant, HEX_SHORT)) { - result = new byte[] { charType.encode(calendar.get(Calendar.DAY_OF_MONTH))[0], - charType.encode(calendar.get(Calendar.MONTH) + 1)[0], - charType.encode(calendar.get(Calendar.YEAR) % 100)[0] }; + result = new byte[] { charType.encode(calendar.get(Calendar.DAY_OF_MONTH))[0], + charType.encode(calendar.get(Calendar.MONTH) + 1)[0], + charType.encode(calendar.get(Calendar.YEAR) % 100)[0] }; - } else if (StringUtils.equals(variant, DAYS)) { + } else if (StringUtils.equals(variant, DAYS)) { - long millis = calendar.getTimeInMillis(); + long millis = calendar.getTimeInMillis(); - calendar.clear(); - calendar.set(1900, 0, 1, 0, 0); - long millis1900 = calendar.getTimeInMillis(); + calendar.clear(); + calendar.set(1900, 0, 1, 0, 0); + long millis1900 = calendar.getTimeInMillis(); - BigDecimal days = new BigDecimal(millis - millis1900); - days = days.divide(BigDecimal.valueOf(86400000), 0, RoundingMode.HALF_UP); + BigDecimal days = new BigDecimal(millis - millis1900); + days = days.divide(BigDecimal.valueOf(86400000), 0, RoundingMode.HALF_UP); - result = wordType.encode(days); - } + result = wordType.encode(days); } + return result; } diff --git a/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeDateTime.java b/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeDateTime.java index 2b6034a..74e1073 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeDateTime.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeDateTime.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 @@ -15,6 +15,8 @@ import java.util.Map; import org.apache.commons.lang3.ArrayUtils; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -28,6 +30,7 @@ * @author Christian Sowada - Initial contribution * */ +@NonNullByDefault public class EBusTypeDateTime extends EBusAbstractType { private static final Logger logger = LoggerFactory.getLogger(EBusTypeDateTime.class); @@ -49,7 +52,7 @@ public class EBusTypeDateTime extends EBusAbstractType { private String variantTime = EBusTypeTime.DEFAULT; @Override - protected byte[] applyByteOrder(byte[] data) { + protected byte @Nullable [] applyByteOrder(byte @Nullable [] data) { if (reverseByteOrder) { logger.warn("Parameter 'reverseByteOrder' not supported for EBusTypeDateTime yet!"); } @@ -62,6 +65,10 @@ public EBusDateTime decodeInt(byte @Nullable [] data) throws EBusTypeException { IEBusType dateType = getDateType(); IEBusType timeType = getTimeType(); + if (dateType == null || timeType == null) { + throw new EBusTypeException("Unable to get all required EBusTyp's types!"); + } + byte[] timeData = null; byte[] dateData = null; @@ -113,6 +120,10 @@ public byte[] encodeInt(@Nullable Object data) throws EBusTypeException { IEBusType dateType = getDateType(); IEBusType timeType = getTimeType(); + if (dateType == null || timeType == null) { + throw new EBusTypeException("Unable to get all required EBusTyp's type!"); + } + Calendar calendar = null; byte[] result = new byte[this.getTypeLength()]; @@ -141,19 +152,19 @@ public byte[] encodeInt(@Nullable Object data) throws EBusTypeException { return result; } - private IEBusType getDateType() { - Map properties = new HashMap(); + private @Nullable IEBusType getDateType() { + Map properties = new HashMap<>(); properties.put(IEBusType.VARIANT, variantDate); return types.getType(EBusTypeDate.TYPE_DATE, properties); } @Override - public String[] getSupportedTypes() { + public String @NonNull [] getSupportedTypes() { return supportedTypes; } - private IEBusType getTimeType() { - Map properties = new HashMap(); + private @Nullable IEBusType getTimeType() { + Map properties = new HashMap<>(); properties.put(IEBusType.VARIANT, variantTime); return types.getType(EBusTypeTime.TYPE_TIME, properties); } @@ -163,6 +174,10 @@ public int getTypeLength() { IEBusType dateType = getDateType(); IEBusType timeType = getTimeType(); + if (dateType == null || timeType == null) { + throw new IllegalStateException("Unable to get all required EBusTyp's type!"); + } + return dateType.getTypeLength() + timeType.getTypeLength(); } diff --git a/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeKWCrc.java b/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeKWCrc.java index b0480cd..fbb2616 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeKWCrc.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeKWCrc.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,6 +10,8 @@ import java.nio.ByteBuffer; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import de.csdev.ebus.command.datatypes.EBusAbstractType; @@ -21,6 +23,7 @@ * @author Christian Sowada - Initial contribution * */ +@NonNullByDefault public class EBusTypeKWCrc extends EBusAbstractType implements IEBusComplexType { public static String TYPE_KW_CRC = "kw-crc"; @@ -41,18 +44,18 @@ public int getTypeLength() { } @Override - public String[] getSupportedTypes() { + public String @NonNull [] getSupportedTypes() { return supportedTypes; } @Override - public Byte decodeInt(byte @Nullable [] data) { - throw new RuntimeException("Not implemented by EBusTypeKWCrc!"); + public Byte decodeInt(byte @Nullable [] data) throws EBusTypeException { + throw new EBusTypeException("Not implemented by EBusTypeKWCrc!"); } @Override - public byte[] encodeInt(@Nullable Object data) { - throw new RuntimeException("Not implemented by EBusTypeKWCrc!"); + public byte[] encodeInt(@Nullable Object data) throws EBusTypeException { + throw new EBusTypeException("Not implemented by EBusTypeKWCrc!"); } @Override diff --git a/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeMultiWord.java b/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeMultiWord.java index adb9007..72f4f26 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeMultiWord.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeMultiWord.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,6 +10,8 @@ import java.math.BigDecimal; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import de.csdev.ebus.command.datatypes.EBusAbstractType; @@ -22,6 +24,7 @@ * @author Christian Sowada - Initial contribution * */ +@NonNullByDefault public class EBusTypeMultiWord extends EBusAbstractType { public static String TYPE_MWORD = "mword"; @@ -31,10 +34,12 @@ public class EBusTypeMultiWord extends EBusAbstractType { private static String[] supportedTypes = new String[] { TYPE_MWORD }; private int length = 2; + + @SuppressWarnings({"null"}) private BigDecimal multiplier = BigDecimal.valueOf(1000); @Override - public String[] getSupportedTypes() { + public String @NonNull [] getSupportedTypes() { return supportedTypes; } @@ -44,7 +49,7 @@ public int getTypeLength() { } @Override - public BigDecimal decodeInt(byte @Nullable [] data) throws EBusTypeException { + public @Nullable BigDecimal decodeInt(byte @Nullable [] data) throws EBusTypeException { byte[] dataNew = new byte[2]; diff --git a/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeString.java b/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeString.java index 5fbaf9f..9969e98 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeString.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeString.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,6 +8,7 @@ */ package de.csdev.ebus.command.datatypes.ext; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import de.csdev.ebus.command.datatypes.EBusAbstractType; @@ -16,6 +17,7 @@ * @author Christian Sowada - Initial contribution * */ +@NonNullByDefault public class EBusTypeString extends EBusAbstractType { public static String TYPE_STRING = "string"; diff --git a/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeTime.java b/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeTime.java index eaa3a46..1a2f3bd 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeTime.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeTime.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 @@ -14,6 +14,7 @@ import java.util.GregorianCalendar; import org.apache.commons.lang3.StringUtils; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import de.csdev.ebus.command.datatypes.EBusAbstractType; @@ -29,6 +30,7 @@ * @author Christian Sowada - Initial contribution * */ +@NonNullByDefault public class EBusTypeTime extends EBusAbstractType { public static String TYPE_TIME = "time"; @@ -48,6 +50,7 @@ public class EBusTypeTime extends EBusAbstractType { private String variant = DEFAULT; + @SuppressWarnings({"null"}) private BigDecimal minuteMultiplier = BigDecimal.valueOf(1); @Override @@ -74,6 +77,7 @@ public int getTypeLength() { } @Override + @SuppressWarnings("java:S3776") public EBusDateTime decodeInt(byte @Nullable [] data) throws EBusTypeException { if (data == null) { @@ -90,25 +94,28 @@ public EBusDateTime decodeInt(byte @Nullable [] data) throws EBusTypeException { throw new EBusTypeException("Input byte array must have a length of %d bytes!", getTypeLength()); } + IEBusType bcdType = types.getType(EBusTypeBCD.TYPE_BCD); + IEBusType charType = types.getType(EBusTypeChar.TYPE_CHAR); + + if (bcdType == null || charType == null) { + throw new EBusTypeException("Unable to get all required EBusTyp's type!"); + } + if (StringUtils.equals(variant, SHORT)) { - IEBusType bcdType = types.getType(EBusTypeBCD.TYPE_BCD); minute = bcdType.decode(new byte[] { data[0] }); hour = bcdType.decode(new byte[] { data[1] }); } else if (StringUtils.equals(variant, DEFAULT)) { - IEBusType bcdType = types.getType(EBusTypeBCD.TYPE_BCD); second = bcdType.decode(new byte[] { data[0] }); minute = bcdType.decode(new byte[] { data[1] }); hour = bcdType.decode(new byte[] { data[2] }); } else if (StringUtils.equals(variant, HEX)) { - IEBusType charType = types.getType(EBusTypeChar.TYPE_CHAR); second = charType.decode(new byte[] { data[0] }); minute = charType.decode(new byte[] { data[1] }); hour = charType.decode(new byte[] { data[2] }); } else if (StringUtils.equals(variant, HEX_SHORT)) { - IEBusType charType = types.getType(EBusTypeChar.TYPE_CHAR); minute = charType.decode(new byte[] { data[0] }); hour = charType.decode(new byte[] { data[1] }); @@ -117,9 +124,15 @@ public EBusDateTime decodeInt(byte @Nullable [] data) throws EBusTypeException { BigDecimal minutesSinceMidnight = null; if (StringUtils.equals(variant, MINUTES_SHORT)) { IEBusType type = types.getType(EBusTypeUnsignedNumber.TYPE_UNUMBER, IEBusType.LENGTH, 1); + if (type == null) { + throw new EBusTypeException("Unable to get required EBusTyp type!"); + } minutesSinceMidnight = type.decode(data); } else { IEBusType type = types.getType(EBusTypeUnsignedNumber.TYPE_UNUMBER, IEBusType.LENGTH, 2); + if (type == null) { + throw new EBusTypeException("Unable to get required EBusTyp type!"); + } minutesSinceMidnight = type.decode(data); } @@ -150,12 +163,16 @@ public EBusDateTime decodeInt(byte @Nullable [] data) throws EBusTypeException { } @Override - public byte[] encodeInt(@Nullable Object data) throws EBusTypeException { + public byte @Nullable [] encodeInt(@Nullable Object data) throws EBusTypeException { IEBusType bcdType = types.getType(EBusTypeBCD.TYPE_BCD); IEBusType wordType = types.getType(EBusTypeWord.TYPE_WORD); IEBusType charType = types.getType(EBusTypeChar.TYPE_CHAR); + if (bcdType == null || wordType == null || charType == null) { + throw new EBusTypeException("Unable to get all required EBusTyp's type!"); + } + Calendar calendar = null; byte[] result = new byte[this.getTypeLength()]; @@ -174,54 +191,53 @@ public byte[] encodeInt(@Nullable Object data) throws EBusTypeException { calendar = (Calendar) calendar.clone(); calendar.set(1970, 0, 1); - if (calendar != null) { - if (StringUtils.equals(variant, DEFAULT)) { - result = new byte[] { bcdType.encode(calendar.get(Calendar.SECOND))[0], - bcdType.encode(calendar.get(Calendar.MINUTE))[0], - bcdType.encode(calendar.get(Calendar.HOUR_OF_DAY))[0] }; + if (StringUtils.equals(variant, DEFAULT)) { - } else if (StringUtils.equals(variant, SHORT)) { + result = new byte[] { bcdType.encode(calendar.get(Calendar.SECOND))[0], + bcdType.encode(calendar.get(Calendar.MINUTE))[0], + bcdType.encode(calendar.get(Calendar.HOUR_OF_DAY))[0] }; - result = new byte[] { bcdType.encode(calendar.get(Calendar.MINUTE))[0], - bcdType.encode(calendar.get(Calendar.HOUR_OF_DAY))[0] }; + } else if (StringUtils.equals(variant, SHORT)) { - } else if (StringUtils.equals(variant, HEX)) { + result = new byte[] { bcdType.encode(calendar.get(Calendar.MINUTE))[0], + bcdType.encode(calendar.get(Calendar.HOUR_OF_DAY))[0] }; - result = new byte[] { charType.encode(calendar.get(Calendar.SECOND))[0], - charType.encode(calendar.get(Calendar.MINUTE))[0], - charType.encode(calendar.get(Calendar.HOUR_OF_DAY))[0] }; + } else if (StringUtils.equals(variant, HEX)) { - } else if (StringUtils.equals(variant, HEX_SHORT)) { + result = new byte[] { charType.encode(calendar.get(Calendar.SECOND))[0], + charType.encode(calendar.get(Calendar.MINUTE))[0], + charType.encode(calendar.get(Calendar.HOUR_OF_DAY))[0] }; - result = new byte[] { charType.encode(calendar.get(Calendar.MINUTE))[0], - charType.encode(calendar.get(Calendar.HOUR_OF_DAY))[0] }; + } else if (StringUtils.equals(variant, HEX_SHORT)) { - } else if (StringUtils.equals(variant, MINUTES) || StringUtils.equals(variant, MINUTES_SHORT)) { + result = new byte[] { charType.encode(calendar.get(Calendar.MINUTE))[0], + charType.encode(calendar.get(Calendar.HOUR_OF_DAY))[0] }; - long millis = calendar.getTimeInMillis(); + } else if (StringUtils.equals(variant, MINUTES) || StringUtils.equals(variant, MINUTES_SHORT)) { - calendar.clear(); - calendar.set(1970, 0, 1, 0, 0, 0); - calendar.set(Calendar.MILLISECOND, 0); + long millis = calendar.getTimeInMillis(); - long millisMidnight = calendar.getTimeInMillis(); + calendar.clear(); + calendar.set(1970, 0, 1, 0, 0, 0); + calendar.set(Calendar.MILLISECOND, 0); - BigDecimal minutes = new BigDecimal(millis - millisMidnight); + long millisMidnight = calendar.getTimeInMillis(); - // milliseconds to minutes - minutes = minutes.divide(BigDecimal.valueOf(1000 * 60), 0, RoundingMode.HALF_UP); + BigDecimal minutes = new BigDecimal(millis - millisMidnight); - // xxx - minutes = minutes.divide(minuteMultiplier, 0, RoundingMode.HALF_UP); + // milliseconds to minutes + minutes = minutes.divide(BigDecimal.valueOf(1000L * 60), 0, RoundingMode.HALF_UP); - if (StringUtils.equals(variant, MINUTES_SHORT)) { - result = charType.encode(minutes); - } else { - result = wordType.encode(minutes); - } + // xxx + minutes = minutes.divide(minuteMultiplier, 0, RoundingMode.HALF_UP); + if (StringUtils.equals(variant, MINUTES_SHORT)) { + result = charType.encode(minutes); + } else { + result = wordType.encode(minutes); } + } return result; diff --git a/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeVersion.java b/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeVersion.java index 459c723..370cbe9 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeVersion.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeVersion.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,6 +10,7 @@ import java.math.BigDecimal; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import de.csdev.ebus.command.datatypes.EBusAbstractType; @@ -21,6 +22,7 @@ * @author Christian Sowada - Initial contribution * */ +@NonNullByDefault public class EBusTypeVersion extends EBusAbstractType { public static String TYPE_VERSION = "version"; @@ -38,7 +40,7 @@ public int getTypeLength() { } @Override - public BigDecimal decodeInt(byte @Nullable [] data) throws EBusTypeException { + public @Nullable BigDecimal decodeInt(byte @Nullable [] data) throws EBusTypeException { if (data == null) { throw new IllegalArgumentException(); @@ -59,7 +61,7 @@ public BigDecimal decodeInt(byte @Nullable [] data) throws EBusTypeException { } @Override - public byte[] encodeInt(@Nullable Object data) throws EBusTypeException { + public byte @Nullable [] encodeInt(@Nullable Object data) throws EBusTypeException { BigDecimal value = NumberUtils.toBigDecimal(data); @@ -73,6 +75,10 @@ public byte[] encodeInt(@Nullable Object data) throws EBusTypeException { byte[] encode1 = types.encode(EBusTypeBCD.TYPE_BCD, values[0]); byte[] encode2 = types.encode(EBusTypeBCD.TYPE_BCD, values[1]); + if ( encode1 == null || encode1.length == 0 || encode2 == null || encode2.length == 0 ) { + return null; + } + return new byte[] { encode1[0], encode2[0] }; } diff --git a/src/main/java/de/csdev/ebus/command/datatypes/std/AbstractEBusTypeNumber.java b/src/main/java/de/csdev/ebus/command/datatypes/std/AbstractEBusTypeNumber.java index 915c77b..b53057c 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/std/AbstractEBusTypeNumber.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/std/AbstractEBusTypeNumber.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,27 +12,32 @@ import java.math.BigInteger; import org.apache.commons.lang3.ArrayUtils; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import de.csdev.ebus.command.datatypes.EBusAbstractType; import de.csdev.ebus.command.datatypes.EBusTypeException; import de.csdev.ebus.utils.NumberUtils; +@NonNullByDefault public abstract class AbstractEBusTypeNumber extends EBusAbstractType { @Override public byte[] getReplaceValue() { int length = getTypeLength(); - if (replaceValue == null || replaceValue.length == 0) { - replaceValue = new byte[length]; - replaceValue[length - 1] = (byte) 0x80; - } + byte[] lReplacevalue = this.replaceValue; - return replaceValue; + if (lReplacevalue == null || lReplacevalue.length == 0) { + lReplacevalue = new byte[length]; + lReplacevalue[length - 1] = (byte) 0x80; + } + + this.replaceValue = lReplacevalue; + return lReplacevalue; } @Override - public BigDecimal decodeInt(byte @Nullable [] data) throws EBusTypeException { + public @Nullable BigDecimal decodeInt(byte @Nullable [] data) throws EBusTypeException { byte[] clone = ArrayUtils.clone(data); ArrayUtils.reverse(clone); return new BigDecimal(new BigInteger(clone)); diff --git a/src/main/java/de/csdev/ebus/command/datatypes/std/AbstractEBusTypeUnsignedNumber.java b/src/main/java/de/csdev/ebus/command/datatypes/std/AbstractEBusTypeUnsignedNumber.java index e3d1671..f60ba91 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/std/AbstractEBusTypeUnsignedNumber.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/std/AbstractEBusTypeUnsignedNumber.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.math.BigInteger; import org.apache.commons.lang3.ArrayUtils; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import de.csdev.ebus.command.datatypes.EBusAbstractType; @@ -22,10 +23,11 @@ * @author Christian Sowada - Initial contribution * */ +@NonNullByDefault public abstract class AbstractEBusTypeUnsignedNumber extends EBusAbstractType { @Override - public BigDecimal decodeInt(byte @Nullable [] data) throws EBusTypeException { + public @Nullable BigDecimal decodeInt(byte @Nullable [] data) throws EBusTypeException { byte[] clone = ArrayUtils.clone(data); ArrayUtils.reverse(clone); @@ -34,7 +36,7 @@ public BigDecimal decodeInt(byte @Nullable [] data) throws EBusTypeException { } @Override - public byte[] encodeInt(@Nullable Object data) throws EBusTypeException { + public byte @Nullable [] encodeInt(@Nullable Object data) throws EBusTypeException { BigDecimal b = NumberUtils.toBigDecimal(data == null ? 0 : data); diff --git a/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeBCD.java b/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeBCD.java index f956d01..adcd033 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeBCD.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeBCD.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,6 +11,7 @@ import java.math.BigDecimal; import java.util.Objects; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import de.csdev.ebus.command.datatypes.EBusAbstractType; @@ -22,11 +23,12 @@ * @author Christian Sowada - Initial contribution * */ +@NonNullByDefault public class EBusTypeBCD extends EBusAbstractType { public static String TYPE_BCD = "bcd"; - private static String[] supportedTypes = new String[] { TYPE_BCD }; + private static final String[] supportedTypes = new String[] { TYPE_BCD }; private int length = 1; @@ -45,7 +47,7 @@ public int getTypeLength() { } @Override - public BigDecimal decodeInt(byte @Nullable [] data) { + public @Nullable BigDecimal decodeInt(byte @Nullable [] data) { Objects.requireNonNull(data); diff --git a/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeBit.java b/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeBit.java index 6c7fa87..3dd84ae 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeBit.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeBit.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,6 +10,8 @@ import java.util.Objects; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import de.csdev.ebus.command.datatypes.EBusAbstractType; @@ -19,27 +21,30 @@ * @author Christian Sowada - Initial contribution * */ +@NonNullByDefault public class EBusTypeBit extends EBusAbstractType { - public static String TYPE_BIT = "bit"; + public static final String TYPE_BIT = "bit"; - private static String[] supportedTypes = new String[] { TYPE_BIT }; + private static final String[] supportedTypes = new String[] { TYPE_BIT }; public static String POS = "pos"; + // will be filled by reflection + @SuppressWarnings({"null", "java:S1845"}) private Integer pos = null; public EBusTypeBit() { - + // noop } @Override - public byte[] getReplaceValue() { + public byte @Nullable [] getReplaceValue() { return null; } @Override - public String[] getSupportedTypes() { + public String @NonNull [] getSupportedTypes() { return supportedTypes; } @@ -50,16 +55,13 @@ public int getTypeLength() { @Override public Boolean decodeInt(byte @Nullable [] data) { - Objects.requireNonNull(data); - - Boolean isSet = (data[0] >> pos & 0x1) == 1; - return isSet; + return (data[0] >> pos & 0x1) == 1; } @Override public byte[] encodeInt(@Nullable Object data) { - throw new RuntimeException("Not implemented yet!"); + throw new UnsupportedOperationException("Not implemented yet!"); } @Override diff --git a/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeByte.java b/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeByte.java index 70bc0ad..05c7930 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeByte.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeByte.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,12 +8,15 @@ */ package de.csdev.ebus.command.datatypes.std; +import org.eclipse.jdt.annotation.NonNullByDefault; + import de.csdev.ebus.utils.EBusUtils; /** * @author Christian Sowada - Initial contribution * */ +@NonNullByDefault public class EBusTypeByte extends AbstractEBusTypeUnsignedNumber { public static String TYPE_UCHAR = "uchar"; diff --git a/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeChar.java b/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeChar.java index b25ba53..ca5828a 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeChar.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeChar.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,12 +8,15 @@ */ package de.csdev.ebus.command.datatypes.std; +import org.eclipse.jdt.annotation.NonNullByDefault; + import de.csdev.ebus.utils.EBusUtils; /** * @author Christian Sowada - Initial contribution * */ +@NonNullByDefault public class EBusTypeChar extends AbstractEBusTypeNumber { public static String TYPE_CHAR = "char"; diff --git a/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeData1b.java b/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeData1b.java index c7ab667..68eb0e9 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeData1b.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeData1b.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,12 +8,15 @@ */ package de.csdev.ebus.command.datatypes.std; +import org.eclipse.jdt.annotation.NonNullByDefault; + import de.csdev.ebus.utils.EBusUtils; /** * @author Christian Sowada - Initial contribution * */ +@NonNullByDefault public class EBusTypeData1b extends AbstractEBusTypeNumber { public static String TYPE_DATA1B = "data1b"; diff --git a/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeData1c.java b/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeData1c.java index b81a794..a36f62b 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeData1c.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeData1c.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,6 +10,7 @@ import java.math.BigDecimal; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import de.csdev.ebus.command.datatypes.EBusTypeException; @@ -20,6 +21,7 @@ * @author Christian Sowada - Initial contribution * */ +@NonNullByDefault public class EBusTypeData1c extends AbstractEBusTypeUnsignedNumber { public static String TYPE_DATA1C = "data1c"; @@ -37,13 +39,17 @@ public int getTypeLength() { } @Override - public BigDecimal decodeInt(byte @Nullable [] data) throws EBusTypeException { + public @Nullable BigDecimal decodeInt(byte @Nullable [] data) throws EBusTypeException { BigDecimal decodeInt = super.decodeInt(data); - return decodeInt.divide(BigDecimal.valueOf(2)); + + if (decodeInt != null) { + return decodeInt.divide(BigDecimal.valueOf(2)); + } + return null; } @Override - public byte[] encodeInt(@Nullable Object data) throws EBusTypeException { + public byte @Nullable [] encodeInt(@Nullable Object data) throws EBusTypeException { BigDecimal b = NumberUtils.toBigDecimal(data); if (b == null) { diff --git a/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeData2b.java b/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeData2b.java index 2449a1d..45a6c76 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeData2b.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeData2b.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,6 +10,7 @@ import java.math.BigDecimal; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import de.csdev.ebus.command.datatypes.EBusTypeException; @@ -20,6 +21,7 @@ * @author Christian Sowada - Initial contribution * */ +@NonNullByDefault public class EBusTypeData2b extends AbstractEBusTypeNumber { public static String TYPE_DATA2B = "data2b"; @@ -37,9 +39,12 @@ public int getTypeLength() { } @Override - public BigDecimal decodeInt(byte @Nullable [] data) throws EBusTypeException { + public @Nullable BigDecimal decodeInt(byte @Nullable [] data) throws EBusTypeException { BigDecimal decodeInt = super.decodeInt(data); - return decodeInt.divide(BigDecimal.valueOf(256)); + if (decodeInt != null) { + return decodeInt.divide(BigDecimal.valueOf(256)); + } + return null; } @Override diff --git a/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeData2c.java b/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeData2c.java index 2a9940b..2bbeceb 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeData2c.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeData2c.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,6 +10,7 @@ import java.math.BigDecimal; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import de.csdev.ebus.command.datatypes.EBusTypeException; @@ -20,6 +21,7 @@ * @author Christian Sowada - Initial contribution * */ +@NonNullByDefault public class EBusTypeData2c extends AbstractEBusTypeNumber { public static String TYPE_DATA2C = "data2c"; @@ -37,15 +39,18 @@ public int getTypeLength() { } @Override - public BigDecimal decodeInt(byte @Nullable [] data) throws EBusTypeException { + public @Nullable BigDecimal decodeInt(byte @Nullable [] data) throws EBusTypeException { BigDecimal decodeInt = super.decodeInt(data); - return decodeInt.divide(BigDecimal.valueOf(16)); + if (decodeInt != null) { + return decodeInt.divide(BigDecimal.valueOf(16)); + } + return null; } @Override public byte[] encodeInt(@Nullable Object data) throws EBusTypeException { BigDecimal b = NumberUtils.toBigDecimal(data); - + if (b == null) { throw new EBusTypeException("Unable to convert input data to number!"); } diff --git a/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeFloat.java b/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeFloat.java index 7eb429b..d20132e 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeFloat.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeFloat.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.nio.ByteBuffer; import java.nio.ByteOrder; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -25,8 +26,10 @@ * @author Christian Sowada - Initial contribution * */ +@NonNullByDefault public class EBusTypeFloat extends EBusAbstractType { + @SuppressWarnings({"null"}) private static final Logger logger = LoggerFactory.getLogger(EBusTypeFloat.class); public static String TYPE_FLOAT = "float"; @@ -49,7 +52,7 @@ public int getTypeLength() { } @Override - public BigDecimal decodeInt(byte @Nullable [] data) throws EBusTypeException { + public @Nullable BigDecimal decodeInt(byte @Nullable [] data) throws EBusTypeException { float value = ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN).getFloat(); if (!Float.isNaN(value)) { return BigDecimal.valueOf(value); @@ -60,7 +63,7 @@ public BigDecimal decodeInt(byte @Nullable [] data) throws EBusTypeException { } @Override - public byte[] encodeInt(@Nullable Object data) throws EBusTypeException { + public byte @Nullable [] encodeInt(@Nullable Object data) throws EBusTypeException { BigDecimal b = NumberUtils.toBigDecimal(data == null ? 0 : data); diff --git a/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeInteger.java b/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeInteger.java index d6cd2ed..8551593 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeInteger.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeInteger.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,12 +8,15 @@ */ package de.csdev.ebus.command.datatypes.std; +import org.eclipse.jdt.annotation.NonNullByDefault; + import de.csdev.ebus.utils.EBusUtils; /** * @author Christian Sowada - Initial contribution * */ +@NonNullByDefault public class EBusTypeInteger extends AbstractEBusTypeNumber { public static String TYPE_INTEGER = "int"; diff --git a/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeNumber.java b/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeNumber.java index eeea5ca..905eb33 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeNumber.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeNumber.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,12 +8,15 @@ */ package de.csdev.ebus.command.datatypes.std; +import org.eclipse.jdt.annotation.NonNullByDefault; + import de.csdev.ebus.utils.EBusUtils; /** * @author Christian Sowada - Initial contribution * */ +@NonNullByDefault public class EBusTypeNumber extends AbstractEBusTypeNumber { public static String TYPE_NUMBER = "number"; diff --git a/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeUnsignedNumber.java b/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeUnsignedNumber.java index 994e0c3..cf7590b 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeUnsignedNumber.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeUnsignedNumber.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,12 +8,15 @@ */ package de.csdev.ebus.command.datatypes.std; +import org.eclipse.jdt.annotation.NonNullByDefault; + import de.csdev.ebus.utils.EBusUtils; /** * @author Christian Sowada - Initial contribution * */ +@NonNullByDefault public class EBusTypeUnsignedNumber extends AbstractEBusTypeUnsignedNumber { public static String TYPE_UNUMBER = "unumber"; diff --git a/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeWord.java b/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeWord.java index 3dc2024..06add6e 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeWord.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeWord.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,12 +8,15 @@ */ package de.csdev.ebus.command.datatypes.std; +import org.eclipse.jdt.annotation.NonNullByDefault; + import de.csdev.ebus.utils.EBusUtils; /** * @author Christian Sowada - Initial contribution * */ +@NonNullByDefault public class EBusTypeWord extends AbstractEBusTypeUnsignedNumber { public static String TYPE_WORD = "word"; diff --git a/src/main/java/de/csdev/ebus/core/EBusConnectorEventListener.java b/src/main/java/de/csdev/ebus/core/EBusConnectorEventListener.java index ddd3d32..607372b 100644 --- a/src/main/java/de/csdev/ebus/core/EBusConnectorEventListener.java +++ b/src/main/java/de/csdev/ebus/core/EBusConnectorEventListener.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/core/EBusConsts.java b/src/main/java/de/csdev/ebus/core/EBusConsts.java index 631b673..e4efed0 100644 --- a/src/main/java/de/csdev/ebus/core/EBusConsts.java +++ b/src/main/java/de/csdev/ebus/core/EBusConsts.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,6 +8,8 @@ */ package de.csdev.ebus.core; +import org.eclipse.jdt.annotation.NonNull; + /** * @author Christian Sowada - Initial contribution * @@ -34,10 +36,12 @@ private EBusConsts() { public static final byte ESCAPE = (byte) 0xA9; /** replacement for an excape symbol */ - public static final byte[] ESCAPE_REPLACEMENT = new byte[] { EBusConsts.ESCAPE, 0x00 }; + @SuppressWarnings("java:S2386") + public static final byte @NonNull [] ESCAPE_REPLACEMENT = new byte[] { EBusConsts.ESCAPE, 0x00 }; /** replacement for an sync symbol */ - public static final byte[] SYN_REPLACEMENT = new byte[] { EBusConsts.ESCAPE, 0x01 }; + @SuppressWarnings("java:S2386") + public static final byte @NonNull [] SYN_REPLACEMENT = new byte[] { EBusConsts.ESCAPE, 0x01 }; /** eBUS standard collection id */ public static final String COLLECTION_STD = "std"; diff --git a/src/main/java/de/csdev/ebus/core/EBusControllerBase.java b/src/main/java/de/csdev/ebus/core/EBusControllerBase.java index 2c37f16..eb63054 100644 --- a/src/main/java/de/csdev/ebus/core/EBusControllerBase.java +++ b/src/main/java/de/csdev/ebus/core/EBusControllerBase.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 @@ -336,7 +336,7 @@ protected void setConnectionStatus(final @NonNull ConnectionStatus status) { } @Override - public ConnectionStatus getConnectionStatus() { + public @NonNull ConnectionStatus getConnectionStatus() { return this.connectionStatus; } diff --git a/src/main/java/de/csdev/ebus/core/EBusControllerException.java b/src/main/java/de/csdev/ebus/core/EBusControllerException.java index 95ab9ba..de0e52c 100644 --- a/src/main/java/de/csdev/ebus/core/EBusControllerException.java +++ b/src/main/java/de/csdev/ebus/core/EBusControllerException.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/core/EBusDataException.java b/src/main/java/de/csdev/ebus/core/EBusDataException.java index e9a55c0..097ea94 100644 --- a/src/main/java/de/csdev/ebus/core/EBusDataException.java +++ b/src/main/java/de/csdev/ebus/core/EBusDataException.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/core/EBusEbusdController.java b/src/main/java/de/csdev/ebus/core/EBusEbusdController.java index 4e8a083..b1dafdd 100644 --- a/src/main/java/de/csdev/ebus/core/EBusEbusdController.java +++ b/src/main/java/de/csdev/ebus/core/EBusEbusdController.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 @@ -128,6 +128,7 @@ public void run() { } } + @SuppressWarnings("java:S3776") private ByteBuffer parseLine(String readLine) throws IOException, InterruptedException, EBusDataException { ByteBuffer b = null; @@ -250,6 +251,7 @@ private void startSenderThread() { } @Override + @SuppressWarnings("java:S3776") public void run() { try { @@ -414,7 +416,7 @@ private void disconnect() { setConnectionStatus(ConnectionStatus.DISCONNECTED); } - private boolean connect() throws UnknownHostException, IOException { + private boolean connect() throws IOException { logger.info("Run connect ..."); socket = new Socket(hostname, port); socket.setSoTimeout(20000); diff --git a/src/main/java/de/csdev/ebus/core/EBusLowLevelController.java b/src/main/java/de/csdev/ebus/core/EBusLowLevelController.java index 0b5f7c1..8a6e471 100644 --- a/src/main/java/de/csdev/ebus/core/EBusLowLevelController.java +++ b/src/main/java/de/csdev/ebus/core/EBusLowLevelController.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 @@ -129,7 +129,7 @@ private void reconnect() throws IOException, InterruptedException { logger.warn("Retry to connect to eBUS adapter in {} seconds ...", 5 * reConnectCounter); - Thread.sleep(5000 * reConnectCounter); + Thread.sleep(5000L * reConnectCounter); connection.close(); if (connection.open()) { @@ -162,6 +162,7 @@ private boolean resend() { } @Override + @SuppressWarnings("java:S3776") public void run() { initThreadPool(); @@ -259,6 +260,7 @@ public void run() { * @param secondTry * @throws IOException */ + @SuppressWarnings("java:S3776") private void send(boolean secondTry) throws IOException { if (!isRunning()) { diff --git a/src/main/java/de/csdev/ebus/core/EBusQueue.java b/src/main/java/de/csdev/ebus/core/EBusQueue.java index 506ee8d..6bdf0f9 100644 --- a/src/main/java/de/csdev/ebus/core/EBusQueue.java +++ b/src/main/java/de/csdev/ebus/core/EBusQueue.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/core/EBusReceiveStateMachine.java b/src/main/java/de/csdev/ebus/core/EBusReceiveStateMachine.java index 9800638..251436b 100644 --- a/src/main/java/de/csdev/ebus/core/EBusReceiveStateMachine.java +++ b/src/main/java/de/csdev/ebus/core/EBusReceiveStateMachine.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 @@ -225,6 +225,7 @@ public String toDumpString() { * @param dataByte The next byte * @throws EBusDataException throws an exception on any telegram error */ + @SuppressWarnings("java:S3776") public void update(final byte dataByte) throws EBusDataException { byte data = dataByte; diff --git a/src/main/java/de/csdev/ebus/core/EBusVersion.java b/src/main/java/de/csdev/ebus/core/EBusVersion.java index 949777d..7033644 100644 --- a/src/main/java/de/csdev/ebus/core/EBusVersion.java +++ b/src/main/java/de/csdev/ebus/core/EBusVersion.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 @@ -25,7 +25,7 @@ private static String getAttribute(final Class rootClass, final String name) Manifest manifest = new Manifest(rootClass.getResourceAsStream("/META-INF/MANIFEST.MF")); return manifest.getMainAttributes().getValue(name); } catch (IOException e) { - + // noop } return ""; } diff --git a/src/main/java/de/csdev/ebus/core/EBusWorkerThreadFactory.java b/src/main/java/de/csdev/ebus/core/EBusWorkerThreadFactory.java index 7dd647e..705881f 100644 --- a/src/main/java/de/csdev/ebus/core/EBusWorkerThreadFactory.java +++ b/src/main/java/de/csdev/ebus/core/EBusWorkerThreadFactory.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/core/IEBusConnectorEventListener.java b/src/main/java/de/csdev/ebus/core/IEBusConnectorEventListener.java index 7b1e574..c1b4f89 100644 --- a/src/main/java/de/csdev/ebus/core/IEBusConnectorEventListener.java +++ b/src/main/java/de/csdev/ebus/core/IEBusConnectorEventListener.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/core/IEBusController.java b/src/main/java/de/csdev/ebus/core/IEBusController.java index 3db4dfe..fb85db9 100644 --- a/src/main/java/de/csdev/ebus/core/IEBusController.java +++ b/src/main/java/de/csdev/ebus/core/IEBusController.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 @@ -9,10 +9,11 @@ package de.csdev.ebus.core; import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.NonNullByDefault; +@NonNullByDefault public interface IEBusController { - @NonNull Integer addToSendQueue(final byte @NonNull [] buffer, final int maxAttemps) throws EBusControllerException; /** @@ -20,7 +21,6 @@ public interface IEBusController { * @return * @throws EBusControllerException */ - @NonNull Integer addToSendQueue(final byte @NonNull [] buffer) throws EBusControllerException; /** @@ -28,7 +28,7 @@ public interface IEBusController { * * @param listener */ - void addEBusEventListener(final @NonNull IEBusConnectorEventListener listener); + void addEBusEventListener(final IEBusConnectorEventListener listener); /** * Remove an eBUS listener @@ -36,7 +36,7 @@ public interface IEBusController { * @param listener * @return */ - boolean removeEBusEventListener(final @NonNull IEBusConnectorEventListener listener); + boolean removeEBusEventListener(final IEBusConnectorEventListener listener); boolean isRunning(); diff --git a/src/main/java/de/csdev/ebus/core/connection/AbstractEBusConnection.java b/src/main/java/de/csdev/ebus/core/connection/AbstractEBusConnection.java index 75886ca..29870d5 100644 --- a/src/main/java/de/csdev/ebus/core/connection/AbstractEBusConnection.java +++ b/src/main/java/de/csdev/ebus/core/connection/AbstractEBusConnection.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.io.InputStream; import java.io.OutputStream; +import org.eclipse.jdt.annotation.NonNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -53,7 +54,7 @@ public boolean isOpen() throws IOException { } @Override - public int readBytes(final byte[] buffer) throws IOException { + public int readBytes(final byte @NonNull [] buffer) throws IOException { return inputStream.read(buffer); } diff --git a/src/main/java/de/csdev/ebus/core/connection/EBusCaptureProxyConnection.java b/src/main/java/de/csdev/ebus/core/connection/EBusCaptureProxyConnection.java index 0350fb2..17f962c 100644 --- a/src/main/java/de/csdev/ebus/core/connection/EBusCaptureProxyConnection.java +++ b/src/main/java/de/csdev/ebus/core/connection/EBusCaptureProxyConnection.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,6 +10,8 @@ import java.io.IOException; +import org.eclipse.jdt.annotation.NonNull; + import de.csdev.ebus.utils.EmulatorCapture; /** @@ -54,7 +56,7 @@ public boolean isReceiveBufferEmpty() throws IOException { return proxyConnection.isReceiveBufferEmpty(); } - public int readBytes(final byte[] buffer) throws IOException { + public int readBytes(final byte @NonNull [] buffer) throws IOException { int readBytes = proxyConnection.readBytes(buffer); captureWriter.write(buffer, readBytes); return readBytes; diff --git a/src/main/java/de/csdev/ebus/core/connection/EBusEmulatorConnection.java b/src/main/java/de/csdev/ebus/core/connection/EBusEmulatorConnection.java index 3018ce9..71922bd 100644 --- a/src/main/java/de/csdev/ebus/core/connection/EBusEmulatorConnection.java +++ b/src/main/java/de/csdev/ebus/core/connection/EBusEmulatorConnection.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/core/connection/EBusJSerialCommConnection.java b/src/main/java/de/csdev/ebus/core/connection/EBusJSerialCommConnection.java index 9d096b0..7439883 100644 --- a/src/main/java/de/csdev/ebus/core/connection/EBusJSerialCommConnection.java +++ b/src/main/java/de/csdev/ebus/core/connection/EBusJSerialCommConnection.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/core/connection/EBusSerialNRJavaSerialConnection.java b/src/main/java/de/csdev/ebus/core/connection/EBusSerialNRJavaSerialConnection.java index a9867c1..91e50f1 100644 --- a/src/main/java/de/csdev/ebus/core/connection/EBusSerialNRJavaSerialConnection.java +++ b/src/main/java/de/csdev/ebus/core/connection/EBusSerialNRJavaSerialConnection.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/core/connection/EBusTCPConnection.java b/src/main/java/de/csdev/ebus/core/connection/EBusTCPConnection.java index 2d98b1a..97cf0e7 100644 --- a/src/main/java/de/csdev/ebus/core/connection/EBusTCPConnection.java +++ b/src/main/java/de/csdev/ebus/core/connection/EBusTCPConnection.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/core/connection/IEBusConnection.java b/src/main/java/de/csdev/ebus/core/connection/IEBusConnection.java index 6634b7f..c1e0303 100644 --- a/src/main/java/de/csdev/ebus/core/connection/IEBusConnection.java +++ b/src/main/java/de/csdev/ebus/core/connection/IEBusConnection.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.io.IOException; +import org.eclipse.jdt.annotation.NonNullByDefault; + /** * @author Christian Sowada - Initial contribution * */ +@NonNullByDefault public interface IEBusConnection { /** diff --git a/src/main/java/de/csdev/ebus/service/device/EBusDevice.java b/src/main/java/de/csdev/ebus/service/device/EBusDevice.java index b9df9a9..8dc4486 100644 --- a/src/main/java/de/csdev/ebus/service/device/EBusDevice.java +++ b/src/main/java/de/csdev/ebus/service/device/EBusDevice.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/service/device/EBusDeviceTable.java b/src/main/java/de/csdev/ebus/service/device/EBusDeviceTable.java index 5623114..43d7a30 100644 --- a/src/main/java/de/csdev/ebus/service/device/EBusDeviceTable.java +++ b/src/main/java/de/csdev/ebus/service/device/EBusDeviceTable.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 @@ -23,7 +23,6 @@ import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; -import org.apache.commons.lang3.ObjectUtils; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.slf4j.Logger; @@ -112,6 +111,7 @@ public String getManufacturerName(final byte vendorCode) { * @param address * @param data */ + @SuppressWarnings("java:S3776") public void updateDevice(final byte address, final Map<@NonNull String, @Nullable Object> data) { boolean newDevice = false; @@ -164,7 +164,7 @@ public void updateDevice(final byte address, final Map<@NonNull String, @Nullabl Object value = data.get("hardware_version"); if (value != null) { BigDecimal obj2 = NumberUtils.toBigDecimal(value); - if (obj2 != null && !ObjectUtils.equals(obj2, device.getHardwareVersion())) { + if (obj2 != null && !Objects.equals(obj2, device.getHardwareVersion())) { device.setHardwareVersion(obj2); updatedDevice = true; } @@ -173,7 +173,7 @@ public void updateDevice(final byte address, final Map<@NonNull String, @Nullabl value = data.get("software_version"); if (value != null) { BigDecimal obj2 = NumberUtils.toBigDecimal(value); - if (obj2 != null && !ObjectUtils.equals(obj2, device.getSoftwareVersion())) { + if (obj2 != null && !Objects.equals(obj2, device.getSoftwareVersion())) { device.setSoftwareVersion(obj2); updatedDevice = true; } @@ -182,7 +182,7 @@ public void updateDevice(final byte address, final Map<@NonNull String, @Nullabl value = data.get("vendor"); if (value != null) { BigDecimal obj2 = NumberUtils.toBigDecimal(value); - if (obj2 != null && !ObjectUtils.equals(obj2.byteValue(), device.getManufacturer())) { + if (obj2 != null && !Objects.equals(obj2.byteValue(), device.getManufacturer())) { int intValue = obj2.intValue(); device.setManufacturer((byte) intValue); updatedDevice = true; diff --git a/src/main/java/de/csdev/ebus/service/device/EBusDeviceTableService.java b/src/main/java/de/csdev/ebus/service/device/EBusDeviceTableService.java index 091be75..3a30077 100644 --- a/src/main/java/de/csdev/ebus/service/device/EBusDeviceTableService.java +++ b/src/main/java/de/csdev/ebus/service/device/EBusDeviceTableService.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 @@ -13,7 +13,6 @@ import java.util.Objects; import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,7 +35,6 @@ * @author Christian Sowada - Initial contribution * */ -@NonNullByDefault public class EBusDeviceTableService extends EBusConnectorEventListener implements IEBusParserListener, IEBusDeviceTableListener { diff --git a/src/main/java/de/csdev/ebus/service/device/IEBusDevice.java b/src/main/java/de/csdev/ebus/service/device/IEBusDevice.java index 247ec9a..9c9314c 100644 --- a/src/main/java/de/csdev/ebus/service/device/IEBusDevice.java +++ b/src/main/java/de/csdev/ebus/service/device/IEBusDevice.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/service/device/IEBusDeviceTableListener.java b/src/main/java/de/csdev/ebus/service/device/IEBusDeviceTableListener.java index 2072e57..5dbf2d2 100644 --- a/src/main/java/de/csdev/ebus/service/device/IEBusDeviceTableListener.java +++ b/src/main/java/de/csdev/ebus/service/device/IEBusDeviceTableListener.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/service/metrics/EBusMetricsService.java b/src/main/java/de/csdev/ebus/service/metrics/EBusMetricsService.java index b55fa71..57ca6b8 100644 --- a/src/main/java/de/csdev/ebus/service/metrics/EBusMetricsService.java +++ b/src/main/java/de/csdev/ebus/service/metrics/EBusMetricsService.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,23 +29,24 @@ */ @NonNullByDefault public class EBusMetricsService extends EBusConnectorEventListener implements IEBusParserListener { - + @SuppressWarnings({"null"}) private static final BigDecimal HUNDRED = BigDecimal.valueOf(100); - + @SuppressWarnings({"null"}) private BigDecimal resolved = BigDecimal.valueOf(0); - + @SuppressWarnings({"null"}) private BigDecimal unresolved = BigDecimal.valueOf(0); - + @SuppressWarnings({"null"}) private BigDecimal received = BigDecimal.valueOf(0); - + @SuppressWarnings({"null"}) private BigDecimal failed = BigDecimal.valueOf(0); - + @SuppressWarnings({"null"}) private BigDecimal connectionFailed = BigDecimal.valueOf(0); - + @SuppressWarnings({"null"}) private BigDecimal receivedAmount = BigDecimal.valueOf(0); private Map failedMap = new EnumMap<>(EBusError.class); + @SuppressWarnings({"null"}) public void clear() { resolved = BigDecimal.valueOf(0); unresolved = BigDecimal.valueOf(0); @@ -57,26 +58,30 @@ public void clear() { } @Override - public void onTelegramResolved(@NonNull IEBusCommandMethod commandChannel, - @NonNull Map<@NonNull String, @Nullable Object> result, byte @NonNull [] receivedData, + @SuppressWarnings({"null"}) + public void onTelegramResolved(IEBusCommandMethod commandChannel, + Map result, byte @NonNull [] receivedData, @Nullable Integer sendQueueId) { resolved = resolved.add(BigDecimal.ONE); } @Override + @SuppressWarnings({"null"}) public void onTelegramResolveFailed(@Nullable IEBusCommandMethod commandChannel, byte @Nullable [] receivedData, @Nullable Integer sendQueueId, @Nullable String exceptionMessage) { unresolved = unresolved.add(BigDecimal.ONE); } @Override - public void onTelegramReceived(byte @NonNull [] receivedData, @Nullable Integer sendQueueId) { + @SuppressWarnings({"null"}) + public void onTelegramReceived(byte[] receivedData, @Nullable Integer sendQueueId) { received = received.add(BigDecimal.ONE); receivedAmount = receivedAmount.add(BigDecimal.valueOf(receivedData.length)); } @Override - public void onTelegramException(@NonNull EBusDataException exception, @Nullable Integer sendQueueId) { + @SuppressWarnings({"null"}) + public void onTelegramException(EBusDataException exception, @Nullable Integer sendQueueId) { EBusError errorCode = exception.getErrorCode(); @@ -94,7 +99,8 @@ public void onTelegramException(@NonNull EBusDataException exception, @Nullable } @Override - public void onConnectionException(@NonNull Exception e) { + @SuppressWarnings({"null"}) + public void onConnectionException(Exception e) { connectionFailed = connectionFailed.add(BigDecimal.ONE); } @@ -122,6 +128,7 @@ public BigDecimal getConnectionFailed() { return connectionFailed; } + @SuppressWarnings({"null"}) public BigDecimal getFailureRatio() { BigDecimal all = received.add(failed); if (!failed.equals(BigDecimal.ZERO) && !all.equals(BigDecimal.ZERO)) { @@ -133,6 +140,7 @@ public BigDecimal getFailureRatio() { } } + @SuppressWarnings({"null"}) public BigDecimal getUnresolvedRatio() { BigDecimal all = unresolved.add(resolved); if (!unresolved.equals(BigDecimal.ZERO) && !all.equals(BigDecimal.ZERO)) { diff --git a/src/main/java/de/csdev/ebus/service/parser/EBusParserService.java b/src/main/java/de/csdev/ebus/service/parser/EBusParserService.java index b1b0d32..df0518a 100644 --- a/src/main/java/de/csdev/ebus/service/parser/EBusParserService.java +++ b/src/main/java/de/csdev/ebus/service/parser/EBusParserService.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/service/parser/IEBusParserListener.java b/src/main/java/de/csdev/ebus/service/parser/IEBusParserListener.java index d78584c..a17b770 100644 --- a/src/main/java/de/csdev/ebus/service/parser/IEBusParserListener.java +++ b/src/main/java/de/csdev/ebus/service/parser/IEBusParserListener.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/utils/CollectionUtils.java b/src/main/java/de/csdev/ebus/utils/CollectionUtils.java index 9381856..5ee4972 100644 --- a/src/main/java/de/csdev/ebus/utils/CollectionUtils.java +++ b/src/main/java/de/csdev/ebus/utils/CollectionUtils.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,6 +10,7 @@ import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; @@ -26,6 +27,10 @@ private CollectionUtils() { throw new IllegalStateException("Utility class"); } + public static final @NonNull List<@NonNull T> emptyList() { + return Objects.requireNonNull(Collections.emptyList()); + } + /** * A null checked variant of map.get * diff --git a/src/main/java/de/csdev/ebus/utils/CommonsUtils.java b/src/main/java/de/csdev/ebus/utils/CommonsUtils.java index 134207b..c01375d 100644 --- a/src/main/java/de/csdev/ebus/utils/CommonsUtils.java +++ b/src/main/java/de/csdev/ebus/utils/CommonsUtils.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/utils/EBusConsoleUtils.java b/src/main/java/de/csdev/ebus/utils/EBusConsoleUtils.java index 10fadae..8d432fa 100644 --- a/src/main/java/de/csdev/ebus/utils/EBusConsoleUtils.java +++ b/src/main/java/de/csdev/ebus/utils/EBusConsoleUtils.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 @@ -61,6 +61,7 @@ private EBusConsoleUtils() { * @return * @throws EBusTypeException */ + @SuppressWarnings("java:S3776") public static String bruteforceData(byte @Nullable [] data) throws EBusTypeException { EBusTypeRegistry typeRegistry = new EBusTypeRegistry(); @@ -117,16 +118,16 @@ public static String bruteforceData(byte @Nullable [] data) throws EBusTypeExcep StringBuilder sb = new StringBuilder(); - sb.append(String.format("%-25s | %-10s\n", "Successful received", service.getReceived())); - sb.append(String.format("%-25s | %-10s\n", "Failed received", service.getFailed())); - sb.append(String.format("%-25s | %-10s\n", "Successful/Failed ratio", service.getFailureRatio())); + sb.append(String.format("%-25s | %-10s%n", "Successful received", service.getReceived())); + sb.append(String.format("%-25s | %-10s%n", "Failed received", service.getFailed())); + sb.append(String.format("%-25s | %-10s%n", "Successful/Failed ratio", service.getFailureRatio())); sb.append("\n"); - sb.append(String.format("%-25s | %-10s\n", "Resolved telegrams", service.getResolved())); - sb.append(String.format("%-25s | %-10s\n", "Unresolved telegrams", service.getUnresolved())); - sb.append(String.format("%-25s | %-10s\n", "Resolved/Unresolved ratio", service.getUnresolvedRatio())); + sb.append(String.format("%-25s | %-10s%n", "Resolved telegrams", service.getResolved())); + sb.append(String.format("%-25s | %-10s%n", "Unresolved telegrams", service.getUnresolved())); + sb.append(String.format("%-25s | %-10s%n", "Resolved/Unresolved ratio", service.getUnresolvedRatio())); - return sb.toString(); + return Objects.requireNonNull(sb.toString()); } /** @@ -139,7 +140,7 @@ public static String getDeviceTableInformation(@NonNull Collection<@NonNull IEBu StringBuilder sb = new StringBuilder(); - Map mapping = new HashMap(); + Map mapping = new HashMap<>(); for (IEBusCommandCollection collection : collections) { for (String identification : collection.getIdentification()) { @@ -149,10 +150,10 @@ public static String getDeviceTableInformation(@NonNull Collection<@NonNull IEBu EBusDevice ownDevice = deviceTable.getOwnDevice(); - sb.append(String.format("%-2s | %-2s | %-14s | %-14s | %-25s | %-2s | %-10s | %-10s | %-20s\n", "MA", "SA", + sb.append(String.format("%-2s | %-2s | %-14s | %-14s | %-25s | %-2s | %-10s | %-10s | %-20s%n", "MA", "SA", "Identifier", "Device", "Manufacture", "ID", "Firmware", "Hardware", "Last Activity")); - sb.append(String.format("%-2s-+-%-2s-+-%-14s-+-%-14s-+-%-20s-+-%-2s-+-%-10s-+-%-10s-+-%-20s\n", + sb.append(String.format("%-2s-+-%-2s-+-%-14s-+-%-14s-+-%-20s-+-%-2s-+-%-10s-+-%-10s-+-%-20s%n", StringUtils.repeat("-", 2), StringUtils.repeat("-", 2), StringUtils.repeat("-", 14), StringUtils.repeat("-", 14), StringUtils.repeat("-", 20), StringUtils.repeat("-", 2), StringUtils.repeat("-", 10), StringUtils.repeat("-", 10), StringUtils.repeat("-", 20))); @@ -168,7 +169,7 @@ public static String getDeviceTableInformation(@NonNull Collection<@NonNull IEBu String deviceName = isBridge ? "" : mapping.getOrDefault(id, "---"); String manufacture = isBridge ? "eBUS Library" : device.getManufacturerName(); - sb.append(String.format("%-2s | %-2s | %-14s | %-14s | %-25s | %-2s | %-10s | %-10s | %-20s\n", + sb.append(String.format("%-2s | %-2s | %-14s | %-14s | %-25s | %-2s | %-10s | %-10s | %-20s%n", masterAddress, slaveAddress, id, deviceName, manufacture, EBusUtils.toHexDumpString(device.getManufacturer()), device.getSoftwareVersion(), device.getHardwareVersion(), activity)); @@ -188,6 +189,7 @@ public static String getDeviceTableInformation(@NonNull Collection<@NonNull IEBu * @param data * @return */ + @SuppressWarnings("java:S3776") public static @NonNull String analyzeTelegram(@NonNull EBusCommandRegistry registry, byte @NonNull [] data) { Objects.requireNonNull(registry, "registry"); @@ -217,7 +219,7 @@ public static String getDeviceTableInformation(@NonNull Collection<@NonNull IEBu sb.append(StringUtils.repeat("*", len) + "\n"); sb.append("\n"); - return sb.toString(); + return Objects.requireNonNull(sb.toString()); } sb.append("\n"); @@ -225,8 +227,8 @@ public static String getDeviceTableInformation(@NonNull Collection<@NonNull IEBu sb.append("***************************\n"); sb.append("\n"); - sb.append(String.format("Original data : %s\n", EBusUtils.toHexDumpString(data))); - sb.append(String.format("Unescaped data: %s\n", EBusUtils.toHexDumpString(edata))); + sb.append(String.format("Original data : %s%n", EBusUtils.toHexDumpString(data))); + sb.append(String.format("Unescaped data: %s%n", EBusUtils.toHexDumpString(edata))); byte[] command = Arrays.copyOfRange(edata, 2, 4); @@ -312,7 +314,7 @@ public static String getDeviceTableInformation(@NonNull Collection<@NonNull IEBu sb.append("Resolve the telegram\n"); sb.append("********************\n"); sb.append("\n"); - sb.append(String.format("Found %s command method(s) for this telegram.\n", methods.size())); + sb.append(String.format("Found %s command method(s) for this telegram.%n", methods.size())); sb.append("\n"); for (IEBusCommandMethod method : methods) { @@ -320,7 +322,7 @@ public static String getDeviceTableInformation(@NonNull Collection<@NonNull IEBu if (method != null) { Map result = EBusCommandUtils.decodeTelegram(method, data); - sb.append(String.format("Values from command '%s' with method '%s' from collection '%s'\n", + sb.append(String.format("Values from command '%s' with method '%s' from collection '%s'%n", method.getParent().getId(), method.getMethod(), method.getParent().getParentCollection().getId())); @@ -331,7 +333,7 @@ public static String getDeviceTableInformation(@NonNull Collection<@NonNull IEBu value = EBusUtils.toHexDumpString((byte[]) value); } - sb.append(String.format(" %-20s = %s\n", entry.getKey(), + sb.append(String.format(" %-20s = %s%n", entry.getKey(), value != null ? value.toString() : "NULL")); } } @@ -344,7 +346,7 @@ public static String getDeviceTableInformation(@NonNull Collection<@NonNull IEBu logger.error("error!", e); } - return sb.toString(); + return Objects.requireNonNull(sb.toString()); } @@ -359,6 +361,7 @@ public static String getDeviceTableInformation(@NonNull Collection<@NonNull IEBu return "Slave"; } + @SuppressWarnings({"null"}) private static @NonNull String hex(byte[] b) { return EBusUtils.toHexDumpString(b).toString(); @@ -385,6 +388,6 @@ public static String getDeviceTableInformation(@NonNull Collection<@NonNull IEBu sb.append(text); sb.append("\n"); - return sb.toString(); + return Objects.requireNonNull(sb.toString()); } } diff --git a/src/main/java/de/csdev/ebus/utils/EBusDateTime.java b/src/main/java/de/csdev/ebus/utils/EBusDateTime.java index 1d0dd85..8966ae0 100644 --- a/src/main/java/de/csdev/ebus/utils/EBusDateTime.java +++ b/src/main/java/de/csdev/ebus/utils/EBusDateTime.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,11 +11,15 @@ import java.text.SimpleDateFormat; import java.util.Calendar; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; + /** * * @author Christian Sowada - Initial contribution * */ +@NonNullByDefault public class EBusDateTime { private Calendar calendar; @@ -96,7 +100,7 @@ public int hashCode() { } @Override - public boolean equals(Object obj) { + public boolean equals(@Nullable Object obj) { if (this == obj) { return true; } diff --git a/src/main/java/de/csdev/ebus/utils/EBusTelegramWriter.java b/src/main/java/de/csdev/ebus/utils/EBusTelegramWriter.java index 1154a5b..bde0071 100644 --- a/src/main/java/de/csdev/ebus/utils/EBusTelegramWriter.java +++ b/src/main/java/de/csdev/ebus/utils/EBusTelegramWriter.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,13 +12,13 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; +import java.io.Writer; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date; import java.util.Map; -import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.slf4j.Logger; @@ -35,11 +35,12 @@ @NonNullByDefault public class EBusTelegramWriter implements IEBusParserListener { + @NonNullByDefault({}) private final Logger logger = LoggerFactory.getLogger(EBusTelegramWriter.class); - private BufferedWriter writerResolved; + private @Nullable BufferedWriter writerResolved; - private BufferedWriter writerUnresolved; + private @Nullable BufferedWriter writerUnresolved; private File loggingDirectory; @@ -48,8 +49,8 @@ public EBusTelegramWriter(File loggingDirectory) { } @Override - public void onTelegramResolved(@NonNull IEBusCommandMethod commandChannel, - @NonNull Map<@NonNull String, @Nullable Object> result, byte @NonNull [] receivedData, + public void onTelegramResolved(IEBusCommandMethod commandChannel, + Map result, byte[] receivedData, @Nullable Integer sendQueueId) { try { @@ -123,15 +124,17 @@ private BufferedWriter open(final String filename) throws IOException { */ public void close() { try { - if (writerResolved != null) { - writerResolved.flush(); - writerResolved.close(); - writerResolved = null; + Writer w = this.writerResolved; + if (w != null) { + w.flush(); + w.close(); + this.writerResolved = null; } - if (writerUnresolved != null) { - writerUnresolved.flush(); - writerUnresolved.close(); + w = this.writerUnresolved; + if (w != null) { + w.flush(); + w.close(); writerUnresolved = null; } @@ -140,7 +143,7 @@ public void close() { } } - private void write(final BufferedWriter writer, final byte[] receivedData, final @Nullable String comment) throws IOException { + private void write(final @Nullable BufferedWriter writer, final byte[] receivedData, final @Nullable String comment) throws IOException { DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = new Date(); @@ -168,6 +171,8 @@ private void write(final BufferedWriter writer, final byte[] receivedData, final sb.append("\n"); - writer.append(sb).flush(); + if (writer != null) { + writer.append(sb).flush(); + } } } diff --git a/src/main/java/de/csdev/ebus/utils/EBusUtils.java b/src/main/java/de/csdev/ebus/utils/EBusUtils.java index 7d1d0eb..db45306 100644 --- a/src/main/java/de/csdev/ebus/utils/EBusUtils.java +++ b/src/main/java/de/csdev/ebus/utils/EBusUtils.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.Objects; import org.apache.commons.lang3.StringUtils; -import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import de.csdev.ebus.core.EBusConsts; @@ -23,6 +23,7 @@ * @author Christian Sowada - Initial contribution * */ +@NonNullByDefault public class EBusUtils { private EBusUtils() { @@ -30,7 +31,7 @@ private EBusUtils() { } /** calculated crc values */ - protected static final byte CRC_TAB_8_VALUE[] = { (byte) 0x00, (byte) 0x9B, (byte) 0xAD, (byte) 0x36, (byte) 0xC1, + protected static final byte[] CRC_TAB_8_VALUE = { (byte) 0x00, (byte) 0x9B, (byte) 0xAD, (byte) 0x36, (byte) 0xC1, (byte) 0x5A, (byte) 0x6C, (byte) 0xF7, (byte) 0x19, (byte) 0x82, (byte) 0xB4, (byte) 0x2F, (byte) 0xD8, (byte) 0x43, (byte) 0x75, (byte) 0xEE, (byte) 0x32, (byte) 0xA9, (byte) 0x9F, (byte) 0x04, (byte) 0xF3, (byte) 0x68, (byte) 0x5E, (byte) 0xC5, (byte) 0x2B, (byte) 0xB0, (byte) 0x86, (byte) 0x1D, (byte) 0xEA, @@ -235,12 +236,11 @@ public static boolean isValidAddress(final byte address) { } /** - * FIXME: Badly programmed * * @param hexDumpString * @return */ - static public @Nullable Byte toByte(final String hexDumpString) { + public static @Nullable Byte toByte(final String hexDumpString) { if (StringUtils.isEmpty(hexDumpString)) { return null; } @@ -253,7 +253,7 @@ public static boolean isValidAddress(final byte address) { * @param buffer * @return */ - public static byte @NonNull [] toByteArray(@Nullable ByteBuffer buffer) { + public static byte[] toByteArray(@Nullable ByteBuffer buffer) { if (buffer == null) { return new byte[0]; @@ -281,7 +281,7 @@ public static boolean isValidAddress(final byte address) { * @param hexDumpString * @return */ - public static byte @NonNull [] toByteArray(final @Nullable String hexDumpString) throws NumberFormatException { + public static byte[] toByteArray(final @Nullable String hexDumpString) throws NumberFormatException { if (hexDumpString == null || StringUtils.isEmpty(hexDumpString)) { return new byte[0]; } @@ -303,7 +303,7 @@ public static boolean isValidAddress(final byte address) { * @param hexDumpString * @return */ - public static byte @NonNull [] toByteArray2(final @Nullable String hexDumpString) throws NumberFormatException { + public static byte[] toByteArray2(final @Nullable String hexDumpString) throws NumberFormatException { String h = hexDumpString; @@ -326,9 +326,9 @@ public static boolean isValidAddress(final byte address) { return result; } - public static @NonNull String mergeHexDumpStrings(final @Nullable String... args) { + public static String mergeHexDumpStrings(final @Nullable String... args) { - if (args == null) { + if (args.length == 0) { return ""; } @@ -349,7 +349,7 @@ public static boolean isValidAddress(final byte address) { * @param data The source * @return The hex string */ - public static @NonNull String toHexDumpString(final @Nullable Byte data) { + public static String toHexDumpString(final @Nullable Byte data) { if (data == null) { return ""; @@ -365,7 +365,7 @@ public static boolean isValidAddress(final byte address) { * @param data The source * @return The StringBuilder with hex dump */ - public static @NonNull StringBuilder toHexDumpString(final byte @Nullable [] data) { + public static StringBuilder toHexDumpString(final byte @Nullable [] data) { StringBuilder sb = new StringBuilder(); if (data != null && data.length > 0) { for (int i = 0; i < data.length; i++) { @@ -420,7 +420,7 @@ public static String toPrintHexDumpString(final @Nullable Byte data) { if (data != null) { return "0x" + String.format("%02X", (0xFF & data)); } - return null; + return ""; } /** diff --git a/src/main/java/de/csdev/ebus/utils/Emulator.java b/src/main/java/de/csdev/ebus/utils/Emulator.java index 594059a..a6b6b39 100644 --- a/src/main/java/de/csdev/ebus/utils/Emulator.java +++ b/src/main/java/de/csdev/ebus/utils/Emulator.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/utils/EmulatorCapture.java b/src/main/java/de/csdev/ebus/utils/EmulatorCapture.java index 033747b..4ed4b90 100644 --- a/src/main/java/de/csdev/ebus/utils/EmulatorCapture.java +++ b/src/main/java/de/csdev/ebus/utils/EmulatorCapture.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/utils/NumberUtils.java b/src/main/java/de/csdev/ebus/utils/NumberUtils.java index c1dc3a2..546ab2d 100644 --- a/src/main/java/de/csdev/ebus/utils/NumberUtils.java +++ b/src/main/java/de/csdev/ebus/utils/NumberUtils.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,6 +10,7 @@ import java.math.BigDecimal; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; /** @@ -18,6 +19,7 @@ * @author Christian Sowada - Initial contribution * */ +@NonNullByDefault public class NumberUtils { private NumberUtils() { diff --git a/src/test/java/de/csdev/ebus/StaticTestTelegrams.java b/src/test/java/de/csdev/ebus/StaticTestTelegrams.java index 85f652c..8346f1b 100644 --- a/src/test/java/de/csdev/ebus/StaticTestTelegrams.java +++ b/src/test/java/de/csdev/ebus/StaticTestTelegrams.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/test/java/de/csdev/ebus/TestUtils.java b/src/test/java/de/csdev/ebus/TestUtils.java index eee535d..fc964ed 100644 --- a/src/test/java/de/csdev/ebus/TestUtils.java +++ b/src/test/java/de/csdev/ebus/TestUtils.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/test/java/de/csdev/ebus/basic/EBusUtilsTest.java b/src/test/java/de/csdev/ebus/basic/EBusUtilsTest.java index c3f32c1..0897280 100644 --- a/src/test/java/de/csdev/ebus/basic/EBusUtilsTest.java +++ b/src/test/java/de/csdev/ebus/basic/EBusUtilsTest.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/test/java/de/csdev/ebus/cfg/BuildTelegramTest.java b/src/test/java/de/csdev/ebus/cfg/BuildTelegramTest.java index fded3c6..f8bab15 100644 --- a/src/test/java/de/csdev/ebus/cfg/BuildTelegramTest.java +++ b/src/test/java/de/csdev/ebus/cfg/BuildTelegramTest.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/test/java/de/csdev/ebus/cfg/EBusBitTypeTest.java b/src/test/java/de/csdev/ebus/cfg/EBusBitTypeTest.java index 716814d..a76af5f 100644 --- a/src/test/java/de/csdev/ebus/cfg/EBusBitTypeTest.java +++ b/src/test/java/de/csdev/ebus/cfg/EBusBitTypeTest.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/test/java/de/csdev/ebus/cfg/EBusCommonTelegramTest.java b/src/test/java/de/csdev/ebus/cfg/EBusCommonTelegramTest.java index 77a039c..70cfd24 100644 --- a/src/test/java/de/csdev/ebus/cfg/EBusCommonTelegramTest.java +++ b/src/test/java/de/csdev/ebus/cfg/EBusCommonTelegramTest.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/test/java/de/csdev/ebus/cfg/EBusConfigurationBundleTest.java b/src/test/java/de/csdev/ebus/cfg/EBusConfigurationBundleTest.java index cf0471c..07a86df 100644 --- a/src/test/java/de/csdev/ebus/cfg/EBusConfigurationBundleTest.java +++ b/src/test/java/de/csdev/ebus/cfg/EBusConfigurationBundleTest.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/test/java/de/csdev/ebus/cfg/EBusConfigurationHash.java b/src/test/java/de/csdev/ebus/cfg/EBusConfigurationHash.java index 47d5403..584e25a 100644 --- a/src/test/java/de/csdev/ebus/cfg/EBusConfigurationHash.java +++ b/src/test/java/de/csdev/ebus/cfg/EBusConfigurationHash.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/test/java/de/csdev/ebus/cfg/EBusConfigurationTest.java b/src/test/java/de/csdev/ebus/cfg/EBusConfigurationTest.java index 3199428..f598cb6 100644 --- a/src/test/java/de/csdev/ebus/cfg/EBusConfigurationTest.java +++ b/src/test/java/de/csdev/ebus/cfg/EBusConfigurationTest.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/test/java/de/csdev/ebus/cfg/EBusConsoleTest.java b/src/test/java/de/csdev/ebus/cfg/EBusConsoleTest.java index 1194a3e..bcab26e 100644 --- a/src/test/java/de/csdev/ebus/cfg/EBusConsoleTest.java +++ b/src/test/java/de/csdev/ebus/cfg/EBusConsoleTest.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/test/java/de/csdev/ebus/cfg/EBusNestedTemplatesTest.java b/src/test/java/de/csdev/ebus/cfg/EBusNestedTemplatesTest.java index e6307f8..6f9b552 100644 --- a/src/test/java/de/csdev/ebus/cfg/EBusNestedTemplatesTest.java +++ b/src/test/java/de/csdev/ebus/cfg/EBusNestedTemplatesTest.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/test/java/de/csdev/ebus/command/datatype/ReplaceValueTest.java b/src/test/java/de/csdev/ebus/command/datatype/ReplaceValueTest.java index f92586d..5694af8 100644 --- a/src/test/java/de/csdev/ebus/command/datatype/ReplaceValueTest.java +++ b/src/test/java/de/csdev/ebus/command/datatype/ReplaceValueTest.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/test/java/de/csdev/ebus/command/datatype/ext/CrcKWTest.java b/src/test/java/de/csdev/ebus/command/datatype/ext/CrcKWTest.java index 3310697..7fa1529 100644 --- a/src/test/java/de/csdev/ebus/command/datatype/ext/CrcKWTest.java +++ b/src/test/java/de/csdev/ebus/command/datatype/ext/CrcKWTest.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/test/java/de/csdev/ebus/command/datatype/ext/DateTest.java b/src/test/java/de/csdev/ebus/command/datatype/ext/DateTest.java index 7a55390..b253087 100644 --- a/src/test/java/de/csdev/ebus/command/datatype/ext/DateTest.java +++ b/src/test/java/de/csdev/ebus/command/datatype/ext/DateTest.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/test/java/de/csdev/ebus/command/datatype/ext/DateTimeTest.java b/src/test/java/de/csdev/ebus/command/datatype/ext/DateTimeTest.java index 6e9d26c..e9bb832 100644 --- a/src/test/java/de/csdev/ebus/command/datatype/ext/DateTimeTest.java +++ b/src/test/java/de/csdev/ebus/command/datatype/ext/DateTimeTest.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/test/java/de/csdev/ebus/command/datatype/ext/FloatTest.java b/src/test/java/de/csdev/ebus/command/datatype/ext/FloatTest.java index c91379d..95cfddf 100644 --- a/src/test/java/de/csdev/ebus/command/datatype/ext/FloatTest.java +++ b/src/test/java/de/csdev/ebus/command/datatype/ext/FloatTest.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/test/java/de/csdev/ebus/command/datatype/ext/MultiWordTest.java b/src/test/java/de/csdev/ebus/command/datatype/ext/MultiWordTest.java index e5157f8..e40e0b8 100644 --- a/src/test/java/de/csdev/ebus/command/datatype/ext/MultiWordTest.java +++ b/src/test/java/de/csdev/ebus/command/datatype/ext/MultiWordTest.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/test/java/de/csdev/ebus/command/datatype/ext/StringTest.java b/src/test/java/de/csdev/ebus/command/datatype/ext/StringTest.java index b8d9e44..54cf247 100644 --- a/src/test/java/de/csdev/ebus/command/datatype/ext/StringTest.java +++ b/src/test/java/de/csdev/ebus/command/datatype/ext/StringTest.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/test/java/de/csdev/ebus/command/datatype/ext/TimeTest.java b/src/test/java/de/csdev/ebus/command/datatype/ext/TimeTest.java index 71635e7..7814beb 100644 --- a/src/test/java/de/csdev/ebus/command/datatype/ext/TimeTest.java +++ b/src/test/java/de/csdev/ebus/command/datatype/ext/TimeTest.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/test/java/de/csdev/ebus/command/datatype/ext/VersionTest.java b/src/test/java/de/csdev/ebus/command/datatype/ext/VersionTest.java index 01bf38a..7643280 100644 --- a/src/test/java/de/csdev/ebus/command/datatype/ext/VersionTest.java +++ b/src/test/java/de/csdev/ebus/command/datatype/ext/VersionTest.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/test/java/de/csdev/ebus/command/datatype/std/BCDTest.java b/src/test/java/de/csdev/ebus/command/datatype/std/BCDTest.java index ca0b2a4..067db13 100644 --- a/src/test/java/de/csdev/ebus/command/datatype/std/BCDTest.java +++ b/src/test/java/de/csdev/ebus/command/datatype/std/BCDTest.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/test/java/de/csdev/ebus/command/datatype/std/BitTest.java b/src/test/java/de/csdev/ebus/command/datatype/std/BitTest.java index 3fa9011..02ac0c4 100644 --- a/src/test/java/de/csdev/ebus/command/datatype/std/BitTest.java +++ b/src/test/java/de/csdev/ebus/command/datatype/std/BitTest.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/test/java/de/csdev/ebus/command/datatype/std/ByteTest.java b/src/test/java/de/csdev/ebus/command/datatype/std/ByteTest.java index 059065d..3644987 100644 --- a/src/test/java/de/csdev/ebus/command/datatype/std/ByteTest.java +++ b/src/test/java/de/csdev/ebus/command/datatype/std/ByteTest.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/test/java/de/csdev/ebus/command/datatype/std/CharTest.java b/src/test/java/de/csdev/ebus/command/datatype/std/CharTest.java index 667e474..4c3ae9f 100644 --- a/src/test/java/de/csdev/ebus/command/datatype/std/CharTest.java +++ b/src/test/java/de/csdev/ebus/command/datatype/std/CharTest.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/test/java/de/csdev/ebus/command/datatype/std/Data1bTest.java b/src/test/java/de/csdev/ebus/command/datatype/std/Data1bTest.java index 7769680..6d3df13 100644 --- a/src/test/java/de/csdev/ebus/command/datatype/std/Data1bTest.java +++ b/src/test/java/de/csdev/ebus/command/datatype/std/Data1bTest.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/test/java/de/csdev/ebus/command/datatype/std/Data1cTest.java b/src/test/java/de/csdev/ebus/command/datatype/std/Data1cTest.java index 181f82f..e3e53b7 100644 --- a/src/test/java/de/csdev/ebus/command/datatype/std/Data1cTest.java +++ b/src/test/java/de/csdev/ebus/command/datatype/std/Data1cTest.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/test/java/de/csdev/ebus/command/datatype/std/Data2bTest.java b/src/test/java/de/csdev/ebus/command/datatype/std/Data2bTest.java index d6a2084..8a28d34 100644 --- a/src/test/java/de/csdev/ebus/command/datatype/std/Data2bTest.java +++ b/src/test/java/de/csdev/ebus/command/datatype/std/Data2bTest.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/test/java/de/csdev/ebus/command/datatype/std/Data2cTest.java b/src/test/java/de/csdev/ebus/command/datatype/std/Data2cTest.java index 33098cb..d9405d8 100644 --- a/src/test/java/de/csdev/ebus/command/datatype/std/Data2cTest.java +++ b/src/test/java/de/csdev/ebus/command/datatype/std/Data2cTest.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/test/java/de/csdev/ebus/command/datatype/std/IntegerTest.java b/src/test/java/de/csdev/ebus/command/datatype/std/IntegerTest.java index 26d5ef2..9a48882 100644 --- a/src/test/java/de/csdev/ebus/command/datatype/std/IntegerTest.java +++ b/src/test/java/de/csdev/ebus/command/datatype/std/IntegerTest.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/test/java/de/csdev/ebus/command/datatype/std/UCharTest.java b/src/test/java/de/csdev/ebus/command/datatype/std/UCharTest.java index e8045dc..9f4754e 100644 --- a/src/test/java/de/csdev/ebus/command/datatype/std/UCharTest.java +++ b/src/test/java/de/csdev/ebus/command/datatype/std/UCharTest.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/test/java/de/csdev/ebus/command/datatype/std/WordTest.java b/src/test/java/de/csdev/ebus/command/datatype/std/WordTest.java index d8b25f7..b08985a 100644 --- a/src/test/java/de/csdev/ebus/command/datatype/std/WordTest.java +++ b/src/test/java/de/csdev/ebus/command/datatype/std/WordTest.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/test/java/de/csdev/ebus/core/EBusControllerTest.java b/src/test/java/de/csdev/ebus/core/EBusControllerTest.java index 352fb38..7ad486b 100644 --- a/src/test/java/de/csdev/ebus/core/EBusControllerTest.java +++ b/src/test/java/de/csdev/ebus/core/EBusControllerTest.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/test/java/de/csdev/ebus/core/EBusStateMachineTest.java b/src/test/java/de/csdev/ebus/core/EBusStateMachineTest.java index 2e0475e..35c30a2 100644 --- a/src/test/java/de/csdev/ebus/core/EBusStateMachineTest.java +++ b/src/test/java/de/csdev/ebus/core/EBusStateMachineTest.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/test/java/de/csdev/ebus/core/EBusVersionTest.java b/src/test/java/de/csdev/ebus/core/EBusVersionTest.java index ddcb244..690e91f 100644 --- a/src/test/java/de/csdev/ebus/core/EBusVersionTest.java +++ b/src/test/java/de/csdev/ebus/core/EBusVersionTest.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/test/java/de/csdev/ebus/service/device/DeviceTableTests.java b/src/test/java/de/csdev/ebus/service/device/DeviceTableTests.java index f192082..bc45183 100644 --- a/src/test/java/de/csdev/ebus/service/device/DeviceTableTests.java +++ b/src/test/java/de/csdev/ebus/service/device/DeviceTableTests.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/test/java/de/csdev/ebus/service/metrics/MetricsTest.java b/src/test/java/de/csdev/ebus/service/metrics/MetricsTest.java index 5665605..8951714 100644 --- a/src/test/java/de/csdev/ebus/service/metrics/MetricsTest.java +++ b/src/test/java/de/csdev/ebus/service/metrics/MetricsTest.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/test/java/de/csdev/ebus/wip/ClientTest.java b/src/test/java/de/csdev/ebus/wip/ClientTest.java index 6f7dba2..2560d38 100644 --- a/src/test/java/de/csdev/ebus/wip/ClientTest.java +++ b/src/test/java/de/csdev/ebus/wip/ClientTest.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/test/java/de/csdev/ebus/wip/ClientTest2.java b/src/test/java/de/csdev/ebus/wip/ClientTest2.java index 08f29ab..4099115 100644 --- a/src/test/java/de/csdev/ebus/wip/ClientTest2.java +++ b/src/test/java/de/csdev/ebus/wip/ClientTest2.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/test/java/de/csdev/ebus/wip/ClientTest3.java b/src/test/java/de/csdev/ebus/wip/ClientTest3.java index b42a567..2b4151a 100644 --- a/src/test/java/de/csdev/ebus/wip/ClientTest3.java +++ b/src/test/java/de/csdev/ebus/wip/ClientTest3.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/test/java/de/csdev/ebus/wip/ConfigurationReaderTest.java b/src/test/java/de/csdev/ebus/wip/ConfigurationReaderTest.java index f740b3e..bdd5aa8 100644 --- a/src/test/java/de/csdev/ebus/wip/ConfigurationReaderTest.java +++ b/src/test/java/de/csdev/ebus/wip/ConfigurationReaderTest.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/test/java/de/csdev/ebus/wip/EBusConfigurationTemplateTest.java b/src/test/java/de/csdev/ebus/wip/EBusConfigurationTemplateTest.java index a5ba737..f5ecf30 100644 --- a/src/test/java/de/csdev/ebus/wip/EBusConfigurationTemplateTest.java +++ b/src/test/java/de/csdev/ebus/wip/EBusConfigurationTemplateTest.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/test/java/de/csdev/ebus/wip/EBusCustomParserTest.java b/src/test/java/de/csdev/ebus/wip/EBusCustomParserTest.java index c5d3178..29002d6 100644 --- a/src/test/java/de/csdev/ebus/wip/EBusCustomParserTest.java +++ b/src/test/java/de/csdev/ebus/wip/EBusCustomParserTest.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/test/java/de/csdev/ebus/wip/EBusVaillantBAI00TelegramTest.java b/src/test/java/de/csdev/ebus/wip/EBusVaillantBAI00TelegramTest.java index 7a27d0a..2320dc4 100644 --- a/src/test/java/de/csdev/ebus/wip/EBusVaillantBAI00TelegramTest.java +++ b/src/test/java/de/csdev/ebus/wip/EBusVaillantBAI00TelegramTest.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/test/java/de/csdev/ebus/wip/EBusWolfSM1TelegramTest2XXX.java b/src/test/java/de/csdev/ebus/wip/EBusWolfSM1TelegramTest2XXX.java index c72e6e2..04ff510 100644 --- a/src/test/java/de/csdev/ebus/wip/EBusWolfSM1TelegramTest2XXX.java +++ b/src/test/java/de/csdev/ebus/wip/EBusWolfSM1TelegramTest2XXX.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/test/java/de/csdev/ebus/wip/EBusdControllerTest.java b/src/test/java/de/csdev/ebus/wip/EBusdControllerTest.java index 95c6f3d..e931bc1 100644 --- a/src/test/java/de/csdev/ebus/wip/EBusdControllerTest.java +++ b/src/test/java/de/csdev/ebus/wip/EBusdControllerTest.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/test/java/de/csdev/ebus/wip/EmulatorTest.java b/src/test/java/de/csdev/ebus/wip/EmulatorTest.java index 8acafbd..cdcea3e 100644 --- a/src/test/java/de/csdev/ebus/wip/EmulatorTest.java +++ b/src/test/java/de/csdev/ebus/wip/EmulatorTest.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