This commit is contained in:
crusader 2017-12-23 03:24:42 +09:00
parent 8bea46c526
commit 88d853bdb7
5 changed files with 29 additions and 23 deletions

View File

@ -1,5 +1,6 @@
import {
ClassType,
TypeUtil,
} from '@overflow/commons/core/type';
import {
@ -8,14 +9,14 @@ import {
} from '@overflow/commons/core/reflect';
export abstract class AccessibleObject implements AnnotatedElement {
private _annotations: Map<any, Annotation>;
private _annotations: Map<ClassType, Annotation>;
protected constructor() {
this._annotations = new Map();
}
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 {
@ -23,10 +24,10 @@ export abstract class AccessibleObject implements AnnotatedElement {
}
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;
}
@ -34,7 +35,7 @@ export abstract class AccessibleObject implements AnnotatedElement {
return this.getOwnAnnotation(annotationClass);
}
public getAnnotations(): Map<any, Annotation> {
public getAnnotations(): Map<ClassType, Annotation> {
return this.getOwnAnnotations();
}

View File

@ -11,7 +11,7 @@ export interface AnnotatedElement {
isAnnotationPresent<AnnotationType extends Annotation>(annotationClass: ClassType<AnnotationType>): boolean;
getOwnAnnotation<AnnotationType extends Annotation>(annotationClass: ClassType<AnnotationType>): AnnotationType;
getOwnAnnotations(): Map<any, Annotation>;
getOwnAnnotations(): Map<ClassType, Annotation>;
getAnnotation<AnnotationType extends Annotation>(annotationClass: ClassType<AnnotationType>): AnnotationType;
getAnnotations(): Map<any, Annotation>;
getAnnotations(): Map<ClassType, Annotation>;
}

View File

@ -10,3 +10,8 @@ export interface Annotation {
descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void;
parameterDecorator?(target: Object, propertyKey: PropertyKeyType, parameterIndex: number): void;
}
export abstract class Annotation {
}
export default Annotation;

View File

@ -1,19 +1,19 @@
import {
PropertyKeyType,
} from '@overflow/commons/core/type';
// import {
// PropertyKeyType,
// } from '@overflow/commons/core/type';
import {
Class,
Executable,
} from '@overflow/commons/core/reflect';
// import {
// Class,
// Executable,
// } from '@overflow/commons/core/reflect';
export class Constructor extends Executable {
// export class Constructor extends Executable {
public constructor(declaringClazz: Class, parameterTypes: any[]) {
super(declaringClazz, parameterTypes);
}
// public constructor(declaringClazz: Class, parameterTypes: any[]) {
// super(declaringClazz, parameterTypes);
// }
public getName(): PropertyKeyType {
return this.getDeclaringClass().getName();
}
}
// public getName(): PropertyKeyType {
// return this.getDeclaringClass().getName();
// }
// }

View File

@ -59,7 +59,7 @@ export default class LPCReducer {
}
console.log(`actionMapping-value: ${ama.attributes.value}`);
clazz.getMethods().forEach(method => {
clazz.getOwnMethods().forEach(method => {
let restAPIAnnotation: RestAPIAnnotation = method.getOwnAnnotation(RestAPIAnnotation);
let rpcAPIAnnotation: RpcAPIAnnotation = method.getOwnAnnotation(RpcAPIAnnotation);
if (restAPIAnnotation) {