1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 10:08:15 -05:00
v2fly/common/serial/string.go
2016-01-17 15:20:49 +00:00

37 lines
767 B
Go

package serial
import (
"strings"
)
// An interface for any objects that has string presentation.
type String interface {
String() string
}
type StringLiteral string
func NewStringLiteral(str String) StringLiteral {
return StringLiteral(str.String())
}
func (this StringLiteral) Contains(str String) bool {
return strings.Contains(this.String(), str.String())
}
func (this StringLiteral) String() string {
return string(this)
}
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)))
}