allows overriding the default value of an model property
547826
function (model, property) {
  // TODO the reference to model.api is not available
  if (model.api && model.api.modelPropertyMacro) {
    return model.api.modelPropertyMacro(model, property);
  } else {
    return property.default;
  }
}
206841
protected function assignDefaultValues()
	{
		foreach ($this->defaultValues as $key => $value) {
			$this->model[$key] = $value;
		}

        return true;
	}
571701
function (name, value, schema, options, callback) {

    var err
        , nullable = false
        , valCount = 0;

    // Set default values
    if (options && options.partial !== true) {
        if (schema.hasOwnProperty('default') && value === undefined) {
            if ((_.isString(schema.default) || _.isBoolean(schema.default) || _.isNumber(schema.default)) || (schema.hasOwnProperty('nullable') && schema.nullable === true && _.isNull(schema.default))) {
                value = schema.default;
            }
            else {
                if (_.isFunction(schema.default)) {
                    value = (schema.default)();
                }
                else {
                    err = _.assign({
                        code: 'UnexpectedDefaultValue',
                        'id': name,
                        msg: name + ' default value is faulty. ' + typeof(schema.default) + ' given but not expected'
                    }, err);
                }
            }
        }
    }
    if (value !== undefined) {

        // Check if null value set and is allowed
        if ((schema.hasOwnProperty('nullable') && schema.nullable === true) && value == null) {
            value = null;
        }
        else {
            //Check type
            if (schema.hasOwnProperty('type')) {
                var type = schema.type;
                if (_.isFunction(type) && type.name.toLowerCase()) {
                    type = type.name.toLowerCase();
                }
                var validValue = validationRule.checkType(type, value);
                if (validValue === undefined) {
                    err = _.assign({
                        code: 'UnexpectedType',
                        'id': name,
                        msg: name + ' is unexpected type. ' + typeof(value) + ' given ' + type.toLowerCase() + ' expected'
                    }, err);
                }
                else {
                    value = validValue;
                }
            }

            //Validate single value
            if ((_.isString(value) || _.isBoolean(value) || _.isNumber(value))) {

                //Check minLength
                if (schema.hasOwnProperty('minLength')) {
                    if (validationRule.minLength(schema.minLength, value) == false) {
                        err = _.assign({
                            code: 'MinLengthUnderachieved',
                            'id': name,
                            msg: name + ' length is less than ' + schema.minLength + ' chars'
                        }, err);
                    }
                }

                //Check maxLength
                if (schema.hasOwnProperty('maxLength')) {
                    if (validationRule.maxLength(schema.maxLength, value) == false) {
                        err = _.assign({
                            code: 'MaxLengthExceeded',
                            'id': name,
                            msg: name + ' length is more than ' + schema.maxLength + ' chars'
                        }, err);
                    }
                }


                //Check min
                if (schema.hasOwnProperty('min')) {
                    if (typeof(value) == 'number') {
                        if (validationRule.min(schema.min, value) == false) {
                            err = _.assign({
                                code: 'MinValueUnderachived',
                                'id': name,
                                msg: name + ' value is less than ' + schema.min
                            }, err);
                        }
                    }
                }

                //Check max
                if (schema.hasOwnProperty('max')) {
                    if (typeof(value) == 'number') {
                        if (validationRule.max(schema.max, value) == false) {
                            err = _.assign({
                                code: 'MaxValueExceeded',
                                'id': name,
                                msg: name + ' value is more than ' + schema.max
                            }, err);
                        }
                    }
                }

                //Check allow
                if (schema.hasOwnProperty('allow')) {
                    if (typeof(value) == 'number' || typeof(value) == 'string') {
                        if (validationRule.allow(schema.allow, value) == false) {
                            err = _.assign({
                                code: 'ValueNotAllowed',
                                'id': name,
                                msg: name + ' value \'' + value + '\' is not allowed. Use one of the following values: ' + (schema.allow).join(",")
                            }, err);
                        }
                    }
                }

                //Check deny
                if (schema.hasOwnProperty('deny')) {
                    if (typeof(value) == 'number' || typeof(value) == 'string') {
                        if (validationRule.deny(schema.deny, value) == false) {
                            err = _.assign({
                                code: 'ValueNotAllowed',
                                'id': name,
                                msg: name + ' value \'' + value + '\' is not allowed. Do not use one of the following values: ' + (schema.deny).join(",")
                            });
                        }
                    }
                }

                //Check match
                if (schema.hasOwnProperty('match')) {
                    if (validationRule.match(schema.match, value) == false) {
                        err = _.assign({
                            code: 'PatternMismatch',
                            'id': name,
                            msg: name + ' does not match pattern ' + schema.match + ''
                        }, err);
                    }
                }


                // Convert values
                value = convert.convertValue(schema, value);
            }
        }

        //Validate Array
        if (_.isArray(value)) {
            for (var thisVal in value) {
                valCount++;
                // Check if null value set and is allowed
                if ((schema.hasOwnProperty('nullable') && schema.nullable === true) && value == null) {
                    value = null;
                }
                else {
                    //Check type
                    if (schema.hasOwnProperty('subType')) {
                        if (_.isFunction(schema.subType) && (schema.subType.name).toLowerCase()) {
                            schema.subType = (schema.subType.name).toLowerCase();
                        }
                        var validSubValue = validationRule.checkType(schema.subType, value[thisVal]);
                        if (validSubValue === undefined) {
                            err = _.assign({
                                code: 'UnexpectedType',
                                'id': name,
                                msg: name + '[' + valCount + ']' + ' is unexpected type. ' + typeof(value[thisVal]) + ' given ' + (schema.subType).toLowerCase() + ' expected'
                            }, err);
                        }
                        else {
                            value[thisVal] = validSubValue;
                        }
                    }

                    //Check minLength
                    if (schema.hasOwnProperty('minLength')) {
                        if (validationRule.minLength(schema.minLength, value[thisVal]) == false) {
                            err = _.assign({
                                code: 'MinLengthUnderachieved',
                                'id': name,
                                msg: name + '[' + valCount + ']' + ' length is less than ' + schema.minLength + ' chars'
                            }, err);
                        }
                    }

                    //Check maxLength
                    if (schema.hasOwnProperty('maxLength')) {
                        if (validationRule.maxLength(schema.maxLength, value[thisVal]) == false) {
                            err = _.assign({
                                code: 'MaxLengthExceeded',
                                'id': name,
                                msg: name + '[' + valCount + ']' + ' length is more than ' + schema.maxLength + ' chars'
                            }, err);
                        }
                    }


                    //Check min
                    if (schema.hasOwnProperty('min')) {
                        if (typeof(value) == 'number') {
                            if (validationRule.min(schema.min, value[thisVal]) == false) {
                                err = _.assign({
                                    code: 'MinValueUnderachived',
                                    'id': name,
                                    msg: name + '[' + valCount + ']' + ' value is less than ' + schema.min
                                }, err);
                            }
                        }
                    }

                    //Check max
                    if (schema.hasOwnProperty('max')) {
                        if (typeof(value) == 'number') {
                            if (validationRule.max(schema.max, value[thisVal]) == false) {
                                err = _.assign({
                                    code: 'MaxValueExceeded',
                                    'id': name,
                                    msg: name + '[' + valCount + ']' + ' value is more than ' + schema.max
                                }, err);
                            }
                        }
                    }

                    //Check allow
                    if (schema.hasOwnProperty('allow')) {
                        if (typeof(value) == 'number' || typeof(value[thisVal]) == 'string') {
                            if (validationRule.allow(schema.allow, value[thisVal]) == false) {
                                err = _.assign({
                                    code: 'ValueNotAllowed',
                                    'id': name,
                                    msg: name + '[' + valCount + ']' + ' value \'' + value[thisVal] + '\' is not allowed. Use one of the following values: ' + (schema.allow).join(",")
                                }, err);
                            }
                        }
                    }

                    //Check deny
                    if (schema.hasOwnProperty('deny')) {
                        if (typeof(value) == 'number' || typeof(value[thisVal]) == 'string') {
                            if (validationRule.deny(schema.deny, value[thisVal]) == false) {
                                err = _.assign({
                                    code: 'ValueNotAllowed',
                                    'id': name,
                                    msg: name + '[' + valCount + ']' + ' value \'' + value[thisVal] + '\' is not allowed. Do not use one of the following values: ' + (schema.deny).join(",")
                                });
                            }
                        }
                    }

                    //Check match
                    if (schema.hasOwnProperty('match')) {
                        if (validationRule.match(schema.match, value[thisVal]) == false) {
                            err = _.assign({
                                code: 'PatternMismatch',
                                'id': name,
                                msg: name + '[' + valCount + ']' + ' does not match pattern ' + schema.match + ''
                            }, err);
                        }
                    }
                    // Convert values
                    value[thisVal] = convert.convertValue(schema, value[thisVal]);
                }
            }
        }
    }


    //Check required
    if (schema.hasOwnProperty('required')) {
        if (options && options.partial !== true) {
            if (schema.required == true && (value == undefined || value == "")) {
                if ((schema.hasOwnProperty('public') && schema.public.hasOwnProperty('set') && schema.public.set == false) || (schema.hasOwnProperty('nullable') && schema.nullable === true && _.isNull(value))) {

                }
                else {
                    err = _.assign({
                        code: 'MissingRequiredParameter',
                        id: name,
                        msg: name + ' is required but invalid value or no value given'
                    }, err);
                }
            }
        }
    }

    //Check public
    if (schema.hasOwnProperty('public')) {
        if (schema.public == false || ((schema.public.hasOwnProperty('get') && schema.public.get != true))) {
            value = undefined;
        }
    }
    callback(err, value);
}
613958
def set_default (feature, value):
    
    f = __all_features[feature]
    bad_attribute = None

    if f.free:
        bad_attribute = "free"
    elif f.optional:
        bad_attribute = "optional"

    if bad_attribute:
        raise InvalidValue ("%s property %s cannot have a default" % (bad_attribute, f.name))

    if value not in f.values:
        raise InvalidValue ("The specified default value, '%s' is invalid.\n" % value + "allowed values are: %s" % f.values)

    f.set_default(value)
386871
def override(self, obj):
        """"""
        for field in obj.__class__.export_fields:
            setattr(self, field, getattr(obj, field))
792289
def default_props(reset=False, **kwargs):
    
    global _DEFAULT_PROPS
    if _DEFAULT_PROPS is None or reset:
        reset_default_props(**kwargs)
    return _DEFAULT_PROPS
1120332
def override_args(**kwargs):
  

  override_kwargs = kwargs

  def custom_getter(getter, *args, **kwargs):
    """Custom getter with certain named arguments overridden.

    Args:
      getter: Underlying variable getter to invoke.
      *args: Arguments, compatible with those of tf.get_variable.
      **kwargs: Keyword arguments, compatible with those of tf.get_variable.

    Returns:
      The result of invoking `getter(*args, **kwargs)` except that certain
      kwargs entries may have been overridden.
    """
    kwargs.update(override_kwargs)
    return getter(*args, **kwargs)

  return custom_getter
1223199
def setOverrideValue(self, attributes, hostName):
        
        self['override'] = True
        attrType = type(attributes)
        if attrType is dict:
            self['parameter_type'] = 'hash'
        elif attrType is list:
            self['parameter_type'] = 'array'
        else:
            self['parameter_type'] = 'string'
        orv = self.getOverrideValueForHost(hostName)
        if orv:
            orv['value'] = attributes
            return True
        else:
            return self.api.create('{}/{}/{}'.format(self.objName,
                                                     self.key,
                                                     'override_values'),
                                   {"override_value":
                                       {"match": "fqdn={}".format(hostName),
                                        "value": attributes}})
1181865
function defaults(object, defs) {
  var key;
  object = assign({}, object);
  defs = defs || {};
  // Iterate over object non-prototype properties:
  for (key in defs) {
    if (defs.hasOwnProperty(key)) {
      // Replace values with defaults only if undefined (allow empty/zero values):
      if (object[key] == null) {
        object[key] = defs[key];
      }
    }
  }
  return object;
}
1309948
function applyDefaults(params, defaults) {
    var settings = params || {};

    for(var setting in defaults) {
      if(defaults.hasOwnProperty(setting) && !settings[setting]) {
        settings[setting] = defaults[setting];
      }
    }

    return settings;
  }
768163
private void processPropertyOverrides() {
    PropertyOverrides propertyOverrides = entityClass.getAnnotation(PropertyOverrides.class);
    if (propertyOverrides == null) {
      return;
    }
    PropertyOverride[] propertyOverridesArray = propertyOverrides.value();
    for (PropertyOverride propertyOverride : propertyOverridesArray) {
      entityMetadata.putPropertyOverride(propertyOverride);
    }
  }
1307630
private void applyPropertyOverride(PropertyMetadata propertyMetadata) {
    String name = propertyMetadata.getName();
    Property override = entityMetadata.getPropertyOverride(name);
    if (override != null) {
      String mappedName = override.name();
      if (mappedName != null && mappedName.trim().length() > 0) {
        propertyMetadata.setMappedName(mappedName);
      }
      propertyMetadata.setIndexed(override.indexed());
      propertyMetadata.setOptional(override.optional());
    }

  }
1226807
function (options) {
  const defaults = {
    name: null,
    max: null,
    precision: 2,
    steps: false
  };
  for (var attrname in defaults) {
    this[attrname] = options.hasOwnProperty(attrname) && options[attrname] !== null ? options[attrname] : defaults[attrname];
  }
  if(options.custom) this.custom = options.custom.bind(this);
  this.val = options.count || 0;
}
252053
def setdefault (self, key, def_val=None):
        """"""
        if key in self:
            return self[key]
        self[key] = def_val
        return def_val
866112
def set_default(self, default):
        
        # Find index of choice
        try:
            default_index = self._parameter.default_values.index(default)
            self.default_input_button_group.button(default_index).setChecked(
                True)
        except ValueError:
            last_index = len(self._parameter.default_values) - 1
            self.default_input_button_group.button(last_index).setChecked(
                True)
            self.custom_value.setValue(default)

        self.toggle_custom_value()
1104506
def default_value(self, default_value):
        
        # For custom value
        if default_value not in self.default_values:
            if len(self.default_labels) == len(self.default_values):
                self.default_values[-1] = default_value
            else:
                self.default_values.append(default_value)

        self._default_value = default_value
555191
function applyPresets(model, defaults, presets) {
    if (!model || !presets) { return; }

    var opts = model.presets || presets[model.preset] ||
        (model.preset && presets[model.type + '.' + model.preset]) || presets[model.type];
    if (!opts) { return; }

    for (var name in opts) {
        if (opts.hasOwnProperty(name)) {
            if (!defaults || defaults[name] === undefined) {
                throw new Error('No defaults value for ' + name + ' but in presets.' + model.preset);
            }
            else {
                model[name] = opts[name];
            }
        }
    }
}