Class OverrideInjector
java.lang.Object
com.seibel.distanthorizons.coreapi.DependencyInjection.OverrideInjector
- All Implemented Interfaces:
IOverrideInjector<IDhApiOverrideable>
This class takes care of dependency injection for overridable objects.
This is done so other mods can override our methods to improve features down the line.
This is done so other mods can override our methods to improve features down the line.
-
Field Summary
FieldsFields inherited from interface com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IOverrideInjector
CORE_PRIORITY, DEFAULT_NON_CORE_OVERRIDE_PRIORITY, MIN_NON_CORE_OVERRIDE_PRIORITY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
bind
(Class<? extends IDhApiOverrideable> dependencyInterface, IDhApiOverrideable dependencyImplementation) Seebind(Class, IBindable)
for full documentation.void
clear()
Removes all bound overrides.<T extends IDhApiOverrideable>
TReturns the bound dependency with the highest priority.<T extends IDhApiOverrideable>
TReturns a dependency of type T with the specified priority if one has been bound.void
unbind
(Class<? extends IDhApiOverrideable> dependencyInterface, IDhApiOverrideable dependencyImplementation) Removes the given concreteIDhApiOverrideable
bound to the given interface.
-
Field Details
-
INSTANCE
-
-
Constructor Details
-
OverrideInjector
public OverrideInjector() -
OverrideInjector
-
-
Method Details
-
bind
public void bind(Class<? extends IDhApiOverrideable> dependencyInterface, IDhApiOverrideable dependencyImplementation) throws IllegalStateException, IllegalArgumentException Description copied from interface:IOverrideInjector
Seebind(Class, IBindable)
for full documentation.- Specified by:
bind
in interfaceIOverrideInjector<IDhApiOverrideable>
- Throws:
IllegalStateException
- if another override with the given priority already has been bound.IllegalArgumentException
- if a non-Distant Horizons Override with the priorityIOverrideInjector.CORE_PRIORITY
is passed in or an override is passed in with an invalid priority value.- See Also:
-
unbind
public void unbind(Class<? extends IDhApiOverrideable> dependencyInterface, IDhApiOverrideable dependencyImplementation) Description copied from interface:IOverrideInjector
Removes the given concreteIDhApiOverrideable
bound to the given interface.- Specified by:
unbind
in interfaceIOverrideInjector<IDhApiOverrideable>
-
get
Description copied from interface:IOverrideInjector
Returns the bound dependency with the highest priority.
Seeget(Class, boolean)
for full documentation.- Specified by:
get
in interfaceIOverrideInjector<IDhApiOverrideable>
- Throws:
ClassCastException
- See Also:
-
get
public <T extends IDhApiOverrideable> T get(Class<T> interfaceClass, int priority) throws ClassCastException Description copied from interface:IOverrideInjector
Returns a dependency of type T with the specified priority if one has been bound.
If there is a dependency, but it was bound with a different priority this will return null.
Seeget(Class, boolean)
for more documentation.- Specified by:
get
in interfaceIOverrideInjector<IDhApiOverrideable>
- Throws:
ClassCastException
- See Also:
-
clear
public void clear()Description copied from interface:IOverrideInjector
Removes all bound overrides.- Specified by:
clear
in interfaceIOverrideInjector<IDhApiOverrideable>
-