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 TypeMethodDescriptionvoidbind(Class<? extends IDhApiOverrideable> dependencyInterface, IDhApiOverrideable dependencyImplementation) Seebind(Class, IBindable)for full documentation.voidclear()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.voidunbind(Class<? extends IDhApiOverrideable> dependencyInterface, IDhApiOverrideable dependencyImplementation) Removes the given concreteIDhApiOverrideablebound 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:IOverrideInjectorSeebind(Class, IBindable)for full documentation.- Specified by:
bindin 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_PRIORITYis 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:IOverrideInjectorRemoves the given concreteIDhApiOverrideablebound to the given interface.- Specified by:
unbindin interfaceIOverrideInjector<IDhApiOverrideable>
-
get
Description copied from interface:IOverrideInjectorReturns the bound dependency with the highest priority.
Seeget(Class, boolean)for full documentation.- Specified by:
getin interfaceIOverrideInjector<IDhApiOverrideable>- Throws:
ClassCastException- See Also:
-
get
public <T extends IDhApiOverrideable> T get(Class<T> interfaceClass, int priority) throws ClassCastException Description copied from interface:IOverrideInjectorReturns 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:
getin interfaceIOverrideInjector<IDhApiOverrideable>- Throws:
ClassCastException- See Also:
-
clear
public void clear()Description copied from interface:IOverrideInjectorRemoves all bound overrides.- Specified by:
clearin interfaceIOverrideInjector<IDhApiOverrideable>
-