gitlab.com/evatix-go/core@v1.3.55/coredata/coredynamic/LeftRight.go (about) 1 package coredynamic 2 3 import ( 4 "gitlab.com/evatix-go/core/coredata/corejson" 5 "gitlab.com/evatix-go/core/internal/reflectinternal" 6 ) 7 8 type LeftRight struct { 9 Left, Right interface{} 10 } 11 12 func (it *LeftRight) IsEmpty() bool { 13 return it == nil || 14 reflectinternal.IsNull(it.Left) && 15 reflectinternal.IsNull(it.Right) 16 } 17 18 func (it *LeftRight) HasAnyItem() bool { 19 return !it.IsEmpty() 20 } 21 22 func (it *LeftRight) HasLeft() bool { 23 return it != nil && 24 reflectinternal.IsNull(it.Left) 25 } 26 27 func (it *LeftRight) HasRight() bool { 28 return it != nil && 29 reflectinternal.IsNull(it.Right) 30 } 31 32 func (it *LeftRight) IsLeftEmpty() bool { 33 return it == nil || 34 reflectinternal.IsNull(it.Left) 35 } 36 37 func (it *LeftRight) IsRightEmpty() bool { 38 return it == nil || 39 reflectinternal.IsNull(it.Right) 40 } 41 42 func (it *LeftRight) LeftReflectSet( 43 toPointerOrBytesPointer interface{}, 44 ) error { 45 return ReflectSetFromTo(it.Left, toPointerOrBytesPointer) 46 } 47 48 func (it *LeftRight) RightReflectSet( 49 toPointerOrBytesPointer interface{}, 50 ) error { 51 return ReflectSetFromTo(it.Right, toPointerOrBytesPointer) 52 } 53 54 func (it *LeftRight) DeserializeLeft() *corejson.Result { 55 return corejson.NewPtr(it.Left) 56 } 57 58 func (it *LeftRight) DeserializeRight() *corejson.Result { 59 return corejson.NewPtr(it.Right) 60 } 61 62 func (it *LeftRight) LeftToDynamic() *Dynamic { 63 return NewDynamicPtr(it.Left, true) 64 } 65 66 func (it *LeftRight) RightToDynamic() *Dynamic { 67 return NewDynamicPtr(it.Right, true) 68 } 69 70 func (it *LeftRight) TypeStatus() TypeStatus { 71 return TypeSameStatus(it.Left, it.Right) 72 }