ing
This commit is contained in:
parent
178b12d303
commit
b94873cf6c
50
registry.go
50
registry.go
|
@ -16,9 +16,11 @@ type Registry interface {
|
|||
GetTypeAnnotations(t reflect.Type) (map[reflect.Type]Annotation, error)
|
||||
GetFieldAnnotation(t reflect.Type, name string, at reflect.Type) (Annotation, error)
|
||||
GetFieldAnnotations(t reflect.Type, name string) (map[reflect.Type]Annotation, error)
|
||||
GetFieldAnnotationsByType(t reflect.Type, at reflect.Type) (map[string]Annotation, error)
|
||||
GetAllFieldAnnotations(t reflect.Type) (map[string]map[reflect.Type]Annotation, error)
|
||||
GetMethodAnnotation(t reflect.Type, name string, at reflect.Type) (Annotation, error)
|
||||
GetMethodAnnotations(t reflect.Type, name string) (map[reflect.Type]Annotation, error)
|
||||
GetMethodAnnotationsByType(t reflect.Type, at reflect.Type) (map[string]Annotation, error)
|
||||
GetAllMethodAnnotations(t reflect.Type) (map[string]map[reflect.Type]Annotation, error)
|
||||
}
|
||||
|
||||
|
@ -347,6 +349,30 @@ func (r *AnnotationRegistry) GetFieldAnnotations(t reflect.Type, name string) (m
|
|||
return as, nil
|
||||
}
|
||||
|
||||
func GetFieldAnnotationsByType(t reflect.Type, at reflect.Type) (map[string]Annotation, error) {
|
||||
return SystemRegistry.GetFieldAnnotationsByType(t, at)
|
||||
}
|
||||
func (r *AnnotationRegistry) GetFieldAnnotationsByType(t reflect.Type, at reflect.Type) (map[string]Annotation, error) {
|
||||
td, err := r.getTypeDefinition(t)
|
||||
if nil != err {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if 0 == len(td.fieldAnnotation) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
as := make(map[string]Annotation, 0)
|
||||
|
||||
for k, v := range td.fieldAnnotation {
|
||||
if a, ok := v[at]; ok {
|
||||
as[k] = a
|
||||
}
|
||||
}
|
||||
|
||||
return as, nil
|
||||
}
|
||||
|
||||
func GetAllFieldAnnotations(t reflect.Type) (map[string]map[reflect.Type]Annotation, error) {
|
||||
return SystemRegistry.GetAllFieldAnnotations(t)
|
||||
}
|
||||
|
@ -410,6 +436,30 @@ func (r *AnnotationRegistry) GetMethodAnnotations(t reflect.Type, name string) (
|
|||
return as, nil
|
||||
}
|
||||
|
||||
func GetMethodAnnotationsByType(t reflect.Type, at reflect.Type) (map[string]Annotation, error) {
|
||||
return SystemRegistry.GetMethodAnnotationsByType(t, at)
|
||||
}
|
||||
func (r *AnnotationRegistry) GetMethodAnnotationsByType(t reflect.Type, at reflect.Type) (map[string]Annotation, error) {
|
||||
td, err := r.getTypeDefinition(t)
|
||||
if nil != err {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if 0 == len(td.methodAnnotation) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
as := make(map[string]Annotation, 0)
|
||||
|
||||
for k, v := range td.methodAnnotation {
|
||||
if a, ok := v[at]; ok {
|
||||
as[k] = a
|
||||
}
|
||||
}
|
||||
|
||||
return as, nil
|
||||
}
|
||||
|
||||
func GetAllMethodAnnotations(t reflect.Type) (map[string]map[reflect.Type]Annotation, error) {
|
||||
return SystemRegistry.GetAllMethodAnnotations(t)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user