gitlab.com/evatix-go/core@v1.3.55/coreimpl/enumimpl/KeyValInteger.go (about) 1 package enumimpl 2 3 import ( 4 "fmt" 5 6 "gitlab.com/evatix-go/core/constants" 7 ) 8 9 type KeyValInteger struct { 10 Key string 11 ValueInteger int 12 } 13 14 func (it KeyValInteger) WrapKey() string { 15 return toJsonName(it.Key) 16 } 17 18 func (it KeyValInteger) WrapValue() string { 19 return toJsonName(it.ValueInteger) 20 } 21 22 func (it KeyValInteger) KeyAnyVal() KeyAnyVal { 23 return KeyAnyVal{ 24 Key: it.Key, 25 AnyValue: it.ValueInteger, 26 } 27 } 28 29 func (it KeyValInteger) IsString() bool { 30 return it.ValueInteger == constants.MinInt 31 } 32 33 func (it KeyValInteger) String() string { 34 if it.IsString() { 35 // stringer 36 return fmt.Sprintf( 37 constants.StringEnumNameValueFormat, 38 it.Key, 39 ) 40 } 41 42 return fmt.Sprintf( 43 constants.EnumNameValueFormat, 44 it.Key, 45 it.ValueInteger) 46 }