int8.go 456 B

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