gitee.com/zhongguo168a/gocodes@v0.0.0-20230609140523-e1828349603f/datax/reflectx/ref-desc-type-basic.go (about)

     1  package reflectx
     2  
     3  import (
     4  	"gitee.com/zhongguo168a/gocodes/datax/schemax"
     5  	"gitee.com/zhongguo168a/gocodes/datax/schemax/basickind"
     6  )
     7  
     8  type BasicTypeRef struct {
     9  }
    10  
    11  func (f *BasicTypeRef) RefHas(field string) bool {
    12  	switch field {
    13  	case "Kind":
    14  		return true
    15  	}
    16  	return false
    17  }
    18  
    19  func (f *BasicTypeRef) RefGet(target IRefObject, BasicType string) (val interface{}, isNil bool) {
    20  	obj := target.(*schemax.BasicType)
    21  	switch BasicType {
    22  	case "Kind":
    23  		return obj.Kind, false
    24  	}
    25  	return nil, true
    26  }
    27  
    28  func (f *BasicTypeRef) RefSet(target IRefObject, BasicType string, val interface{}) {
    29  	obj := target.(*schemax.BasicType)
    30  	switch BasicType {
    31  	case "Kind":
    32  		obj.Kind = basickind.Kind(val.(int))
    33  	}
    34  	return
    35  }
    36  
    37  func (f *BasicTypeRef) RefNew() IRefObject {
    38  	return &schemax.BasicType{}
    39  }
    40  
    41  func (f *BasicTypeRef) RefType() string {
    42  	return "basic"
    43  }