Skip to content

Commit a12e6da

Browse files
committed
Add @nonnull and @OVERRIDES annotations
1 parent 40b7c21 commit a12e6da

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

maven-di/src/main/java/org/apache/maven/di/Injector.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.lang.annotation.Annotation;
2222
import java.util.function.Supplier;
2323

24+
import org.apache.maven.api.annotations.Nonnull;
2425
import org.apache.maven.di.impl.InjectorImpl;
2526

2627
public interface Injector {
@@ -29,18 +30,24 @@ public interface Injector {
2930
// Builder API
3031
//
3132

33+
@Nonnull
3234
static Injector create() {
3335
return new InjectorImpl();
3436
}
3537

38+
@Nonnull
3639
Injector discover(ClassLoader classLoader);
3740

41+
@Nonnull
3842
Injector bindScope(Class<? extends Annotation> scopeAnnotation, Scope scope);
3943

44+
@Nonnull
4045
Injector bindScope(Class<? extends Annotation> scopeAnnotation, Supplier<Scope> scope);
4146

47+
@Nonnull
4248
Injector bindImplicit(Class<?> cls);
4349

50+
@Nonnull
4451
<T> Injector bindInstance(Class<T> cls, T instance);
4552

4653
//

maven-di/src/main/java/org/apache/maven/di/impl/InjectorImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,12 @@ public InjectorImpl() {
6464
bindScope(Singleton.class, new SingletonScope());
6565
}
6666

67+
@Override
6768
public <T> T getInstance(Class<T> key) {
6869
return getInstance(Key.of(key));
6970
}
7071

72+
@Override
7173
public <T> T getInstance(Key<T> key) {
7274
return getCompiledBinding(key).get();
7375
}
@@ -100,10 +102,12 @@ public Injector discover(ClassLoader classLoader) {
100102
return this;
101103
}
102104

105+
@Override
103106
public Injector bindScope(Class<? extends Annotation> scopeAnnotation, Scope scope) {
104107
return bindScope(scopeAnnotation, () -> scope);
105108
}
106109

110+
@Override
107111
public Injector bindScope(Class<? extends Annotation> scopeAnnotation, Supplier<Scope> scope) {
108112
if (scopes.put(scopeAnnotation, scope) != null) {
109113
throw new DIException(
@@ -112,6 +116,7 @@ public Injector bindScope(Class<? extends Annotation> scopeAnnotation, Supplier<
112116
return this;
113117
}
114118

119+
@Override
115120
public <U> Injector bindInstance(Class<U> clazz, U instance) {
116121
Key<?> key = Key.of(clazz, ReflectionUtils.qualifierOf(clazz));
117122
Binding<U> binding = Binding.toInstance(instance);

0 commit comments

Comments
 (0)