gitlab.com/evatix-go/core@v1.3.55/coreinstruction/BaseIdentifier.go (about) 1 package coreinstruction 2 3 import ( 4 "regexp" 5 "strings" 6 7 "gitlab.com/evatix-go/core/internal/strutilinternal" 8 ) 9 10 type BaseIdentifier struct { 11 Id string `json:"Id"` 12 } 13 14 func NewIdentifier(id string) *BaseIdentifier { 15 return &BaseIdentifier{Id: id} 16 } 17 18 func (identifier *BaseIdentifier) IdString() string { 19 return identifier.Id 20 } 21 22 func (identifier *BaseIdentifier) IsIdEmpty() bool { 23 return identifier.Id == "" 24 } 25 26 func (identifier *BaseIdentifier) IsIdWhitespace() bool { 27 return strutilinternal.IsNullOrEmptyOrWhitespace(&identifier.Id) 28 } 29 30 func (identifier *BaseIdentifier) IsId(id string) bool { 31 return identifier.Id == id 32 } 33 34 func (identifier *BaseIdentifier) IsIdCaseInsensitive(idInsensitive string) bool { 35 return strings.EqualFold(identifier.Id, idInsensitive) 36 } 37 38 func (identifier *BaseIdentifier) IsIdContains(idContains string) bool { 39 return strings.Contains(identifier.Id, idContains) 40 41 } 42 43 func (identifier *BaseIdentifier) IsIdRegexMatches(regex *regexp.Regexp) bool { 44 return regex.MatchString(identifier.Id) 45 } 46 47 func (identifier *BaseIdentifier) Clone() *BaseIdentifier { 48 return &BaseIdentifier{ 49 Id: identifier.Id, 50 } 51 }