int64.go 473 字节
Newer Older
T
TommyLike 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
package optional

type Int64 struct {
	isSet bool
	value int64
}

func NewInt64(value int64) Int64 {
	return Int64{
		true,
		value,
	}
}

// EmptyInt64 returns a new Int64 that does not have a value set.
func EmptyInt64() Int64 {
	return Int64{
		false,
		0,
	}
}

func (i Int64) IsSet() bool {
	return i.isSet
}

func (i Int64) Value() int64 {
	return i.value
}

func (i Int64) Default(defaultValue int64) int64 {
	if i.isSet {
		return i.value
	}
	return defaultValue
}