MCPcopy Create free account
hub / github.com/apache/dubbo-go-hessian2 / EncObject

Method EncObject

java_collection.go:63–86  ·  view source on GitHub ↗
(e *Encoder, vv POJO)

Source from the content-addressed store, hash-verified

61type JavaCollectionSerializer struct{}
62
63func (JavaCollectionSerializer) EncObject(e *Encoder, vv POJO) error {
64 var err error
65 v, ok := vv.(JavaCollectionObject)
66 if !ok {
67 return perrors.New("can not be converted into java collection object")
68 }
69 collectionName := v.JavaClassName()
70 if collectionName == "" {
71 return perrors.New("collection name empty")
72 }
73 list := v.Get()
74 length := len(list)
75 typeName := v.JavaClassName()
76 err = writeCollectionBegin(length, typeName, e)
77 if err != nil {
78 return err
79 }
80 for i := 0; i < length; i++ {
81 if err = e.Encode(list[i]); err != nil {
82 return err
83 }
84 }
85 return nil
86}
87
88func (JavaCollectionSerializer) DecObject(d *Decoder, typ reflect.Type, cls *ClassInfo) (interface{}, error) {
89 // for the java impl of hessian encode collections as list, which will not be decoded as object in go impl, this method should not be called

Callers

nothing calls this directly

Calls 4

writeCollectionBeginFunction · 0.85
EncodeMethod · 0.80
JavaClassNameMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected