Skip to content

Commit

Permalink
build: minor code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jknack committed May 19, 2024
1 parent 5e76a65 commit 0b2abe1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion jooby/src/main/java/io/jooby/Jooby.java
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ public String getContextPath() {
@NonNull public Jooby install(@NonNull String path, @NonNull SneakyThrows.Supplier<Jooby> factory) {
try {
owner = this;
path(path, () -> factory.get());
path(path, factory::get);
return this;
} finally {
owner = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

public class ServiceRegistryImpl implements ServiceRegistry {

private Map<ServiceKey<?>, Provider<?>> registry = new ConcurrentHashMap<>();
private final Map<ServiceKey<?>, Provider<?>> registry = new ConcurrentHashMap<>();

@NonNull @Override
public Set<ServiceKey<?>> keySet() {
Expand All @@ -31,7 +31,7 @@ public Set<Map.Entry<ServiceKey<?>, Provider<?>>> entrySet() {

@Nullable @Override
public <T> T getOrNull(@NonNull ServiceKey<T> key) {
Provider provider = registry.get(key);
var provider = registry.get(key);
if (provider == null) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
/*
* Jooby https://jooby.io
* Apache License Version 2.0 https://jooby.io/LICENSE.txt
* Copyright 2014 Edgar Espina
*/
package io.jooby.avaje.inject;

import java.util.NoSuchElementException;

import edu.umd.cs.findbugs.annotations.NonNull;
import io.avaje.inject.BeanScope;
import io.jooby.Registry;
import io.jooby.ServiceKey;
Expand All @@ -16,7 +22,7 @@ public AvajeInjectRegistry(BeanScope beanScope) {
}

@Override
public <T> T require(Class<T> type) throws RegistryException {
public @NonNull <T> T require(@NonNull Class<T> type) throws RegistryException {
try {
return beanScope.get(type);
} catch (NoSuchElementException e) {
Expand All @@ -26,7 +32,8 @@ public <T> T require(Class<T> type) throws RegistryException {
}

@Override
public <T> T require(Class<T> type, String name) throws RegistryException {
public @NonNull <T> T require(@NonNull Class<T> type, @NonNull String name)
throws RegistryException {
try {
return beanScope.get(type, name);
} catch (NoSuchElementException e) {
Expand All @@ -36,7 +43,11 @@ public <T> T require(Class<T> type, String name) throws RegistryException {
}

@Override
public <T> T require(ServiceKey<T> key) throws RegistryException {
return require(key.getType(), key.getName());
public @NonNull <T> T require(@NonNull ServiceKey<T> key) throws RegistryException {
if (key.getName() == null) {
return require(key.getType());
} else {
return require(key.getType(), key.getName());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import io.jooby.exception.RegistryException;

class GuiceRegistry implements Registry {
private Injector injector;
private final Injector injector;

GuiceRegistry(Injector injector) {
this.injector = injector;
Expand Down

0 comments on commit 0b2abe1

Please sign in to comment.