Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve dev mode test and *BeanBuldItem #589

Merged
merged 2 commits into from
Jan 4, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,12 @@ CamelRegistryBuildItem registry(
.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.
Expand Down Expand Up @@ -294,12 +294,12 @@ CamelRuntimeRegistryBuildItem bindRuntimeBeansToRegistry(
.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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.apache.camel.quarkus.core.deployment;

import java.util.Objects;
import java.util.Optional;

import javax.annotation.Nullable;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we perhaps remove the Nullable import now?


Expand Down Expand Up @@ -53,7 +54,7 @@ public CamelBeanBuildItem(String name, String type) {
* @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;
Expand All @@ -70,8 +71,8 @@ public String getType() {
}

@Nullable
public RuntimeValue<?> getValue() {
return value;
public Optional<RuntimeValue<?>> getValue() {
return Optional.ofNullable(value);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -53,7 +52,7 @@ public CamelRuntimeBeanBuildItem(String name, String type) {
* @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;
Expand All @@ -69,9 +68,8 @@ public String getType() {
return type;
}

@Nullable
public RuntimeValue<?> getValue() {
return value;
public Optional<RuntimeValue<?>> getValue() {
return Optional.ofNullable(value);
}

@Override
Expand Down