github.com/sandwich-go/boost@v1.3.29/misc/cloud/gen_storageoptions_optiongen.go (about)

     1  // Code generated by optiongen. DO NOT EDIT.
     2  // optiongen: github.com/timestee/optiongen
     3  
     4  package cloud
     5  
     6  // StorageOptions should use NewStorageOptions to initialize it
     7  type StorageOptions struct {
     8  	// annotation@Region(comment="云存储的Region")
     9  	Region string
    10  }
    11  
    12  // NewStorageOptions new StorageOptions
    13  func NewStorageOptions(opts ...StorageOption) *StorageOptions {
    14  	cc := newDefaultStorageOptions()
    15  	for _, opt := range opts {
    16  		opt(cc)
    17  	}
    18  	if watchDogStorageOptions != nil {
    19  		watchDogStorageOptions(cc)
    20  	}
    21  	return cc
    22  }
    23  
    24  // ApplyOption apply multiple new option
    25  func (cc *StorageOptions) ApplyOption(opts ...StorageOption) {
    26  	for _, opt := range opts {
    27  		opt(cc)
    28  	}
    29  }
    30  
    31  // StorageOption option func
    32  type StorageOption func(cc *StorageOptions)
    33  
    34  // WithRegion 云存储的Region
    35  func WithRegion(v string) StorageOption {
    36  	return func(cc *StorageOptions) {
    37  		cc.Region = v
    38  	}
    39  }
    40  
    41  // InstallStorageOptionsWatchDog the installed func will called when NewStorageOptions  called
    42  func InstallStorageOptionsWatchDog(dog func(cc *StorageOptions)) { watchDogStorageOptions = dog }
    43  
    44  // watchDogStorageOptions global watch dog
    45  var watchDogStorageOptions func(cc *StorageOptions)
    46  
    47  // newDefaultStorageOptions new default StorageOptions
    48  func newDefaultStorageOptions() *StorageOptions {
    49  	cc := &StorageOptions{}
    50  
    51  	for _, opt := range [...]StorageOption{
    52  		WithRegion(""),
    53  	} {
    54  		opt(cc)
    55  	}
    56  
    57  	return cc
    58  }
    59  
    60  // all getter func
    61  func (cc *StorageOptions) GetRegion() string { return cc.Region }
    62  
    63  // StorageOptionsVisitor visitor interface for StorageOptions
    64  type StorageOptionsVisitor interface {
    65  	GetRegion() string
    66  }
    67  
    68  // StorageOptionsInterface visitor + ApplyOption interface for StorageOptions
    69  type StorageOptionsInterface interface {
    70  	StorageOptionsVisitor
    71  	ApplyOption(...StorageOption)
    72  }