ing
This commit is contained in:
parent
8bea46c526
commit
88d853bdb7
|
@ -1,5 +1,6 @@
|
||||||
import {
|
import {
|
||||||
ClassType,
|
ClassType,
|
||||||
|
TypeUtil,
|
||||||
} from '@overflow/commons/core/type';
|
} from '@overflow/commons/core/type';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
@ -8,14 +9,14 @@ import {
|
||||||
} from '@overflow/commons/core/reflect';
|
} from '@overflow/commons/core/reflect';
|
||||||
|
|
||||||
export abstract class AccessibleObject implements AnnotatedElement {
|
export abstract class AccessibleObject implements AnnotatedElement {
|
||||||
private _annotations: Map<any, Annotation>;
|
private _annotations: Map<ClassType, Annotation>;
|
||||||
|
|
||||||
protected constructor() {
|
protected constructor() {
|
||||||
this._annotations = new Map();
|
this._annotations = new Map();
|
||||||
}
|
}
|
||||||
|
|
||||||
public _addAnnotation<AnnotationType extends Annotation>(annotation: AnnotationType): void {
|
public _addAnnotation<AnnotationType extends Annotation>(annotation: AnnotationType): void {
|
||||||
this._annotations.set((<any>annotation).prototype, annotation);
|
this._annotations.set(TypeUtil.getClass(annotation), annotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public isAnnotationPresent<AnnotationType extends Annotation>(annotationClass: ClassType<AnnotationType>): boolean {
|
public isAnnotationPresent<AnnotationType extends Annotation>(annotationClass: ClassType<AnnotationType>): boolean {
|
||||||
|
@ -23,10 +24,10 @@ export abstract class AccessibleObject implements AnnotatedElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
public getOwnAnnotation<AnnotationType extends Annotation>(annotationClass: ClassType<AnnotationType>): AnnotationType {
|
public getOwnAnnotation<AnnotationType extends Annotation>(annotationClass: ClassType<AnnotationType>): AnnotationType {
|
||||||
return <AnnotationType>this._annotations.get(annotationClass.prototype);
|
return <AnnotationType>this._annotations.get(annotationClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getOwnAnnotations(): Map<any, Annotation> {
|
public getOwnAnnotations(): Map<ClassType, Annotation> {
|
||||||
return this._annotations;
|
return this._annotations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +35,7 @@ export abstract class AccessibleObject implements AnnotatedElement {
|
||||||
return this.getOwnAnnotation(annotationClass);
|
return this.getOwnAnnotation(annotationClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getAnnotations(): Map<any, Annotation> {
|
public getAnnotations(): Map<ClassType, Annotation> {
|
||||||
return this.getOwnAnnotations();
|
return this.getOwnAnnotations();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ export interface AnnotatedElement {
|
||||||
|
|
||||||
isAnnotationPresent<AnnotationType extends Annotation>(annotationClass: ClassType<AnnotationType>): boolean;
|
isAnnotationPresent<AnnotationType extends Annotation>(annotationClass: ClassType<AnnotationType>): boolean;
|
||||||
getOwnAnnotation<AnnotationType extends Annotation>(annotationClass: ClassType<AnnotationType>): AnnotationType;
|
getOwnAnnotation<AnnotationType extends Annotation>(annotationClass: ClassType<AnnotationType>): AnnotationType;
|
||||||
getOwnAnnotations(): Map<any, Annotation>;
|
getOwnAnnotations(): Map<ClassType, Annotation>;
|
||||||
getAnnotation<AnnotationType extends Annotation>(annotationClass: ClassType<AnnotationType>): AnnotationType;
|
getAnnotation<AnnotationType extends Annotation>(annotationClass: ClassType<AnnotationType>): AnnotationType;
|
||||||
getAnnotations(): Map<any, Annotation>;
|
getAnnotations(): Map<ClassType, Annotation>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,3 +10,8 @@ export interface Annotation {
|
||||||
descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void;
|
descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void;
|
||||||
parameterDecorator?(target: Object, propertyKey: PropertyKeyType, parameterIndex: number): void;
|
parameterDecorator?(target: Object, propertyKey: PropertyKeyType, parameterIndex: number): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export abstract class Annotation {
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Annotation;
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
import {
|
// import {
|
||||||
PropertyKeyType,
|
// PropertyKeyType,
|
||||||
} from '@overflow/commons/core/type';
|
// } from '@overflow/commons/core/type';
|
||||||
|
|
||||||
import {
|
// import {
|
||||||
Class,
|
// Class,
|
||||||
Executable,
|
// Executable,
|
||||||
} from '@overflow/commons/core/reflect';
|
// } from '@overflow/commons/core/reflect';
|
||||||
|
|
||||||
export class Constructor extends Executable {
|
// export class Constructor extends Executable {
|
||||||
|
|
||||||
public constructor(declaringClazz: Class, parameterTypes: any[]) {
|
// public constructor(declaringClazz: Class, parameterTypes: any[]) {
|
||||||
super(declaringClazz, parameterTypes);
|
// super(declaringClazz, parameterTypes);
|
||||||
}
|
// }
|
||||||
|
|
||||||
public getName(): PropertyKeyType {
|
// public getName(): PropertyKeyType {
|
||||||
return this.getDeclaringClass().getName();
|
// return this.getDeclaringClass().getName();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
|
@ -59,7 +59,7 @@ export default class LPCReducer {
|
||||||
}
|
}
|
||||||
console.log(`actionMapping-value: ${ama.attributes.value}`);
|
console.log(`actionMapping-value: ${ama.attributes.value}`);
|
||||||
|
|
||||||
clazz.getMethods().forEach(method => {
|
clazz.getOwnMethods().forEach(method => {
|
||||||
let restAPIAnnotation: RestAPIAnnotation = method.getOwnAnnotation(RestAPIAnnotation);
|
let restAPIAnnotation: RestAPIAnnotation = method.getOwnAnnotation(RestAPIAnnotation);
|
||||||
let rpcAPIAnnotation: RpcAPIAnnotation = method.getOwnAnnotation(RpcAPIAnnotation);
|
let rpcAPIAnnotation: RpcAPIAnnotation = method.getOwnAnnotation(RpcAPIAnnotation);
|
||||||
if (restAPIAnnotation) {
|
if (restAPIAnnotation) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user