gitlab.com/evatix-go/core@v1.3.55/keymk/newKeyCreator.go (about) 1 package keymk 2 3 import "gitlab.com/evatix-go/core/constants" 4 5 type newKeyCreator struct{} 6 7 func (it *newKeyCreator) Create( 8 option *Option, 9 main string, 10 ) *Key { 11 key := &Key{ 12 option: option, 13 mainName: main, 14 keyChains: make( 15 []string, 16 0, 17 constants.Capacity7), 18 } 19 20 return key 21 } 22 23 func (it *newKeyCreator) PathTemplate( 24 root string, 25 starterKeyChains ...interface{}, 26 ) *Key { 27 return it.All( 28 CurlyBracePathJoinerOption, 29 root, 30 starterKeyChains...) 31 } 32 33 func (it *newKeyCreator) PathTemplateDefault( 34 starterKeyChains ...interface{}, 35 ) *Key { 36 return it.All( 37 CurlyBracePathJoinerOption, 38 constants.PathRootTemplate, 39 starterKeyChains...) 40 } 41 42 func (it *newKeyCreator) PathTemplatePrefixRelativeIdDefault() *Key { 43 return it.All( 44 CurlyBracePathJoinerOption, 45 root, 46 prefix, 47 relative, 48 id) 49 } 50 51 func (it *newKeyCreator) PathTemplatePrefixRelativeIdFileDefault() *Key { 52 return it.All( 53 CurlyBracePathJoinerOption, 54 root, 55 prefix, 56 relative, 57 id, 58 constants.FileKeyword) 59 } 60 61 func (it *newKeyCreator) All( 62 option *Option, 63 main string, 64 starterKeyChains ...interface{}, 65 ) *Key { 66 slice := make([]string, 0, len(starterKeyChains)+DefaultCap) 67 68 key := &Key{ 69 option: option, 70 mainName: main, 71 keyChains: slice, 72 } 73 74 if len(starterKeyChains) > 0 { 75 key.keyChains = appendAnyItemsWithBaseStrings( 76 option.IsSkipEmptyEntry, 77 key.keyChains, 78 starterKeyChains) 79 } 80 81 return key 82 } 83 84 func (it *newKeyCreator) AllStrings( 85 option *Option, 86 main string, 87 starterKeyChains ...string, 88 ) *Key { 89 slice := make([]string, 0, len(starterKeyChains)+DefaultCap) 90 91 key := &Key{ 92 option: option, 93 mainName: main, 94 keyChains: slice, 95 } 96 97 if len(starterKeyChains) > 0 { 98 key.AppendChainStrings(starterKeyChains...) 99 } 100 101 return key 102 } 103 104 func (it *newKeyCreator) StringsWithOptions( 105 option *Option, 106 main string, 107 starterKeyChains ...string, 108 ) *Key { 109 slice := make([]string, 0, len(starterKeyChains)+DefaultCap) 110 111 key := &Key{ 112 option: option, 113 mainName: main, 114 keyChains: slice, 115 } 116 117 if len(starterKeyChains) > 0 { 118 key.AppendChainStrings(starterKeyChains...) 119 } 120 121 return key 122 } 123 124 func (it *newKeyCreator) Parenthesis( 125 main string, 126 starterKeyChains ...interface{}, 127 ) *Key { 128 return it.All( 129 ParenthesisJoinerOption, 130 main, 131 starterKeyChains...) 132 } 133 134 func (it *newKeyCreator) ParenthesisStrings( 135 main string, 136 starterKeyChains ...string, 137 ) *Key { 138 return it.AllStrings( 139 ParenthesisJoinerOption, 140 main, 141 starterKeyChains...) 142 } 143 144 func (it *newKeyCreator) Curly( 145 main string, 146 starterKeyChains ...interface{}, 147 ) *Key { 148 return it.All( 149 CurlyBraceJoinerOption, 150 main, 151 starterKeyChains...) 152 } 153 154 func (it *newKeyCreator) CurlyStrings( 155 main string, 156 starterKeyChains ...string, 157 ) *Key { 158 return it.AllStrings( 159 CurlyBraceJoinerOption, 160 main, 161 starterKeyChains...) 162 } 163 164 func (it *newKeyCreator) SquareBrackets( 165 main string, 166 starterKeyChains ...interface{}, 167 ) *Key { 168 return it.All( 169 BracketJoinerOption, 170 main, 171 starterKeyChains...) 172 } 173 174 func (it *newKeyCreator) SquareBracketsStrings( 175 main string, 176 starterKeyChains ...string, 177 ) *Key { 178 return it.AllStrings( 179 BracketJoinerOption, 180 main, 181 starterKeyChains...) 182 } 183 184 func (it *newKeyCreator) Default( 185 main string, 186 starterKeyChains ...interface{}, 187 ) *Key { 188 return it.All( 189 JoinerOption, 190 main, 191 starterKeyChains...) 192 } 193 194 func (it *newKeyCreator) DefaultStrings( 195 main string, 196 starterKeyChains ...string, 197 ) *Key { 198 return it.Create( 199 JoinerOption, 200 main). 201 AppendChainStrings(starterKeyChains...) 202 } 203 204 func (it *newKeyCreator) DefaultMain( 205 main string, 206 ) *Key { 207 return it.Create( 208 JoinerOption, 209 main) 210 } 211 212 func (it *newKeyCreator) OptionMain( 213 option *Option, 214 main string, 215 ) *Key { 216 return it.Create( 217 option, 218 main) 219 }