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)))
|
|
|
|
}
|