forked from ebhomengo/niki
1
0
Fork 0
niki/entity/kind_box_status.go

105 lines
2.6 KiB
Go
Raw Normal View History

package entity
type KindBoxStatus uint
const (
KindBoxPendingSendStatus KindBoxStatus = iota + 1
KindBoxSentStatus
KindBoxPendingReceivedStatus
KindBoxReceivedStatus
KindBoxEnumeratedStatus
)
const (
kindBoxPendingSendStatus = "pending-send"
kindBoxSentStatus = "sent"
kindBoxPendingReceivedStatus = "pending-received"
kindBoxReceivedStatus = "received"
kindBoxEnumeratedStatus = "enumerated"
)
func (s KindBoxStatus) String() string {
switch s {
case KindBoxPendingSendStatus:
return kindBoxPendingSendStatus
case KindBoxSentStatus:
return kindBoxSentStatus
case KindBoxPendingReceivedStatus:
return kindBoxPendingReceivedStatus
case KindBoxReceivedStatus:
return kindBoxReceivedStatus
case KindBoxEnumeratedStatus:
return kindBoxEnumeratedStatus
}
return ""
}
func MapToKindBoxStatus(statusStr string) KindBoxStatus {
switch statusStr {
case kindBoxPendingSendStatus:
return KindBoxPendingSendStatus
case kindBoxSentStatus:
return KindBoxSentStatus
case kindBoxPendingReceivedStatus:
return KindBoxPendingReceivedStatus
case kindBoxReceivedStatus:
return KindBoxReceivedStatus
case kindBoxEnumeratedStatus:
return KindBoxEnumeratedStatus
}
return KindBoxStatus(0)
}
package entity
type KindBoxStatus uint
const (
KindBoxPendingSendStatus KindBoxStatus = iota + 1
KindBoxSentStatus
KindBoxPendingReceivedStatus
KindBoxReceivedStatus
KindBoxEnumeratedStatus
)
var kindBoxStatusStrings = map[KindBoxStatus]string{
KindBoxPendingSendStatus: "pending-send",
KindBoxSentStatus: "sent",
KindBoxPendingReceivedStatus: "pending-received",
KindBoxReceivedStatus: "received",
KindBoxEnumeratedStatus: "enumerated",
}
func (s KindBoxStatus) String() string {
return kindBoxStatusStrings[s]
}
// AllKindBoxStatus returns a slice containing all string values of KindBoxStatus.
func AllKindBoxStatus() []string {
statusStrings := make([]string, len(kindBoxStatusStrings))
for status, str := range kindBoxStatusStrings {
statusStrings[int(status)-1] = str
}
return statusStrings
}
// MapToKindBoxStatus converts a string to the corresponding KindBoxStatus value.
func MapToKindBoxStatus(statusStr string) KindBoxStatus {
for status, str := range kindBoxStatusStrings {
if str == statusStr {
return status
}
}
return KindBoxStatus(0)
}
// AllKindBoxStatus returns a slice containing all string values of KindBoxStatus.
func AllKindBoxStatus() []string {
statusStrings := make([]string, len(kindBoxStatusStrings))
for status, str := range kindBoxStatusStrings {
statusStrings[int(status)-1] = str
}
return statusStrings
}