Skip to content

Commit

Permalink
fix null fields
Browse files Browse the repository at this point in the history
  • Loading branch information
DC2-DanielKrueger committed Dec 11, 2024
1 parent 993c2aa commit 7610e3d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.hivemq.edge.adapters.opcua.config;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.hivemq.adapter.sdk.api.annotations.ModuleConfigField;
import com.hivemq.adapter.sdk.api.config.ProtocolSpecificAdapterConfig;
Expand Down Expand Up @@ -55,6 +56,7 @@ public class OpcUaSpecificAdapterConfig implements ProtocolSpecificAdapterConfig
defaultValue = "false")
private final boolean overrideUri;

// @JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("auth")
private final @NotNull Auth auth;

Expand All @@ -79,7 +81,7 @@ public OpcUaSpecificAdapterConfig(
@JsonProperty("security") final @Nullable Security security) {
this.uri = uri;
this.overrideUri = requireNonNullElse(overrideUri, false);
this.auth = requireNonNullElse(auth, new Auth(null, null));
this.auth = auth;
this.tls = requireNonNullElse(tls, new Tls(false, null, null));
this.opcuaToMqttConfig =
Objects.requireNonNullElseGet(opcuaToMqttConfig, () -> new OpcUaToMqttConfig(null, null));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,29 @@
package com.hivemq.edge.adapters.opcua.config;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.hivemq.adapter.sdk.api.annotations.ModuleConfigField;
import org.jetbrains.annotations.Nullable;

import java.util.Objects;

import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;

public class Tls {

@JsonProperty("enabled")
@ModuleConfigField(title = "Enable TLS", description = "Enables TLS encrypted connection", defaultValue = "true")
private final boolean enabled;

@JsonProperty("keystore")
@JsonInclude(NON_NULL)
@ModuleConfigField(title = "Keystore",
description = "Keystore that contains the client certificate including the chain. Required for X509 authentication.")
private final @Nullable Keystore keystore;

@JsonProperty("truststore")
@JsonInclude(NON_NULL)
@ModuleConfigField(title = "Truststore",
description = "Truststore wich contains the trusted server certificates or trusted intermediates.")
private final @Nullable Truststore truststore;
Expand Down

0 comments on commit 7610e3d

Please sign in to comment.