// If configuredValue is zero, use defaultValue instead.
510710
func timeoutWithDefault(configuredValue time.Duration, defaultValue time.Duration) time.Duration {
	if configuredValue == 0 {
		return defaultValue
	}
	return configuredValue
}
458794
func (s *ProvisioningArtifactParameter) SetDefaultValue(v string) *ProvisioningArtifactParameter {
	s.DefaultValue = &v
	return s
}
1186408
func newKeyValueFromJSONConfig(cfg jsonconfig.Obj) (sorted.KeyValue, error) {
	file := cfg.RequiredString("file")
	if err := cfg.Validate(); err != nil {
		return nil, err
	}
	opts := &kv.Options{}
	db, err := kvutil.Open(file, opts)
	if err != nil {
		return nil, err
	}
	is := &kvis{
		db:   db,
		opts: opts,
		path: file,
	}
	return is, nil
}
221862
func (s *MetricTransformation) SetDefaultValue(v float64) *MetricTransformation {
	s.DefaultValue = &v
	return s
}
1195510
func (prefs Preferences) SetValue(key string, value string) (Preferences, error) {
	parts := strings.Split(key, ".")
	section := parts[0] // [Core|Default]
	key = parts[1]      // Rest of the property name

	// Identify category struct by ini tag name [Core|Default]
	values := reflect.ValueOf(&prefs).Elem()
	target := findElemByName(values, section)

	// Identify field to update by ini tag name
	values = reflect.ValueOf(&prefs).Elem().FieldByName(target)
	if values == reflect.Zero(reflect.TypeOf(values)).Interface() {
		return prefs, errs.NewExitError("error: unknown section `" + section + "`")
	}
	property := findElemByName(values, key)

	// Ensure the field is not zero
	field := values.Addr().Elem().FieldByName(property)
	if field == reflect.Zero(reflect.TypeOf(field)).Interface() {
		return prefs, errs.NewExitError("error: unknown property `" + key + "`")
	}

	switch field.Type() {
	case reflect.TypeOf(true):
		v := true
		if value != "true" && value != "1" {
			v = false
		}
		field.SetBool(v)
	default:
		field.SetString(value)
	}

	return prefs, nil
}
1301713
func (bc *BooleanConstraint) Default(v interface{}) *BooleanConstraint {
	bc.defaultValue.initialized = true
	bc.defaultValue.value = v
	return bc
}
1178600
func (af *aggFunction) CalculateDefaultValue(schema Schema, ctx context.Context) (types.Datum, bool) {
	return types.Datum{}, false
}
440644
func defaultExtensionValue(extension *ExtensionDesc) (interface{}, error) {
	if extension.ExtensionType == nil {
		// incomplete descriptor, so no default
		return nil, ErrMissingExtension
	}

	t := reflect.TypeOf(extension.ExtensionType)
	props := extensionProperties(extension)

	sf, _, err := fieldDefault(t, props)
	if err != nil {
		return nil, err
	}

	if sf == nil || sf.value == nil {
		// There is no default value.
		return nil, ErrMissingExtension
	}

	if t.Kind() != reflect.Ptr {
		// We do not need to return a Ptr, we can directly return sf.value.
		return sf.value, nil
	}

	// We need to return an interface{} that is a pointer to sf.value.
	value := reflect.New(t).Elem()
	value.Set(reflect.New(value.Type().Elem()))
	if sf.kind == reflect.Int32 {
		// We may have an int32 or an enum, but the underlying data is int32.
		// Since we can't set an int32 into a non int32 reflect.value directly
		// set it as a int32.
		value.Elem().SetInt(int64(sf.value.(int32)))
	} else {
		value.Elem().Set(reflect.ValueOf(sf.value))
	}
	return value.Interface(), nil
}
1334559
func (c *JSONConfigContainer) DefaultString(key string, defaultval string) string {
	// TODO FIXME should not use "" to replace non existence
	if v := c.String(key); v != "" {
		return v
	}
	return defaultval
}
131473
func (s *TemplateParameter) SetDefaultValue(v string) *TemplateParameter {
	s.DefaultValue = &v
	return s
}
988459
func (s *StringRule) Default() ctypes.ConfigValue {
	if s.default_ != nil {
		return ctypes.ConfigValueStr{Value: *s.default_}
	}
	return nil
}
229615
func (c *ConfigFile) MustValue(section, key string, defaultVal ...string) string {
	val, err := c.GetValue(section, key)
	if len(defaultVal) > 0 && (err != nil || len(val) == 0) {
		return defaultVal[0]
	}
	return val
}
87143
func ValueOverrides(raw []byte) InstallOption {
	return func(opts *options) {
		opts.instReq.Values = &cpb.Config{Raw: string(raw)}
	}
}
61367
func (sc *StringConstraint) Default(v interface{}) *StringConstraint {
	sc.defaultValue.initialized = true
	sc.defaultValue.value = v
	return sc
}
778653
func SetConfigValue(section, key, val string) error {
	Cfg.SetValue(section, key, val)
	if err := goconfig.SaveConfigFile(Cfg, ConfigFile); err != nil {
		return fmt.Errorf("fail to set config value(%s:%s=%s): %v", section, key, val, err)
	}
	return nil
}
1294216
func (s Session) GetDefault(key string, value interface{}, defaultValue interface{}) interface{} {
	v, e := s.GetInto(key, value, false)
	if e != nil {
		v = defaultValue
	}
	return v
}
697569
func (s *TextOptions) SetDefaultValue(v string) *TextOptions {
	s.DefaultValue = &v
	return s
}