MCPcopy Create free account
hub / github.com/apache/fory / setHas

Method setHas

go/fory/optional_serializer.go:178–192  ·  view source on GitHub ↗
(value reflect.Value, has bool)

Source from the content-addressed store, hash-verified

176}
177
178func (s *optionalSerializer) setHas(value reflect.Value, has bool) {
179 value = s.unwrap(value)
180 if !value.IsValid() {
181 return
182 }
183 if value.CanAddr() {
184 hasPtr := (*bool)(unsafe.Add(unsafe.Pointer(value.UnsafeAddr()), s.hasOffset))
185 *hasPtr = has
186 return
187 }
188 field := value.FieldByName("has")
189 if field.IsValid() && field.CanSet() {
190 field.SetBool(has)
191 }
192}
193
194func (s *optionalSerializer) Write(ctx *WriteContext, refMode RefMode, writeType bool, hasGenerics bool, value reflect.Value) {
195 if !s.has(value) {

Callers 2

ReadMethod · 0.95
ReadDataMethod · 0.95

Calls 2

unwrapMethod · 0.95
AddMethod · 0.45

Tested by

no test coverage detected