bean build items: replace @Nullable with Optional
diff --git a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BuildProcessor.java b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BuildProcessor.java
index 17161e8..a275686 100644
--- a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BuildProcessor.java
+++ b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BuildProcessor.java
@@ -218,12 +218,12 @@
.filter(item -> !containerBeans.getBeans().contains(item))
.forEach(item -> {
LOGGER.debug("Binding bean with name: {}, type {}", item.getName(), item.getType());
- if (item.getValue() != null) {
+ if (item.getValue().isPresent()) {
recorder.bind(
registry,
item.getName(),
recorderContext.classProxy(item.getType()),
- item.getValue());
+ item.getValue().get());
} else {
// the instance of the service will be instantiated by the recorder, this avoid
// creating a recorder for trivial services.
@@ -294,12 +294,12 @@
.forEach(item -> {
LOGGER.debug("Binding runtime bean with name: {}, type {}", item.getName(), item.getType());
- if (item.getValue() != null) {
+ if (item.getValue().isPresent()) {
recorder.bind(
registry.getRegistry(),
item.getName(),
recorderContext.classProxy(item.getType()),
- item.getValue());
+ item.getValue().get());
} else {
// the instance of the service will be instantiated by the recorder, this avoid
// creating a recorder for trivial services.
diff --git a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelBeanBuildItem.java b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelBeanBuildItem.java
index 9274674..0fc6615 100644
--- a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelBeanBuildItem.java
+++ b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelBeanBuildItem.java
@@ -17,6 +17,7 @@
package org.apache.camel.quarkus.core.deployment;
import java.util.Objects;
+import java.util.Optional;
import javax.annotation.Nullable;
@@ -53,7 +54,7 @@
* @param value the value to be bound to the registry, if <code>null</code> a new instance will be create
* by the {@link org.apache.camel.quarkus.core.CamelMainRecorder}
*/
- public CamelBeanBuildItem(String name, String type, @Nullable RuntimeValue<?> value) {
+ public CamelBeanBuildItem(String name, String type, RuntimeValue<?> value) {
this.name = Objects.requireNonNull(name);
this.type = Objects.requireNonNull(type);
this.value = value;
@@ -70,8 +71,8 @@
}
@Nullable
- public RuntimeValue<?> getValue() {
- return value;
+ public Optional<RuntimeValue<?>> getValue() {
+ return Optional.ofNullable(value);
}
@Override
diff --git a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelRuntimeBeanBuildItem.java b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelRuntimeBeanBuildItem.java
index 230413b..b35e840 100644
--- a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelRuntimeBeanBuildItem.java
+++ b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelRuntimeBeanBuildItem.java
@@ -17,8 +17,7 @@
package org.apache.camel.quarkus.core.deployment;
import java.util.Objects;
-
-import javax.annotation.Nullable;
+import java.util.Optional;
import io.quarkus.builder.item.MultiBuildItem;
import io.quarkus.deployment.annotations.ExecutionTime;
@@ -53,7 +52,7 @@
* @param value the value to be bound to the registry, if <code>null</code> a new instance will be create
* by the {@link org.apache.camel.quarkus.core.CamelMainRecorder}
*/
- public CamelRuntimeBeanBuildItem(String name, String type, @Nullable RuntimeValue<?> value) {
+ public CamelRuntimeBeanBuildItem(String name, String type, RuntimeValue<?> value) {
this.name = Objects.requireNonNull(name);
this.type = Objects.requireNonNull(type);
this.value = value;
@@ -69,9 +68,8 @@
return type;
}
- @Nullable
- public RuntimeValue<?> getValue() {
- return value;
+ public Optional<RuntimeValue<?>> getValue() {
+ return Optional.ofNullable(value);
}
@Override