gitlab.com/evatix-go/core@v1.3.55/coreinstruction/Rename.go (about) 1 package coreinstruction 2 3 import ( 4 "fmt" 5 6 "gitlab.com/evatix-go/core/constants" 7 ) 8 9 type Rename struct { 10 Existing string `json:"Existing,omitempty"` 11 New string `json:"New,omitempty"` 12 } 13 14 func (it *Rename) IsNull() bool { 15 return it == nil 16 } 17 18 func (it *Rename) IsExistingEmpty() bool { 19 return it == nil || it.Existing == "" 20 } 21 22 func (it *Rename) IsNewEmpty() bool { 23 return it == nil || it.New == "" 24 } 25 26 func (it Rename) String() string { 27 if it.IsNull() { 28 return "Rename null!" 29 } 30 31 return fmt.Sprintf( 32 constants.RenameFormat, 33 it.Existing, 34 it.New) 35 } 36 37 func (it *Rename) SourceDestination() *SourceDestination { 38 if it == nil { 39 return nil 40 } 41 42 return &SourceDestination{ 43 Source: it.Existing, 44 Destination: it.New, 45 } 46 } 47 48 func (it Rename) FromName() string { 49 return it.Existing 50 } 51 52 func (it Rename) ExistingName() string { 53 return it.Existing 54 } 55 56 func (it Rename) NewName() string { 57 return it.New 58 } 59 60 func (it Rename) ToName() string { 61 return it.New 62 } 63 64 func (it *Rename) SetFromName(form string) { 65 it.Existing = form 66 } 67 68 func (it *Rename) SetToName(to string) { 69 it.New = to 70 } 71 72 func (it *Rename) FromTo() *FromTo { 73 if it == nil { 74 return nil 75 } 76 77 return &FromTo{ 78 From: it.Existing, 79 To: it.New, 80 } 81 } 82 83 func (it *Rename) Clone() *Rename { 84 if it == nil { 85 return nil 86 } 87 88 return &Rename{ 89 Existing: it.Existing, 90 New: it.New, 91 } 92 }