1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-09 03:37:37 -05:00
v2fly/common/serial/string.go

37 lines
767 B
Go
Raw Normal View History

2015-12-02 10:19:39 -05:00
package serial
2016-01-15 09:23:12 -05:00
import (
"strings"
)
2015-12-03 10:57:23 -05:00
// An interface for any objects that has string presentation.
2015-12-02 10:19:39 -05:00
type String interface {
String() string
}
type StringLiteral string
2016-01-15 09:23:12 -05:00
func NewStringLiteral(str String) StringLiteral {
return StringLiteral(str.String())
}
2016-01-17 10:20:49 -05:00
func (this StringLiteral) Contains(str String) bool {
return strings.Contains(this.String(), str.String())
}
2015-12-02 10:19:39 -05:00
func (this StringLiteral) String() string {
return string(this)
}
2016-01-15 09:23:12 -05:00
func (this StringLiteral) ToLower() StringLiteral {
return StringLiteral(strings.ToLower(string(this)))
}
func (this StringLiteral) ToUpper() StringLiteral {
return StringLiteral(strings.ToUpper(string(this)))
}
func (this StringLiteral) TrimSpace() StringLiteral {
return StringLiteral(strings.TrimSpace(string(this)))
}