-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#48 Merge all handler subtypes into the Handler interface
- Loading branch information
Showing
31 changed files
with
195 additions
and
431 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 8 additions & 93 deletions
101
injector/src/main/java/ch/jalu/injector/InjectorConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,116 +1,31 @@ | ||
package ch.jalu.injector; | ||
|
||
import ch.jalu.injector.handlers.annotationvalues.AnnotationValueHandler; | ||
import ch.jalu.injector.handlers.dependency.DependencyHandler; | ||
import ch.jalu.injector.handlers.instantiation.InstantiationProvider; | ||
import ch.jalu.injector.handlers.postconstruct.PostConstructHandler; | ||
import ch.jalu.injector.handlers.preconstruct.PreConstructHandler; | ||
import ch.jalu.injector.handlers.provider.ProviderHandler; | ||
import ch.jalu.injector.handlers.Handler; | ||
import ch.jalu.injector.utils.InjectorUtils; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
/** | ||
* Injector configuration. | ||
*/ | ||
public class InjectorConfig { | ||
|
||
// Handlers | ||
private List<AnnotationValueHandler> annotationValueHandlers = new ArrayList<>(); | ||
private List<ProviderHandler> providerHandlers = new ArrayList<>(); | ||
private List<PreConstructHandler> preConstructHandlers = new ArrayList<>(); | ||
private List<InstantiationProvider> instantiationProviders = new ArrayList<>(); | ||
private List<DependencyHandler> dependencyHandlers = new ArrayList<>(); | ||
private List<PostConstructHandler> postConstructHandlers = new ArrayList<>(); | ||
private List<Handler> handlers = new ArrayList<>(); | ||
|
||
/** | ||
* Use the {@link InjectorBuilder} instead of instantiating this. | ||
*/ | ||
protected InjectorConfig() { | ||
} | ||
|
||
/** | ||
* Returns all registered {@link AnnotationValueHandler} instances. | ||
* | ||
* @return pre construct handlers | ||
*/ | ||
public List<AnnotationValueHandler> getAnnotationValueHandlers() { | ||
return annotationValueHandlers; | ||
} | ||
|
||
/** | ||
* Returns all registered {@link ProviderHandler} instances. | ||
* | ||
* @return pre construct handlers | ||
*/ | ||
public List<ProviderHandler> getProviderHandlers() { | ||
return providerHandlers; | ||
} | ||
|
||
/** | ||
* Returns all registered {@link PreConstructHandler} instances. | ||
* | ||
* @return pre construct handlers | ||
*/ | ||
public List<PreConstructHandler> getPreConstructHandlers() { | ||
return preConstructHandlers; | ||
} | ||
|
||
/** | ||
* Returns all registered {@link InstantiationProvider} instances. | ||
* | ||
* @return instantiation providers | ||
*/ | ||
public List<InstantiationProvider> getInstantiationProviders() { | ||
return instantiationProviders; | ||
} | ||
|
||
/** | ||
* Returns all registered {@link DependencyHandler} instances. | ||
* | ||
* @return dependency handlers | ||
*/ | ||
public List<DependencyHandler> getDependencyHandlers() { | ||
return dependencyHandlers; | ||
} | ||
|
||
/** | ||
* Returns all registered {@link PostConstructHandler} instances. | ||
* | ||
* @return post construct handlers | ||
*/ | ||
public List<PostConstructHandler> getPostConstructHandlers() { | ||
return postConstructHandlers; | ||
} | ||
|
||
public void addAnnotationValueHandlers(List<? extends AnnotationValueHandler> annotationValueHandlers) { | ||
InjectorUtils.checkNotNull(annotationValueHandlers, null); | ||
this.annotationValueHandlers.addAll(annotationValueHandlers); | ||
} | ||
|
||
public void addProviderHandlers(List<? extends ProviderHandler> providerHandlers) { | ||
InjectorUtils.checkNotNull(providerHandlers, null); | ||
this.providerHandlers.addAll(providerHandlers); | ||
} | ||
|
||
public void addPreConstructHandlers(List<? extends PreConstructHandler> preConstructHandlers) { | ||
InjectorUtils.checkNotNull(preConstructHandlers, null); | ||
this.preConstructHandlers.addAll(preConstructHandlers); | ||
} | ||
|
||
public void addInstantiationProviders(List<? extends InstantiationProvider> instantiationProviders) { | ||
InjectorUtils.checkNotNull(instantiationProviders, null); | ||
this.instantiationProviders.addAll(instantiationProviders); | ||
} | ||
|
||
public void addDependencyHandlers(List<? extends DependencyHandler> dependencyHandlers) { | ||
InjectorUtils.checkNotNull(dependencyHandlers, null); | ||
this.dependencyHandlers.addAll(dependencyHandlers); | ||
public void addHandlers(Collection<? extends Handler> handlers) { | ||
InjectorUtils.checkNotNull(handlers, null); | ||
this.handlers.addAll(handlers); | ||
} | ||
|
||
public void addPostConstructHandlers(List<? extends PostConstructHandler> postConstructHandlers) { | ||
InjectorUtils.checkNotNull(postConstructHandlers, null); | ||
this.postConstructHandlers.addAll(postConstructHandlers); | ||
public List<Handler> getHandlers() { | ||
return handlers; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.