Class: AnnotationFactory
AspectJS • Docs
Class: AnnotationFactory
Factory to create an Annotation.
Constructors
new AnnotationFactory()
new AnnotationFactory(
groupId
):AnnotationFactory
Create a new AnnotationFactory with the given groupId
. You generaly have to choose a groupId
that identifies your project or is unique to your organisation. The groupId
will be used as a part of the signature for the created annotations.
Parameters
• groupId: string
The groupId of this factory.
Returns
Defined in
packages/common/src/annotation/factory/annotation.factory.ts:60
Methods
create()
create(type, name)
create<
T
,S
>(type
?,name
?):Annotation
<T
,S
>
Create an annotation with the given type
and name
.
Type Parameters
• T extends AnnotationKind
the type of annotation to create
• S extends AnnotationStub
<T
>
the signature of the annotation to create. It defines the name of the annotation and the set of accepted parameters.
Parameters
• type?: T
The type of annotation to create.
• name?: string
The name of the annotation to create.
Returns
Annotation
<T
, S
>
Example
const LogErrors = new AnnotationFactory('demo').create();
// Or:
const LogErrors = new AnnotationFactory('demo').create(AnnotationKind.METHOD, 'LogErrors');
Defined in
packages/common/src/annotation/factory/annotation.factory.ts:81
create(name)
create<
S
>(name
?):Annotation
<any
,S
>
Create a new annotation with the given name
and type
. If no annotation type is given, the annotation could be used above classes, methods, properties, attributes and parameters.
Type Parameters
• S extends AnnotationStub
the signature of the annotation to create. It defines the name of the annotation and the set of accepted parameters.
Parameters
• name?: string
The name of the annotation to create.
Returns
Annotation
<any
, S
>
Example
const LogErrors = new AnnotationFactory('demo').create('LogErrors');
Defined in
packages/common/src/annotation/factory/annotation.factory.ts:97
create(type, annotationStub)
create<
T
,S
>(type
?,annotationStub
?):Annotation
<T
,S
>
Create a new annotation wwith the given type and signature. The created annotation accepts the same parameters as with the the provid function. If no annotation type is given, the annotation could be used above classes, methods, properties, attributes and parameters.
Type Parameters
• T extends AnnotationKind
the type of annotation to create
• S extends AnnotationStub
<T
>
the signature of the annotation to create. It defines the name of the annotation and the set of accepted parameters.
Parameters
• type?: T
The type of annotation to create.
• annotationStub?: S
The signature of the annotation to create.
Returns
Annotation
<T
, S
>
Example
const LogErrors = new AnnotationFactory('demo').create(
AnnotationKind.METHOD,
function Log(
level: 'info' | 'warn' | 'error' | 'debug' = 'error',
) {});
Defined in
packages/common/src/annotation/factory/annotation.factory.ts:116
create(annotationStub)
create<
S
>(annotationStub
?):Annotation
<any
,S
>
Create a new annotation with the given signature. The created annotation has the same name as the given function, and accepts the same parameters. If no annotation type is given, the annotation could be used above classes, methods, properties, attributes and parameters.
Type Parameters
• S extends AnnotationStub
the signature of the annotation to create. It defines the name of the annotation and the set of accepted parameters.
Parameters
• annotationStub?: S
The signature of the annotation to create.
Returns
Annotation
<any
, S
>
Example
const LogErrors = new AnnotationFactory('demo').create(
AnnotationKind.METHOD,
function Log(
level: 'info' | 'warn' | 'error' | 'debug' = 'error',
) {});
Defined in
packages/common/src/annotation/factory/annotation.factory.ts:137
create(options)
create<
T
,S
>(options
?):Annotation
<T
,S
>
Create with the a n annotation.
Type Parameters
• T extends AnnotationKind
the type of annotation to create
• S extends AnnotationStub
<T
>
the signature of the annotation to create. It defines the name of the annotation and the set of accepted parameters.
Parameters
• options?: AnnotationCreateOptions
<T
, S
>
The options for the annotation to create.
Returns
Annotation
<T
, S
>
Defined in
packages/common/src/annotation/factory/annotation.factory.ts:145
Properties
groupId
readonly
groupId:string
The group of this factory. All annotations created by this factory will belong to this group.
Defined in
packages/common/src/annotation/factory/annotation.factory.ts:65