You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
828 B
Go
33 lines
828 B
Go
1 year ago
|
package wrapper
|
||
|
|
||
|
import (
|
||
|
"git.noahlan.cn/noahlan/ntool/nmap"
|
||
|
"reflect"
|
||
|
)
|
||
|
|
||
|
type TypeWrapper interface {
|
||
|
// Supported 转换器是否支持对应属性类型
|
||
|
Supported(value reflect.Value) bool
|
||
|
// Wrap 将对应属性转换为需要类型的值
|
||
|
Wrap(valueElem reflect.Value, index int, tagMap nmap.SMap) reflect.Value
|
||
|
// Set 设置对应属性值
|
||
|
Set(fieldElem reflect.Value, value any, tagMap nmap.SMap)
|
||
|
}
|
||
|
|
||
|
var _ TypeWrapper = (*BaseTypeWrapper)(nil)
|
||
|
|
||
|
type BaseTypeWrapper struct {
|
||
|
}
|
||
|
|
||
|
func (w *BaseTypeWrapper) Supported(value reflect.Value) bool {
|
||
|
return false
|
||
|
}
|
||
|
|
||
|
func (w *BaseTypeWrapper) Wrap(valueElem reflect.Value, index int, tagMap nmap.SMap) reflect.Value {
|
||
|
panic("implement me")
|
||
|
}
|
||
|
|
||
|
func (w *BaseTypeWrapper) Set(fieldElem reflect.Value, value any, tagMap nmap.SMap) {
|
||
|
fieldElem.Set(reflect.ValueOf(value))
|
||
|
}
|