Class DependencyBuilder<T>
java.lang.Object
org.refcodes.decoupling.Dependency<T>
org.refcodes.decoupling.DependencyBuilder<T>
- Type Parameters:
T- the generic type of theDependency.
- All Implemented Interfaces:
Comparable<Dependency<T>>, ClaimsAccessor, ClaimsAccessor.ClaimsBuilder<DependencyBuilder<T>>, ClaimsAccessor.ClaimsMutator, ClaimsAccessor.ClaimsProperty, InstanceMetricsAccessor, InstanceMetricsAccessor.InstanceMetricsBuilder<DependencyBuilder<T>>, InstanceMetricsAccessor.InstanceMetricsMutator, InstanceMetricsAccessor.InstanceMetricsProperty, ProfilesAccessor, ProfilesAccessor.ProfilesBuilder<DependencyBuilder<T>>, ProfilesAccessor.ProfilesMutator, ProfilesAccessor.ProfilesProperty, TagsAccessor, TagsAccessor.TagsBuilder<DependencyBuilder<T>>, TagsAccessor.TagsMutator, TagsAccessor.TagsProperty, org.refcodes.mixin.AliasAccessor, org.refcodes.mixin.AliasAccessor.AliasBuilder<DependencyBuilder<T>>, org.refcodes.mixin.AliasAccessor.AliasMutator, org.refcodes.mixin.AliasAccessor.AliasProperty, org.refcodes.mixin.InstanceAccessor<T>, org.refcodes.mixin.InstanceAccessor.InstanceBuilder<T, DependencyBuilder<T>>, org.refcodes.mixin.InstanceAccessor.InstanceMutator<T>, org.refcodes.mixin.InstanceAccessor.InstanceProperty<T>, org.refcodes.mixin.TypeAccessor<T>, org.refcodes.mixin.TypeAccessor.TypeBuilder<T, DependencyBuilder<T>>, org.refcodes.mixin.TypeAccessor.TypeMutator<T>, org.refcodes.mixin.TypeAccessor.TypeProperty<T>, org.refcodes.schema.Schemable
public class DependencyBuilder<T>
extends Dependency<T>
implements org.refcodes.mixin.AliasAccessor.AliasProperty, org.refcodes.mixin.AliasAccessor.AliasBuilder<DependencyBuilder<T>>, org.refcodes.mixin.TypeAccessor.TypeProperty<T>, org.refcodes.mixin.TypeAccessor.TypeBuilder<T, DependencyBuilder<T>>, org.refcodes.mixin.InstanceAccessor.InstanceProperty<T>, org.refcodes.mixin.InstanceAccessor.InstanceBuilder<T, DependencyBuilder<T>>, ProfilesAccessor.ProfilesProperty, ProfilesAccessor.ProfilesBuilder<DependencyBuilder<T>>, TagsAccessor.TagsProperty, TagsAccessor.TagsBuilder<DependencyBuilder<T>>, InstanceMetricsAccessor.InstanceMetricsProperty, InstanceMetricsAccessor.InstanceMetricsBuilder<DependencyBuilder<T>>, ClaimsAccessor.ClaimsProperty, ClaimsAccessor.ClaimsBuilder<DependencyBuilder<T>>
A
DependencyBuilder describes a component or module depending on or
required by other components or modules.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.mixin.AliasAccessor
org.refcodes.mixin.AliasAccessor.AliasBuilder<B>, org.refcodes.mixin.AliasAccessor.AliasMutator, org.refcodes.mixin.AliasAccessor.AliasPropertyNested classes/interfaces inherited from interface ClaimsAccessor
ClaimsAccessor.ClaimsBuilder<B>, ClaimsAccessor.ClaimsMutator, ClaimsAccessor.ClaimsPropertyNested classes/interfaces inherited from interface org.refcodes.mixin.InstanceAccessor
org.refcodes.mixin.InstanceAccessor.InstanceBuilder<T,B>, org.refcodes.mixin.InstanceAccessor.InstanceMutator<T>, org.refcodes.mixin.InstanceAccessor.InstanceProperty<T> Nested classes/interfaces inherited from interface InstanceMetricsAccessor
InstanceMetricsAccessor.InstanceMetricsBuilder<B>, InstanceMetricsAccessor.InstanceMetricsMutator, InstanceMetricsAccessor.InstanceMetricsPropertyNested classes/interfaces inherited from interface ProfilesAccessor
ProfilesAccessor.ProfilesBuilder<B>, ProfilesAccessor.ProfilesMutator, ProfilesAccessor.ProfilesPropertyNested classes/interfaces inherited from interface TagsAccessor
TagsAccessor.TagsBuilder<B>, TagsAccessor.TagsMutator, TagsAccessor.TagsPropertyNested classes/interfaces inherited from interface org.refcodes.mixin.TypeAccessor
org.refcodes.mixin.TypeAccessor.TypeBuilder<T,B>, org.refcodes.mixin.TypeAccessor.TypeMutator<T>, org.refcodes.mixin.TypeAccessor.TypeProperty<T> -
Field Summary
Fields inherited from class Dependency
_alias, _claims, _dependencies, _factory, _initializer, _instanceMetrics, _instances, _profiles, _reactor, _singleton, _tags, _type -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedEmpty constructor for creating an instance of theDependencyBuilderin which to apply the builder methods to set the desired state.DependencyBuilder(Class<T> aType) DependencyBuilder(T aInstance) -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanbooleanbooleanbooleanaddProfile(Object aProfile) Adds the given profile to the profiles.booleanAdds the given tag to the tags.voidvoidsetClaims(Collection<Claim> aClaims) Sets theClaiminstances to theDependencyBuilderinstance.void<F extends org.refcodes.factory.Factory<T>>
voidsetFactory(Class<F> aFactory) <F extends org.refcodes.factory.Factory<T>>
voidsetFactory(Class<F> aFactory, String aAlias) <F> voidsetFactory(Class<F> aDependency, Function<F, T> aFactory) <F> voidsetFactory(Class<F> aDependency, Function<F, T> aFactory, String aAlias) <F> voidsetFactory(FactoryClaim<F, T> aFactory) <F extends org.refcodes.factory.Initializer<T>>
voidsetInitializer(Class<F> aFactory) Sets theInitializerClaim, being aClaimdedicated to preprocess theDependencyafter instantiation.<F extends org.refcodes.factory.Initializer<T>>
voidsetInitializer(Class<F> aFactory, String aAlias) Sets theInitializerClaim, being aClaimdedicated to preprocess theDependencyafter instantiation.<I> voidsetInitializer(Class<I> aDependency, BiFunction<T, I, T> aInitializer) Sets theInitializerClaim, being aClaimdedicated to preprocess theDependencyafter instantiation.<I> voidsetInitializer(Class<I> aDependency, BiFunction<T, I, T> aInitializer, String aAlias) Sets theInitializerClaim, being aClaimdedicated to preprocess theDependencyafter instantiation.<I> voidsetInitializer(InitializerClaim<I, T> aInitializer) Sets theInitializerClaim, being aClaimdedicated to preprocess theDependencyafter instantiation.voidsetInstance(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).voidsetInstanceMetrics(InstanceMetrics aInstanceMetrics) Sets theInstanceMetricsinstance for theInstanceMetricsproperty.voidsetInstanceMetrics(InstanceMode aInstanceMode) Sets theInstanceModewhich describes how an instance for aDependencyis managed.voidsetProfiles(Object[] aProfiles) Sets the profiles for the profiles property.voidsetProfiles(Collection<?> aProfiles) Sets the profiles assigned to theDependencyBuilderinstance.voidSets the tags for the tags property.voidsetTags(Collection<?> aTags) Sets the tags assigned to theDependencyBuilderinstance.voidwithAddClaim(Class<?> aType) Builder method for the accordingaddClaim(Class)method.withAddClaim(Class<?> aType, String aAlias) Builder method for the accordingaddClaim(Class, String)method.withAddClaim(String aAlias) Builder method for the accordingaddClaim(Claim)method.withAddClaim(Claim aClaim) Builder method for the accordingaddClaim(Claim)method.withAddProfile(Object aProfile) Builder method for adding a single profile.withAddTag(Object aTag) Builder method for adding a single tag.withClaims(Collection<Claim> aClaims) Builder method for thesetClaims(Claim[])method.withClaims(Claim... aClaims) <F extends org.refcodes.factory.Factory<T>>
DependencyBuilder<T> withFactory(Class<F> aFactory) Builder method for thesetFactory(Class)method.<F extends org.refcodes.factory.Factory<T>>
DependencyBuilder<T> withFactory(Class<F> aFactory, String aAlias) Builder method for thesetFactory(Class, String)method.<F> DependencyBuilder<T> withFactory(Class<F> aDependency, Function<F, T> aFactory) Builder method for thesetFactory(Class, Function)method.<F> DependencyBuilder<T> withFactory(Class<F> aDependency, Function<F, T> aFactory, String aAlias) Builder method for thesetFactory(Class, Function, String)method.<F> DependencyBuilder<T> withFactory(FactoryClaim<F, T> aFactory) Builder method for thesetFactory(FactoryClaim)method.<F> DependencyBuilder<T> withInitializer(Class<F> aDependency, BiFunction<T, F, T> aInitializer, String aAlias) Builder method for thesetInitializer(Class, BiFunction, String)method.<I extends org.refcodes.factory.Initializer<T>>
DependencyBuilder<T> withInitializer(Class<I> aInitializer) Builder method for thesetInitializer(Class)method.<I extends org.refcodes.factory.Initializer<T>>
DependencyBuilder<T> withInitializer(Class<I> aInitializer, String aAlias) Builder method for thesetInitializer(Class, String)method.<I> DependencyBuilder<T> withInitializer(Class<I> aDependency, BiFunction<T, I, T> aInitializer) Builder method for thesetInitializer(Class, BiFunction)method.<I> DependencyBuilder<T> withInitializer(InitializerClaim<I, T> aInitializer) Builder method for thesetInitializer(InitializerClaim)method.withInstance(T aInstance) withInstanceMetrics(InstanceMetrics aInstanceMetrics) Sets theInstanceMetricsinstance for theInstanceMetricsproperty.withInstanceMetrics(InstanceMode aInstanceMode) Builder method for thesetInstanceMetrics(InstanceMode)method.withProfiles(Object... aProfiles) Sets the profiles for the profiles property.withProfiles(Collection<?> aProfiles) Builder method for thesetProfiles(Object[])method.Sets the tags for the tags property.withTags(Collection<?> aTags) Builder method for thesetTags(Object[])method.Methods inherited from class Dependency
compareTo, equals, getAlias, getClaims, getFactory, getInitializer, getInstanceMetrics, getInstances, getProfiles, getTags, getType, hashCode, hasInstance, hasInstances, hasProfile, intercept, toInstance, toInstance, toInstance, toSchema, toStringMethods inherited from interface org.refcodes.mixin.AliasAccessor
getAliasMethods inherited from interface org.refcodes.mixin.AliasAccessor.AliasProperty
letAliasMethods inherited from interface ClaimsAccessor
getClaimsMethods inherited from interface ClaimsAccessor.ClaimsProperty
letClaimsMethods inherited from interface org.refcodes.mixin.InstanceAccessor.InstanceProperty
letInstanceMethods inherited from interface InstanceMetricsAccessor
getInstanceMetricsMethods inherited from interface InstanceMetricsAccessor.InstanceMetricsProperty
letInstanceMetricsMethods inherited from interface ProfilesAccessor
getProfilesMethods inherited from interface ProfilesAccessor.ProfilesProperty
letProfilesMethods inherited from interface TagsAccessor
getTagsMethods inherited from interface TagsAccessor.TagsProperty
letTagsMethods inherited from interface org.refcodes.mixin.TypeAccessor
getTypeMethods inherited from interface org.refcodes.mixin.TypeAccessor.TypeProperty
letType
-
Constructor Details
-
DependencyBuilder
protected DependencyBuilder()Empty constructor for creating an instance of theDependencyBuilderin which to apply the builder methods to set the desired state. -
DependencyBuilder
-
DependencyBuilder
-
-
Method Details
-
getInstance
-
addClaim
-
addClaim
-
addClaim
-
addClaim
-
addProfile
Adds the given profile to the profiles.- Parameters:
aProfile- The profile to add.- Returns:
- True in case the profile was added, false in case the profile has already been added.
-
addTag
Adds the given tag to the tags.- Parameters:
aTag- The tag to add.- Returns:
- True in case the tag was added, false in case the tag has already been added.
-
setInitializer
Sets theInitializerClaim, being aClaimdedicated to preprocess theDependencyafter instantiation.- Type Parameters:
I- The type of theDependencybeing claimed by theInitializerClaim.- Parameters:
aInitializer- The setup configuring thisDependency's instances.
-
setInitializer
Sets theInitializerClaim, being aClaimdedicated to preprocess theDependencyafter instantiation.- Type Parameters:
I- The type of theDependencybeing required by theInitializerClaim.- Parameters:
aDependency- The according claim required by theInitializerClaim.aInitializer- The setup configuring thisDependency's instances.
-
setInitializer
Sets theInitializerClaim, being aClaimdedicated to preprocess theDependencyafter instantiation.- Type Parameters:
I- The type of theDependencybeing claimed by theInitializerClaim.- Parameters:
aDependency- The according claim required by theInitializerClaim.aInitializer- The setup configuring thisDependency's instances.aAlias- the alias for theInitializerClaimto be added.
-
setInitializer
Sets theInitializerClaim, being aClaimdedicated to preprocess theDependencyafter instantiation. The accordingInitializerClaimmust implement theInitializerfunctional interface for setting up thisDependency's instances.- Type Parameters:
F- The type of theDependencybeing claimed by theInitializerClaim.- Parameters:
aFactory- The factory setting up thisDependency's instance.
-
setInitializer
public <F extends org.refcodes.factory.Initializer<T>> void setInitializer(Class<F> aFactory, String aAlias) Sets theInitializerClaim, being aClaimdedicated to preprocess theDependencyafter instantiation. The accordingInitializerClaimmust implement theInitializerfunctional interface for setting up thisDependency's instances.- Type Parameters:
F- The type of theDependencybeing claimed by theInitializerClaim.- Parameters:
aFactory- The factory setting up thisDependency's instance.aAlias- the alias for theInitializerClaimto be added.
-
setFactory
- Type Parameters:
F- The type of theDependencybeing claimed by theFactoryClaim.- Parameters:
aFactory- TheFactoryClaiminstance used to create (fabricate) theDependency's instance.
-
setFactory
- Type Parameters:
F- The type of theDependencybeing claimed by theFactoryClaim.- Parameters:
aDependency- The according claim required by theFactoryClaim.aFactory- The factory used to create (fabricate) theDependency's instance.
-
setFactory
- Type Parameters:
F- The type of theDependencybeing claimed by theFactoryClaim.- Parameters:
aDependency- The according claim required by theFactoryClaim.aFactory- The factory setting up thisDependency's instance.aAlias- the alias for theFactoryClaimto be added.
-
setFactory
- Type Parameters:
F- The type of theDependencybeing claimed by theFactoryClaim.- Parameters:
aFactory- The factory setting up thisDependency's instance.
-
setFactory
public <F extends org.refcodes.factory.Factory<T>> void setFactory(Class<F> aFactory, String aAlias) - Type Parameters:
F- The type of theDependencybeing claimed by theFactoryClaim.- Parameters:
aFactory- The factory setting up thisDependency's instance.aAlias- the alias for theFactoryClaimto be added.
-
setAlias
- Specified by:
setAliasin interfaceorg.refcodes.mixin.AliasAccessor.AliasMutator
-
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).- Specified by:
setInstancein interfaceorg.refcodes.mixin.InstanceAccessor.InstanceMutator<T>- Overrides:
setInstancein classDependency<T>- Parameters:
aInstance- The instance of the dependency;
-
setInstanceMetrics
Sets theInstanceMetricsinstance for theInstanceMetricsproperty.- Specified by:
setInstanceMetricsin interfaceInstanceMetricsAccessor.InstanceMetricsMutator- Parameters:
aInstanceMetrics- TheInstanceMetricsinstance to be stored by theInstanceMetricsproperty.
-
setInstanceMetrics
Sets theInstanceModewhich describes how an instance for aDependencyis managed.- Parameters:
aInstanceMode- The accordingInstanceMode.
-
setProfiles
Sets the profiles for the profiles property.- Specified by:
setProfilesin interfaceProfilesAccessor.ProfilesMutator- Parameters:
aProfiles- The profiles to be stored by the profiles property.
-
setProfiles
Sets the profiles assigned to theDependencyBuilderinstance.- Parameters:
aProfiles- The profiles to be assigned.
-
setTags
Sets the tags for the tags property.- Specified by:
setTagsin interfaceTagsAccessor.TagsMutator- Parameters:
aTags- The tags to be stored by the tags property.
-
setTags
Sets the tags assigned to theDependencyBuilderinstance.- Parameters:
aTags- The tags to be assigned.
-
setClaims
-
setClaims
Sets theClaiminstances to theDependencyBuilderinstance.- Parameters:
aClaims- TheClaiminstances to be assigned.
-
setType
-
withAddClaim
Builder method for the accordingaddClaim(Claim)method. -
withAddClaim
Builder method for the accordingaddClaim(Claim)method. -
withAddClaim
Builder method for the accordingaddClaim(Class)method.- Parameters:
aType- the type of the claimed dependency.- Returns:
- This instance as of the builder pattern with additions to finish
building the current
Claim.
-
withAddClaim
Builder method for the accordingaddClaim(Class, String)method. -
withAddProfile
Builder method for adding a single profile.- Parameters:
aProfile- The profile to be added.- Returns:
- This instance as of the builder pattern.
-
withAddTag
Builder method for adding a single tag.- Parameters:
aTag- The tag to be added.- Returns:
- This instance as of the builder pattern.
-
withAlias
- Specified by:
withAliasin interfaceorg.refcodes.mixin.AliasAccessor.AliasBuilder<T>
-
withInstance
- Specified by:
withInstancein interfaceorg.refcodes.mixin.InstanceAccessor.InstanceBuilder<T, DependencyBuilder<T>>
-
withInstanceMetrics
Sets theInstanceMetricsinstance for theInstanceMetricsproperty.- Specified by:
withInstanceMetricsin interfaceInstanceMetricsAccessor.InstanceMetricsBuilder<T>- Parameters:
aInstanceMetrics- TheInstanceMetricsinstance to be stored by theInstanceMetricsproperty.- Returns:
- The builder for applying multiple build operations.
-
withInstanceMetrics
Builder method for thesetInstanceMetrics(InstanceMode)method.- Parameters:
aInstanceMode- The accordingInstanceMode.- Returns:
- This instance as of the builder pattern.
-
withProfiles
Builder method for thesetProfiles(Object[])method.- Parameters:
aProfiles- The profiles to be assigned.- Returns:
- This instance as of the builder pattern.
-
withProfiles
Sets the profiles for the profiles property.- Specified by:
withProfilesin interfaceProfilesAccessor.ProfilesBuilder<T>- Parameters:
aProfiles- The profiles to be stored by the profiles property.- Returns:
- The builder for applying multiple build operations.
-
withTags
Builder method for thesetTags(Object[])method.- Parameters:
aTags- The tags to be assigned.- Returns:
- This instance as of the builder pattern.
-
withTags
Sets the tags for the tags property.- Specified by:
withTagsin interfaceTagsAccessor.TagsBuilder<T>- Parameters:
aTags- The tags to be stored by the tags property.- Returns:
- The builder for applying multiple build operations.
-
withClaims
Builder method for thesetClaims(Claim[])method.- Parameters:
aClaims- TheClaiminstances to be assigned.- Returns:
- This instance as of the builder pattern.
-
withClaims
- Specified by:
withClaimsin interfaceClaimsAccessor.ClaimsBuilder<T>- Parameters:
aClaims- TheClaiminstances to be stored by theClaiminstances property.- Returns:
- The builder for applying multiple build operations.
-
withType
- Specified by:
withTypein interfaceorg.refcodes.mixin.TypeAccessor.TypeBuilder<T, DependencyBuilder<T>>
-
withInitializer
Builder method for thesetInitializer(InitializerClaim)method.- Type Parameters:
I- The type of theDependencybeing claimed by theInitializerClaim.- Parameters:
aInitializer- The setup configuring thisDependency's instances.- Returns:
- This instance as of the builder pattern.
-
withInitializer
public <I> DependencyBuilder<T> withInitializer(Class<I> aDependency, BiFunction<T, I, T> aInitializer) Builder method for thesetInitializer(Class, BiFunction)method.- Type Parameters:
I- The type of theDependencybeing claimed by theInitializerClaim.- Parameters:
aDependency- The according dependency required by theInitializerClaim.aInitializer- The setup configuring thisDependency's instances.- Returns:
- This instance as of the builder pattern.
-
withInitializer
public <F> DependencyBuilder<T> withInitializer(Class<F> aDependency, BiFunction<T, F, T> aInitializer, String aAlias) Builder method for thesetInitializer(Class, BiFunction, String)method.- Type Parameters:
F- The type of theDependencybeing claimed by theInitializerClaim.- Parameters:
aDependency- The according claim required by theInitializerClaim.aInitializer- The setup configuring thisDependency's instances.aAlias- the alias for theInitializerClaimto be added.- Returns:
- This instance as of the builder pattern.
-
withInitializer
public <I extends org.refcodes.factory.Initializer<T>> DependencyBuilder<T> withInitializer(Class<I> aInitializer) Builder method for thesetInitializer(Class)method.- Type Parameters:
I- The type of theDependencybeing claimed by theInitializerClaim.- Parameters:
aInitializer- The setup configuring thisDependency's instances.- Returns:
- This instance as of the builder pattern.
-
withInitializer
public <I extends org.refcodes.factory.Initializer<T>> DependencyBuilder<T> withInitializer(Class<I> aInitializer, String aAlias) Builder method for thesetInitializer(Class, String)method.- Type Parameters:
I- The type of theDependencybeing claimed by theInitializerClaim.- Parameters:
aInitializer- The setup configuring thisDependency's instances.aAlias- the alias for theInitializerClaimto be added.- Returns:
- This instance as of the builder pattern.
-
withFactory
Builder method for thesetFactory(FactoryClaim)method.- Type Parameters:
F- The type of theDependencybeing required by theFactoryClaim.- Parameters:
aFactory- TheFactoryClaiminstance used for setting up theDependency.- Returns:
- This instance as of the builder pattern.
-
withFactory
Builder method for thesetFactory(Class, Function)method.- Type Parameters:
F- The type of theDependencybeing claimed by theFactoryClaim.- Parameters:
aDependency- The according dependency required by theFactoryClaim.aFactory- The factory fabricating (creating) thisDependency's instances using the provided dependency.- Returns:
- This instance as of the builder pattern.
-
withFactory
public <F> DependencyBuilder<T> withFactory(Class<F> aDependency, Function<F, T> aFactory, String aAlias) Builder method for thesetFactory(Class, Function, String)method.- Type Parameters:
F- The type of theDependencybeing claimed by theFactoryClaim.- Parameters:
aDependency- The according dependency required by theFactoryClaim.aFactory- The factory fabricating (creating) thisDependency's instances using the provided dependency.aAlias- the alias for theFactoryClaimto be added.- Returns:
- This instance as of the builder pattern.
-
withFactory
public <F extends org.refcodes.factory.Factory<T>> DependencyBuilder<T> withFactory(Class<F> aFactory) Builder method for thesetFactory(Class)method.- Type Parameters:
F- The type of theDependencybeing claimed by theFactoryClaim.- Parameters:
aFactory- The factory setting up thisDependency's instance.- Returns:
- This instance as of the builder pattern.
-
withFactory
public <F extends org.refcodes.factory.Factory<T>> DependencyBuilder<T> withFactory(Class<F> aFactory, String aAlias) Builder method for thesetFactory(Class, String)method.- Type Parameters:
F- The type of theDependencybeing claimed by theFactoryClaim.- Parameters:
aFactory- The factory setting up thisDependency's instance.aAlias- the alias for theFactoryClaimto be added.- Returns:
- This instance as of the builder pattern.
-