Skip to content
v2.275.0

MixinApplicator Class ​

Applies mixins to constructs.

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';

declare const constructSelector: cdk.IConstructSelector;
const mixinApplicator = new cdk.MixinApplicator(this, /* all optional props */ constructSelector);
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk

# construct_selector: cdk.IConstructSelector

mixin_applicator = cdk.MixinApplicator(self, construct_selector)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;

IConstructSelector constructSelector;

MixinApplicator mixinApplicator = new MixinApplicator(this, constructSelector);
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;

IConstructSelector constructSelector;

var mixinApplicator = new MixinApplicator(this, constructSelector);
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import cdk "github.com/aws/aws-cdk-go/awscdk"

var constructSelector IConstructSelector

mixinApplicator := cdk.NewMixinApplicator(this, constructSelector)

Initializer ​

ts
new MixinApplicator(scope: IConstruct, selector?: IConstructSelector)
python
MixinApplicator(scope: IConstruct, selector: typing.Optional[IConstructSelector] = None)
java
new MixinApplicator(IConstruct scope, IConstructSelector selector)
csharp
new MixinApplicator(IConstruct scope, IConstructSelector? selector = null)
go
NewMixinApplicator(Scope IConstruct, Selector IConstructSelector)

Properties ​

reportMixinApplication[]reporttyping.List[MixinApplication]reportList<MixinApplication>ReportMixinApplication[]Report*[]MixinApplication#
Returns the successful mixin applications.
selectedConstructsIConstruct[]selected_constructstyping.List[IConstruct]selectedConstructsList<IConstruct>SelectedConstructsIConstruct[]SelectedConstructs*[]IConstruct#
The constructs that match the selector in the given scope.

Methods ​

apply(...mixins: IMixin[]): MixinApplicator // chainabledef apply(self, mixins: IMixin) -> MixinApplicatorpublic MixinApplicator apply(IMixin mixins)public MixinApplicator Apply(IMixin mixins)func Apply(Mixins IMixin) MixinApplicator#
Applies a mixin to selected constructs.
requireAll(): MixinApplicator // chainabledef require_all(self, ) -> MixinApplicatorpublic MixinApplicator requireAll()public MixinApplicator RequireAll()func RequireAll() MixinApplicator#
Requires all selected constructs to support the applied mixins.

Will only check for future call of apply(). Set this before calling apply() to take effect.

example
ts
Mixins.of(scope)
  .requireAll()
  .apply(new MyMixin());
requireAny(): MixinApplicator // chainabledef require_any(self, ) -> MixinApplicatorpublic MixinApplicator requireAny()public MixinApplicator RequireAny()func RequireAny() MixinApplicator#
Requires at least one mixin to be successfully applied.

Will only check for future call of apply(). Set this before calling apply() to take effect.

example
ts
Mixins.of(scope)
  .requireAny()
  .apply(new MyMixin());