diff --git a/.classpath b/.classpath
index 1fca90e..075b839 100644
--- a/.classpath
+++ b/.classpath
@@ -21,11 +21,14 @@
+
+
+
diff --git a/.project b/.project
index eefcc95..086bdba 100644
--- a/.project
+++ b/.project
@@ -18,7 +18,6 @@
org.eclipse.m2e.core.maven2Nature
- org.eclipse.pde.PluginNature
org.eclipse.jdt.core.javanature
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
index fd53e3b..c809b82 100644
--- a/.settings/org.eclipse.jdt.core.prefs
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -7,7 +7,7 @@ org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annota
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary=
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
-org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
+org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
@@ -16,6 +16,8 @@ org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.APILeak=warning
+org.eclipse.jdt.core.compiler.problem.annotatedTypeArgumentToUnannotated=info
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
@@ -56,14 +58,14 @@ org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
-org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.nullReference=error
org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=error
org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
@@ -77,8 +79,10 @@ org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
+org.eclipse.jdt.core.compiler.problem.suppressWarningsNotFullyAnalysed=info
+org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=enabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
@@ -91,6 +95,7 @@ org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName=warning
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
@@ -108,5 +113,5 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.release=disabled
+org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=1.8
diff --git a/annotations/java/lang/Class.eea b/annotations/java/lang/Class.eea
new file mode 100644
index 0000000..b39b5e1
--- /dev/null
+++ b/annotations/java/lang/Class.eea
@@ -0,0 +1,4 @@
+class java/lang/Class
+getResource
+ (Ljava/lang/String;)Ljava/net/URL;
+ (Ljava/lang/String;)L0java/net/URL;
diff --git a/annotations/java/lang/String.eea b/annotations/java/lang/String.eea
new file mode 100644
index 0000000..50c4bcb
--- /dev/null
+++ b/annotations/java/lang/String.eea
@@ -0,0 +1,4 @@
+class java/lang/String
+format
+ (Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
+ (Ljava/lang/String;[Ljava/lang/Object;)L1java/lang/String;
diff --git a/annotations/java/lang/StringBuilder.eea b/annotations/java/lang/StringBuilder.eea
new file mode 100644
index 0000000..7b45488
--- /dev/null
+++ b/annotations/java/lang/StringBuilder.eea
@@ -0,0 +1,4 @@
+class java/lang/StringBuilder
+toString
+ ()Ljava/lang/String;
+ ()L1java/lang/String;
diff --git a/annotations/java/lang/reflect/Field.eea b/annotations/java/lang/reflect/Field.eea
new file mode 100644
index 0000000..44da91c
--- /dev/null
+++ b/annotations/java/lang/reflect/Field.eea
@@ -0,0 +1,4 @@
+class java/lang/reflect/Field
+getAnnotation
+ (Ljava/lang/Class;)TT;
+ (Ljava/lang/Class;)T0T;
diff --git a/annotations/java/math/BigDecimal.eea b/annotations/java/math/BigDecimal.eea
new file mode 100644
index 0000000..2eb31be
--- /dev/null
+++ b/annotations/java/math/BigDecimal.eea
@@ -0,0 +1,13 @@
+class java/math/BigDecimal
+ZERO
+ Ljava/math/BigDecimal;
+ L1java/math/BigDecimal;
+add
+ (Ljava/math/BigDecimal;)Ljava/math/BigDecimal;
+ (Ljava/math/BigDecimal;)L1java/math/BigDecimal;
+setScale
+ (ILjava/math/RoundingMode;)Ljava/math/BigDecimal;
+ (ILjava/math/RoundingMode;)L1java/math/BigDecimal;
+valueOf
+ (J)Ljava/math/BigDecimal;
+ (J)L1java/math/BigDecimal;
diff --git a/annotations/java/util/Collections.eea b/annotations/java/util/Collections.eea
new file mode 100644
index 0000000..90e6e0c
--- /dev/null
+++ b/annotations/java/util/Collections.eea
@@ -0,0 +1,10 @@
+class java/util/Collections
+emptyMap
+ ()Ljava/util/Map;
+ ()L1java/util/Map;
+unmodifiableCollection
+ (Ljava/util/Collection<+TT;>;)Ljava/util/Collection;
+ (Ljava/util/Collection<+TT;>;)L1java/util/Collection;
+unmodifiableMap
+ (Ljava/util/Map<+TK;+TV;>;)Ljava/util/Map;
+ (Ljava/util/Map<+TK;+TV;>;)L1java/util/Map;
diff --git a/annotations/java/util/Objects.eea b/annotations/java/util/Objects.eea
new file mode 100644
index 0000000..6631c1a
--- /dev/null
+++ b/annotations/java/util/Objects.eea
@@ -0,0 +1,4 @@
+class java/util/Objects
+requireNonNull
+ (TT;)TT;
+ <1T:Ljava/lang/Object;>(TT;)T1T;
diff --git a/annotations/org/slf4j/LoggerFactory.eea b/annotations/org/slf4j/LoggerFactory.eea
new file mode 100644
index 0000000..5676819
--- /dev/null
+++ b/annotations/org/slf4j/LoggerFactory.eea
@@ -0,0 +1,4 @@
+class org/slf4j/LoggerFactory
+getLogger
+ (Ljava/lang/Class<*>;)Lorg/slf4j/Logger;
+ (Ljava/lang/Class<*>;)L1org/slf4j/Logger;
diff --git a/pom.xml b/pom.xml
index 1f9137f..25d5fe9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,18 +7,19 @@
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.0.8-SNAPSHOT
+ 1.1.0
https://github.com/csowada/ebus
bundle
-
- yyyyMMddHHmm
- UTF-8
- 1.8
- 1.8
- 2020
- 1.0.8.${maven.build.timestamp}
-
+
+ yyyyMMddHHmm
+ UTF-8
+ 1.8
+ 1.8
+ 8
+ 2020
+ 1.1.0.${maven.build.timestamp}
+
Christian Sowada
@@ -91,8 +92,8 @@
${bundle.version}
de.csdev.ebus.*
resolution:=optional
- org.slf4j;$[opt], com.fazecast.jSerialComm;$[opt], gnu.io;$[opt], *
-
+ org.slf4j;$[opt], com.fazecast.jSerialComm;$[opt], gnu.io;$[opt], org.eclipse.jdt.annotation;$[opt], *
+
${maven.build.timestamp}
${buildNumber}
${scmBranch}
@@ -248,24 +249,28 @@
org.slf4j
slf4j-api
1.7.25
+ provided
commons-io
commons-io
2.2
+ provided
commons-lang
commons-lang
2.6
+ provided
com.neuronrobotics
nrjavaserial
3.12.1
+ provided
true
@@ -273,6 +278,7 @@
com.fazecast
jSerialComm
2.5.3
+ provided
true
@@ -280,6 +286,14 @@
com.google.code.gson
gson
2.5
+ provided
+
+
+
+ org.eclipse.jdt
+ org.eclipse.jdt.annotation
+ 2.2.600
+ provided
diff --git a/src/main/java/de/csdev/ebus/cfg/IEBusConfigurationProvider.java b/src/main/java/de/csdev/ebus/cfg/IEBusConfigurationProvider.java
index 97f10c8..c277a1c 100644
--- a/src/main/java/de/csdev/ebus/cfg/IEBusConfigurationProvider.java
+++ b/src/main/java/de/csdev/ebus/cfg/IEBusConfigurationProvider.java
@@ -11,16 +11,20 @@
import java.io.InputStream;
import java.util.List;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+
/**
* @author Christian Sowada - Initial contribution
*
*/
+@NonNullByDefault
public interface IEBusConfigurationProvider {
/**
* Returns a list with all configuration ids
*
- * @return
+ * @return Returns a list with all configuration ids
*/
public List getConfigurationIds();
@@ -28,16 +32,16 @@ public interface IEBusConfigurationProvider {
* Returns a configuration label for an id or null if not existent.
*
* @param configurationId
- * @return
+ * @return Returns a configuration label for an id or null if not existent.
*/
- public String getConfigurationLabel(String configurationId);
+ public @Nullable String getConfigurationLabel(String configurationId);
/**
* Returns the input stream for a configuration id or null if not existent.
- *
+ *
* @param configurationId
- * @return
+ * @return Returns the input stream for a configuration id or null if not existent.
*/
- public InputStream getConfigurationStream(String configurationId);
+ public @Nullable InputStream getConfigurationStream(String configurationId);
}
\ No newline at end of file
diff --git a/src/main/java/de/csdev/ebus/cfg/IEBusConfigurationReader.java b/src/main/java/de/csdev/ebus/cfg/IEBusConfigurationReader.java
index 63b853a..1dab598 100644
--- a/src/main/java/de/csdev/ebus/cfg/IEBusConfigurationReader.java
+++ b/src/main/java/de/csdev/ebus/cfg/IEBusConfigurationReader.java
@@ -12,6 +12,9 @@
import java.net.URL;
import java.util.List;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+
import de.csdev.ebus.command.IEBusCommandCollection;
import de.csdev.ebus.command.datatypes.EBusTypeRegistry;
@@ -19,6 +22,7 @@
* @author Christian Sowada - Initial contribution
*
*/
+@NonNullByDefault
public interface IEBusConfigurationReader {
/**
@@ -36,7 +40,7 @@ public interface IEBusConfigurationReader {
* @throws EBusConfigurationReaderException
* @throws IOException
*/
- public IEBusCommandCollection loadConfigurationCollection(URL url)
+ public @Nullable IEBusCommandCollection loadConfigurationCollection(URL url)
throws EBusConfigurationReaderException, IOException;
/**
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 bef0f7b..9a1655d 100644
--- a/src/main/java/de/csdev/ebus/cfg/std/EBusConfigurationReader.java
+++ b/src/main/java/de/csdev/ebus/cfg/std/EBusConfigurationReader.java
@@ -21,8 +21,11 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import org.apache.commons.lang.StringUtils;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -48,6 +51,7 @@
import de.csdev.ebus.command.IEBusCommandCollection;
import de.csdev.ebus.command.IEBusCommandMethod;
import de.csdev.ebus.command.IEBusCommandMethod.Method;
+import de.csdev.ebus.command.datatypes.EBusTypeException;
import de.csdev.ebus.command.datatypes.EBusTypeRegistry;
import de.csdev.ebus.command.datatypes.IEBusType;
import de.csdev.ebus.command.datatypes.ext.EBusTypeBytes;
@@ -63,10 +67,18 @@ public class EBusConfigurationReader implements IEBusConfigurationReader {
private final Logger logger = LoggerFactory.getLogger(EBusConfigurationReader.class);
- private EBusTypeRegistry registry;
+ private @NonNull EBusTypeRegistry registry;
- private Map> templateValueRegistry = new HashMap>();
- private Map> templateBlockRegistry = new HashMap>();
+ private @NonNull Map<@NonNull String, @Nullable Collection<@NonNull EBusCommandValue>> templateValueRegistry = new HashMap<@NonNull String, @Nullable Collection<@NonNull EBusCommandValue>>();
+ private @NonNull Map<@NonNull String, @Nullable Collection<@NonNull EBusCommandValue>> templateBlockRegistry = new HashMap<@NonNull String, @Nullable Collection<@NonNull EBusCommandValue>>();
+
+ public EBusConfigurationReader() {
+ try {
+ this.registry = new EBusTypeRegistry();
+ } catch (EBusTypeException e) {
+ throw new IllegalStateException("Unable to create a new eBus type registry!");
+ }
+ }
/*
* (non-Javadoc)
@@ -74,9 +86,12 @@ public class EBusConfigurationReader implements IEBusConfigurationReader {
* @see de.csdev.ebus.cfg.IEBusConfigurationReader#loadBuildInConfigurations()
*/
@Override
- public List loadBuildInConfigurationCollections() {
- return loadConfigurationCollectionBundle(
- EBusConfigurationReader.class.getResource("/index-configuration.json"));
+ public @NonNull List<@NonNull IEBusCommandCollection> loadBuildInConfigurationCollections() {
+
+ URL url = EBusConfigurationReader.class.getResource("/index-configuration.json");
+ Objects.requireNonNull(url);
+
+ return loadConfigurationCollectionBundle(url);
}
/*
@@ -85,16 +100,10 @@ public List loadBuildInConfigurationCollections() {
* @see de.csdev.ebus.cfg.IEBusConfigurationReader#loadConfigurationCollection(java.io.InputStream)
*/
@Override
- public IEBusCommandCollection loadConfigurationCollection(URL url)
+ public @NonNull IEBusCommandCollection loadConfigurationCollection(@NonNull URL url)
throws IOException, EBusConfigurationReaderException {
- if (registry == null) {
- throw new RuntimeException("Unable to load configuration without EBusType set!");
- }
-
- if (url == null) {
- throw new IllegalArgumentException("Required argument url is null!");
- }
+ Objects.requireNonNull(url, "url");
Type merchantListType = new TypeToken>() {
}.getType();
@@ -113,7 +122,8 @@ public IEBusCommandCollection loadConfigurationCollection(URL url)
// collect md5 hash while reading file
DigestInputStream dis = new DigestInputStream(url.openStream(), md);
- EBusCollectionDTO collection = gson.fromJson(new InputStreamReader(dis), EBusCollectionDTO.class);
+ EBusCollectionDTO collection = Objects
+ .requireNonNull(gson.fromJson(new InputStreamReader(dis), EBusCollectionDTO.class));
EBusCommandCollection commandCollection = (EBusCommandCollection) loadConfigurationCollection(collection);
@@ -123,22 +133,23 @@ public IEBusCommandCollection loadConfigurationCollection(URL url)
return commandCollection;
}
- public IEBusCommandCollection loadConfigurationCollection(EBusCollectionDTO collection)
+ public @NonNull IEBusCommandCollection loadConfigurationCollection(@NonNull EBusCollectionDTO collection)
throws EBusConfigurationReaderException {
- // EBusCollectionDTO collection = gson.fromJson(new InputStreamReader(dis), EBusCollectionDTO.class);
+
+ Objects.requireNonNull(collection, "collection");
EBusCommandCollection commandCollection = new EBusCommandCollection(collection.getId(), collection.getLabel(),
collection.getDescription(), collection.getProperties());
// add md5 hash
- // commandCollection.setSourceHash(md.digest());
commandCollection.setIdentification(collection.getIdentification());
// parse the template block
parseTemplateConfiguration(collection);
- if (collection.getCommands() != null) {
- for (EBusCommandDTO commandDto : collection.getCommands()) {
+ List commands = collection.getCommands();
+ if (commands != null) {
+ for (EBusCommandDTO commandDto : commands) {
if (commandDto != null) {
commandCollection.addCommand(parseTelegramConfiguration(commandCollection, commandDto));
}
@@ -148,7 +159,10 @@ public IEBusCommandCollection loadConfigurationCollection(EBusCollectionDTO coll
return commandCollection;
}
- protected void parseTemplateConfiguration(EBusCollectionDTO collection) throws EBusConfigurationReaderException {
+ protected void parseTemplateConfiguration(@NonNull EBusCollectionDTO collection)
+ throws EBusConfigurationReaderException {
+
+ Objects.requireNonNull(collection, "collection");
// extract templates
List templateSection = collection.getTemplates();
@@ -160,21 +174,27 @@ protected void parseTemplateConfiguration(EBusCollectionDTO collection) throws E
Collection blockList = new ArrayList();
for (EBusValueDTO value : templateValues) {
+ if (value != null) {
+ Collection<@NonNull EBusCommandValue> pv = parseValueConfiguration(value, null, null, null);
- Collection pv = parseValueConfiguration(value, null, null, null);
- blockList.addAll(pv);
+ if (pv != null && !pv.isEmpty()) {
+ blockList.addAll(pv);
- // global id
- String id = collection.getId() + "." + templates.getName() + "." + value.getName();
- logger.trace("Add template with global id {} to registry ...", id);
- templateValueRegistry.put(id, pv);
+ // global id
+ String id = collection.getId() + "." + templates.getName() + "." + value.getName();
+ logger.trace("Add template with global id {} to registry ...", id);
+ templateValueRegistry.put(id, pv);
+ }
+ }
}
- String id = collection.getId() + "." + templates.getName();
+ if (!blockList.isEmpty()) {
+ String id = collection.getId() + "." + templates.getName();
- // global id
- logger.trace("Add template block with global id {} to registry ...", id);
- templateBlockRegistry.put(id, blockList);
+ // global id
+ logger.trace("Add template block with global id {} to registry ...", id);
+ templateBlockRegistry.put(id, blockList);
+ }
}
}
}
@@ -186,12 +206,10 @@ protected void parseTemplateConfiguration(EBusCollectionDTO collection) throws E
* @return
* @throws EBusConfigurationReaderException
*/
- protected EBusCommand parseTelegramConfiguration(IEBusCommandCollection commandCollection,
- EBusCommandDTO commandElement) throws EBusConfigurationReaderException {
+ protected EBusCommand parseTelegramConfiguration(@NonNull IEBusCommandCollection commandCollection,
+ @NonNull EBusCommandDTO commandElement) throws EBusConfigurationReaderException {
- if (commandElement == null) {
- throw new IllegalArgumentException("Parameter \"command dto\" not set!");
- }
+ Objects.requireNonNull(commandCollection, "commandCollection");
LinkedHashMap templateMap = new LinkedHashMap();
ArrayList templateList = new ArrayList();
@@ -217,18 +235,26 @@ protected EBusCommand parseTelegramConfiguration(IEBusCommandCollection commandC
Byte source = EBusUtils.toByte(commandElement.getSrc());
// read in template block
- if (commandElement.getTemplate() != null) {
- for (EBusValueDTO template : commandElement.getTemplate()) {
- for (EBusCommandValue templateCfg : parseValueConfiguration(template, null, null, null)) {
- if (StringUtils.isEmpty(templateCfg.getName())) {
- templateMap.put(templateCfg.getName(), templateCfg);
- }
+ List templates = commandElement.getTemplate();
+ if (templates != null) {
+ for (EBusValueDTO template : templates) {
+ if (template != null) {
+ for (EBusCommandValue templateCfg : parseValueConfiguration(template, null, null, null)) {
+ if (StringUtils.isEmpty(templateCfg.getName())) {
+ templateMap.put(templateCfg.getName(), templateCfg);
+ }
- templateList.add(templateCfg);
+ templateList.add(templateCfg);
+ }
}
}
}
+ if (id == null) {
+ throw new EBusConfigurationReaderException("Property 'id' is missing for command ! {0}",
+ commandElement != null ? commandElement.toString() : "");
+ }
+
EBusCommand cfg = new EBusCommand();
cfg.setId(id);
cfg.setLabel(label);
@@ -269,20 +295,26 @@ protected EBusCommand parseTelegramConfiguration(IEBusCommandCollection commandC
commandMethod.setDestinationAddress(destination);
commandMethod.setSourceAddress(source);
- if (commandMethodElement.getMaster() != null) {
- for (EBusValueDTO template : commandMethodElement.getMaster()) {
- for (EBusCommandValue ev : parseValueConfiguration(template, templateMap, templateList,
- commandMethod)) {
- commandMethod.addMasterValue(ev);
+ List master = commandMethodElement.getMaster();
+ if (master != null) {
+ for (EBusValueDTO template : master) {
+ if (template != null) {
+ for (EBusCommandValue ev : parseValueConfiguration(template, templateMap, templateList,
+ commandMethod)) {
+ commandMethod.addMasterValue(ev);
+ }
}
}
}
- if (commandMethodElement.getSlave() != null) {
- for (EBusValueDTO template : commandMethodElement.getSlave()) {
- for (EBusCommandValue ev : parseValueConfiguration(template, templateMap, templateList,
- commandMethod)) {
- commandMethod.addSlaveValue(ev);
+ List slave = commandMethodElement.getSlave();
+ if (slave != null) {
+ for (EBusValueDTO template : slave) {
+ if (template != null) {
+ for (EBusCommandValue ev : parseValueConfiguration(template, templateMap, templateList,
+ commandMethod)) {
+ commandMethod.addSlaveValue(ev);
+ }
}
}
}
@@ -318,11 +350,14 @@ protected EBusCommand parseTelegramConfiguration(IEBusCommandCollection commandC
* @return
* @throws EBusConfigurationReaderException
*/
- protected Collection parseValueConfiguration(EBusValueDTO valueDto,
- Map templateMap, List templateList,
- EBusCommandMethod commandMethod) throws EBusConfigurationReaderException {
+ protected @NonNull Collection<@NonNull EBusCommandValue> parseValueConfiguration(@NonNull EBusValueDTO valueDto,
+ @Nullable Map<@NonNull String, @NonNull EBusCommandValue> templateMap,
+ @Nullable List<@NonNull EBusCommandValue> templateList, @Nullable EBusCommandMethod commandMethod)
+ throws EBusConfigurationReaderException {
- Collection result = new ArrayList();
+ Objects.requireNonNull(valueDto, "valueDto");
+
+ Collection<@NonNull EBusCommandValue> result = new ArrayList<@NonNull EBusCommandValue>();
String typeStr = valueDto.getType();
String collectionId = null;
@@ -334,11 +369,12 @@ protected Collection parseValueConfiguration(EBusValueDTO valu
if (StringUtils.isEmpty(typeStr)) {
throw new EBusConfigurationReaderException("Property 'type' is missing for command ! {0}",
- commandMethod.getParent());
+ commandMethod != null ? commandMethod.getParent() : "");
+ }
- } else if (typeStr.equals("template-block")) {
+ if (typeStr != null && typeStr.equals("template-block")) {
- Collection templateCollection = null;
+ Collection<@NonNull EBusCommandValue> templateCollection = null;
if (StringUtils.isNotEmpty(valueDto.getName())) {
logger.warn("Property 'name' is not allowed for type 'template-block', ignore property !");
@@ -389,11 +425,11 @@ protected Collection parseValueConfiguration(EBusValueDTO valu
return result;
- } else if (typeStr.equals("template")) {
+ } else if (typeStr != null && typeStr.equals("template")) {
String id = (String) valueDto.getProperty("id");
String globalId = collectionId + "." + id;
- Collection templateCollection = null;
+ Collection<@NonNull EBusCommandValue> templateCollection = null;
if (StringUtils.isEmpty(id)) {
throw new EBusConfigurationReaderException("No additional information for type 'template' defined!");
@@ -407,7 +443,7 @@ protected Collection parseValueConfiguration(EBusValueDTO valu
} else if (templateMap != null && templateMap.containsKey(id)) {
// return the complete template block from within command block
- templateCollection = new ArrayList();
+ templateCollection = new ArrayList<@NonNull EBusCommandValue>();
templateCollection.add(templateMap.get(id));
} else {
@@ -434,7 +470,7 @@ protected Collection parseValueConfiguration(EBusValueDTO valu
return result;
- } else if (typeStr.equals("static")) {
+ } else if (typeStr != null && typeStr.equals("static")) {
// convert static content to bytes
byte[] byteArray = EBusUtils.toByteArray(valueDto.getDefault());
@@ -463,18 +499,21 @@ protected Collection parseValueConfiguration(EBusValueDTO valu
ev = evc;
int pos = 0;
- for (EBusValueDTO childElem : valueDto.getChildren()) {
+ List children = valueDto.getChildren();
+ if (children != null) {
+ for (EBusValueDTO childElem : children) {
- // add pos information from list
- childElem.setPos(pos);
+ // add pos information from list
+ childElem.setPos(pos);
- // parse child value
- for (EBusCommandValue childValue : parseValueConfiguration(childElem, templateMap, templateList,
- commandMethod)) {
- evc.add(childValue);
- }
+ // parse child value
+ for (EBusCommandValue childValue : parseValueConfiguration(childElem, templateMap, templateList,
+ commandMethod)) {
+ evc.add(childValue);
+ }
- pos++;
+ pos++;
+ }
}
} else {
@@ -497,14 +536,15 @@ protected Collection parseValueConfiguration(EBusValueDTO valu
ev.setMapping(valueDto.getMapping());
ev.setFormat(valueDto.getFormat());
- ev.setParent(commandMethod);
+ if (commandMethod != null) {
+ ev.setParent(commandMethod);
+ }
result.add(ev);
return result;
}
- private void overwritePropertiesFromTemplate(EBusCommandValue clone, EBusValueDTO template) {
-
+ private void overwritePropertiesFromTemplate(@NonNull EBusCommandValue clone, @NonNull EBusValueDTO template) {
// allow placeholders in template-block mode
if (StringUtils.isNotEmpty(template.getLabel())) {
if (StringUtils.isNotEmpty(clone.getLabel()) && clone.getLabel().contains("%s")) {
@@ -513,9 +553,6 @@ private void overwritePropertiesFromTemplate(EBusCommandValue clone, EBusValueDT
clone.setLabel(template.getLabel());
}
}
-
- // clone.setName(StringUtils.defaultIfEmpty(template.g, clone.getName()));
-
}
/*
@@ -524,13 +561,17 @@ private void overwritePropertiesFromTemplate(EBusCommandValue clone, EBusValueDT
* @see de.csdev.ebus.cfg.IEBusConfigurationReader#setEBusTypes(de.csdev.ebus.command.datatypes.EBusTypeRegistry)
*/
@Override
- public void setEBusTypes(EBusTypeRegistry ebusTypes) {
+ public void setEBusTypes(@NonNull EBusTypeRegistry ebusTypes) {
+ Objects.requireNonNull(ebusTypes, "ebusTypes");
registry = ebusTypes;
}
@Override
- public List loadConfigurationCollectionBundle(URL url) {
- List result = new ArrayList();
+ public @NonNull List<@NonNull IEBusCommandCollection> loadConfigurationCollectionBundle(@NonNull URL url) {
+
+ Objects.requireNonNull(url, "url");
+
+ List<@NonNull IEBusCommandCollection> result = new ArrayList<@NonNull IEBusCommandCollection>();
Gson gson = new Gson();
Type type = new TypeToken