additional methods for FieldsMask and ChangedFields
This commit is contained in:
parent
4fd35a4f3a
commit
abe543a275
|
@ -27,6 +27,10 @@ func (cf ChangedFields) Changed(field string) bool {
|
|||
}
|
||||
|
||||
func (cf *ChangedFields) SetChanged(fields ...string) {
|
||||
if cf.fieldNames == nil {
|
||||
cf.fieldNames = make(map[string]struct{})
|
||||
}
|
||||
|
||||
for _, field := range fields {
|
||||
cf.fieldNames[field] = struct{}{}
|
||||
}
|
||||
|
@ -35,3 +39,7 @@ func (cf *ChangedFields) SetChanged(fields ...string) {
|
|||
func (cf ChangedFields) Empty() bool {
|
||||
return len(cf.fieldNames) == 0
|
||||
}
|
||||
|
||||
func (cf ChangedFields) IsNil() bool {
|
||||
return cf.fieldNames == nil
|
||||
}
|
||||
|
|
|
@ -52,6 +52,18 @@ func (fm FieldsMask) IsFilled() bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func (fm *FieldsMask) Reset() {
|
||||
for i := range fm.parts {
|
||||
fm.parts[i] = 0
|
||||
}
|
||||
}
|
||||
|
||||
func (fm *FieldsMask) SetChangedAll() {
|
||||
for i := range fm.parts {
|
||||
fm.parts[i] = 1<<64 - 1
|
||||
}
|
||||
}
|
||||
|
||||
func (fm FieldsMask) partIndex(index uint64) uint64 {
|
||||
return index / FieldsMaskPartBitSize
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue