java.lang.Object
org.refcodes.decoupling.DependencyImpl<T>
- Type Parameters:
T
- the generic type of theDependency
.
- All Implemented Interfaces:
Comparable<Dependency<T>>
,ClaimsAccessor
,Dependency<T>
,InstanceMetricsAccessor
,ProfilesAccessor
,TagsAccessor
,org.refcodes.mixin.AliasAccessor
,org.refcodes.mixin.Schemable
,org.refcodes.mixin.TypeAccessor<T>
- Direct Known Subclasses:
DependencyBuilderImpl
An implementation of a
Dependency
.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.mixin.AliasAccessor
org.refcodes.mixin.AliasAccessor.AliasBuilder<B extends org.refcodes.mixin.AliasAccessor.AliasBuilder<B>>, org.refcodes.mixin.AliasAccessor.AliasMutator, org.refcodes.mixin.AliasAccessor.AliasProperty
Nested classes/interfaces inherited from interface org.refcodes.decoupling.ClaimsAccessor
ClaimsAccessor.ClaimsBuilder<B extends ClaimsAccessor.ClaimsBuilder<B>>, ClaimsAccessor.ClaimsMutator, ClaimsAccessor.ClaimsProperty
Nested classes/interfaces inherited from interface org.refcodes.decoupling.InstanceMetricsAccessor
InstanceMetricsAccessor.InstanceMetricsBuilder<B extends InstanceMetricsAccessor.InstanceMetricsBuilder<B>>, InstanceMetricsAccessor.InstanceMetricsMutator, InstanceMetricsAccessor.InstanceMetricsProperty
Nested classes/interfaces inherited from interface org.refcodes.decoupling.ProfilesAccessor
ProfilesAccessor.ProfilesBuilder<B extends ProfilesAccessor.ProfilesBuilder<B>>, ProfilesAccessor.ProfilesMutator, ProfilesAccessor.ProfilesProperty
Nested classes/interfaces inherited from interface org.refcodes.decoupling.TagsAccessor
TagsAccessor.TagsBuilder<B extends TagsAccessor.TagsBuilder<B>>, TagsAccessor.TagsMutator, TagsAccessor.TagsProperty
Nested classes/interfaces inherited from interface org.refcodes.mixin.TypeAccessor
org.refcodes.mixin.TypeAccessor.TypeBuilder<T extends Object,
B extends org.refcodes.mixin.TypeAccessor.TypeBuilder<T, B>>, org.refcodes.mixin.TypeAccessor.TypeMutator<T extends Object>, org.refcodes.mixin.TypeAccessor.TypeProperty<T extends Object> -
Field Summary
Modifier and TypeFieldDescriptionprotected String
protected Dependency<?>[]
protected InstanceMetrics
protected T
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
getAlias()
Claim[]
Retrieves theInstanceMetrics
which describes how an instance for aDependency
is managed.T[]
Retrieves the instances produced by thisDependency
(as of theDependency
'sInstanceMetrics
configuration).Object[]
Retrieves the profiles assigned to theDependency
instance.getSetup()
Object[]
getTags()
Retrieves the tags assigned to theDependency
instance.getType()
int
hashCode()
boolean
Determines weather thisDependency
element has at least one instance of its typeTypeAccessor.getType()
being created.protected void
setInstance
(T aInstance) Sets the instance for theDependency
(the type is derived from the instance if not already set, the alias is derived from type if not already set).Creates theDependency
's instance using the preparedDependency
instances (theDependency
instances are prepared by theReactor
'sReactor.createContext()
and the like methods and in turn by thetoInstance(Dependency[], Set)
method).protected T
toInstance
(Dependency<?>[] aDependencies) Creates theDependency
's instance as of its type using the providedDependency
instances.protected T
toInstance
(Dependency<?>[] aDependencies, Set<Dependency<?>> aVistedDependencies) Creates theDependency
's instance as of its type using the providedDependency
instances.protected T
toPostProcessed
(T aInstance) Hook method to be overwritten by sub-classes in order to decorate new aspects to the produced instance.toSchema()
Retrieves theDependencySchema
representing thisDependency
.toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.refcodes.decoupling.Dependency
compareTo, hasInstance
-
Field Details
-
_singleton
-
_alias
-
_claims
-
_dependencies
-
_instanceMetrics
-
_instances
-
_profiles
-
_tags
-
_type
-
_setup
-
_factory
-
-
Constructor Details
-
DependencyImpl
protected DependencyImpl()Instantiates a newDependency
.
-
-
Method Details
-
equals
-
getAlias
- Specified by:
getAlias
in interfaceorg.refcodes.mixin.AliasAccessor
-
getClaims
- Specified by:
getClaims
in interfaceClaimsAccessor
- Returns:
- The
Claim
instances stored by theClaim
instances property.
-
getSetup
- Specified by:
getSetup
in interfaceDependency<T>
- Returns:
- The
Setup
being set for thisDependency
.
-
getFactory
- Specified by:
getFactory
in interfaceDependency<T>
- Returns:
- The
Factory
being set for thisDependency
.
-
getInstanceMetrics
Retrieves theInstanceMetrics
which describes how an instance for aDependency
is managed.- Specified by:
getInstanceMetrics
in interfaceInstanceMetricsAccessor
- Returns:
- The according
InstanceMetrics
.
-
getInstances
Retrieves the instances produced by thisDependency
(as of theDependency
'sInstanceMetrics
configuration).- Specified by:
getInstances
in interfaceDependency<T>
- Returns:
- The instances fabricated by this
Dependency
instance.
-
getProfiles
Retrieves the profiles assigned to theDependency
instance.- Specified by:
getProfiles
in interfaceProfilesAccessor
- Returns:
- The assigned profiles.
-
getTags
Retrieves the tags assigned to theDependency
instance.- Specified by:
getTags
in interfaceTagsAccessor
- Returns:
- The assigned tags.
-
getType
- Specified by:
getType
in interfaceorg.refcodes.mixin.TypeAccessor<T>
-
hashCode
public int hashCode() -
hasInstance
public boolean hasInstance()Determines weather thisDependency
element has at least one instance of its typeTypeAccessor.getType()
being created.- Specified by:
hasInstance
in interfaceDependency<T>
- Returns:
- True in case instances for this
Dependency
have already been created.
-
toInstance
Creates theDependency
's instance using the preparedDependency
instances (theDependency
instances are prepared by theReactor
'sReactor.createContext()
and the like methods and in turn by thetoInstance(Dependency[], Set)
method).- Specified by:
toInstance
in interfaceDependency<T>
- Returns:
- The instance retrieved from the
Dependency
. - Throws:
DependencyInstanciationException
- the dependency instantiation exception
-
toSchema
Retrieves theDependencySchema
representing thisDependency
. Retrieving aDependencySchema
is useful when analyzing and debugging the dependency hierarchy if aDependency
.- Specified by:
toSchema
in interfaceDependency<T>
- Specified by:
toSchema
in interfaceorg.refcodes.mixin.Schemable
- Returns:
- The
DependencySchema
representation of the implementing type for debugging and verification (or documentation) purposes.
-
toString
-
setInstance
Sets the instance for theDependency
(the type is derived from the instance if not already set, the alias is derived from type if not already set).- Parameters:
aInstance
- The instance of the dependency;
-
toInstance
protected T toInstance(Dependency<?>[] aDependencies) throws CircularDependencyException, AmbigousDependencyException, UnsatisfiedDependencyException, AmbigousClaimException, AmbigousSetupException, AmbigousFactoryException, InstallDependencyException Creates theDependency
's instance as of its type using the providedDependency
instances.- Parameters:
aDependencies
- theDependency
instances to use.- Returns:
- The instance retrieved from the
Dependency
. - Throws:
CircularDependencyException
- thrown in case there is some (transitive) circular dependency between twoDependency
instances.AmbigousDependencyException
- thrown in case for a requiredDependency
there are more than one matchingDependency
candidates in theReactor
.UnsatisfiedDependencyException
- thrown in case for a requiredDependency
none matchingDependency
candidates in theReactor
have been found (taking the profiles applied into account) for the constructors of the givenDependency
.AmbigousClaimException
- is thrown in case oneClaim
can be matched by multiple dependencies.AmbigousSetupException
- is thrown in case oneSetup
instance can be matched by multiple dependencies.AmbigousFactoryException
- is thrown in case oneFactory
instance can be matched by multiple dependencies.InstallDependencyException
- is thrown when trying to install aDependency
into theContext
, though installing failed die to the dependency throwing an exception during the process of installing (e.g. instantiation).
-
toInstance
protected T toInstance(Dependency<?>[] aDependencies, Set<Dependency<?>> aVistedDependencies) throws CircularDependencyException, AmbigousDependencyException, UnsatisfiedDependencyException, AmbigousClaimException, AmbigousSetupException, AmbigousFactoryException, InstallDependencyException Creates theDependency
's instance as of its type using the providedDependency
instances.- Parameters:
aDependencies
- theDependency
instances to use.aVistedDependencies
- TheDependency
instances already visited in order to detect a circular dependency situation.- Returns:
- The instance retrieved from the
Dependency
. - Throws:
CircularDependencyException
- thrown in case there is some (transitive) circular dependency between twoDependency
instances.AmbigousDependencyException
- thrown in case for a requiredDependency
there are more than one matchingDependency
candidates in theReactor
.UnsatisfiedDependencyException
- thrown in case for a requiredDependency
none matchingDependency
candidates in theReactor
have been found (taking the profiles applied into account) for the constructors of the givenDependency
.AmbigousClaimException
- is thrown in case oneClaim
can be matched by multiple dependencies.AmbigousSetupException
- is thrown in case oneSetup
instance can be matched by multiple dependencies.AmbigousFactoryException
- is thrown in case oneFactory
instance can be matched by multiple dependencies.InstallDependencyException
- is thrown when trying to install aDependency
into theContext
, though installing failed die to the dependency throwing an exception during the process of installing (e.g. instantiation).
-
toPostProcessed
Hook method to be overwritten by sub-classes in order to decorate new aspects to the produced instance.- Parameters:
aInstance
- The instance to be post processed.- Returns:
- The (new) post processed instance.
-