github.com/antihax/goesi@v0.0.0-20240126031043-6c54d0cb7f95/optional/int64.go (about)

     1  package optional
     2  
     3  type Int64 struct {
     4  	isSet bool
     5  	value int64
     6  }
     7  
     8  func NewInt64(value int64) Int64 {
     9  	return Int64{
    10  		true,
    11  		value,
    12  	}
    13  }
    14  
    15  // EmptyInt64 returns a new Int64 that does not have a value set.
    16  func EmptyInt64() Int64 {
    17  	return Int64{
    18  		false,
    19  		0,
    20  	}
    21  }
    22  
    23  func (i Int64) IsSet() bool {
    24  	return i.isSet
    25  }
    26  
    27  func (i Int64) Value() int64 {
    28  	return i.value
    29  }
    30  
    31  func (i Int64) Default(defaultValue int64) int64 {
    32  	if i.isSet {
    33  		return i.value
    34  	}
    35  	return defaultValue
    36  }