Set options if they exist. Only can override defaults, though, so
if no defaults value, then error thrown.
This matches tpl.helper.applyPresets()

@param model
@param defaults
@param presets
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];
            }
        }
    }
}
1203631
protected function initDefaults($defaults)
    {
        if (!$defaults) {
            return;
        }

        $defaults = $this->fetchParameters($defaults);
        $this->initDefaultsInConfigArray($defaults);
    }
736549
@Deprecated
	public void setReferencedGenModels(String referencedGenModel) {
		if ("".equals(referencedGenModel))
			return;
		this.referencedGenModels = referencedGenModel;
		log.warn("The property 'referencedGenModels' is deprecated. Please use 'StandaloneSetup.registerGenModelFile' instead.");
	}
568852
function defaults(options, defaultOptions) {
  options || (options = {});

  for (var opt in defaultOptions) {
    if (defaultOptions.hasOwnProperty(opt) && !options.hasOwnProperty(opt)) {
      options[opt] = defaultOptions[opt];
    }
  }

  return options;
}
952109
@SuppressWarnings("unchecked")
    public void setSettings(Object presets) {

        if (presets == null) {
            m_settingPresets = null;
        } else if (!(presets instanceof Map)) {
            throw new IllegalArgumentException(
                "cms:container -- value of 'settings' attribute  should be a map, but is "
                    + ClassUtils.getCanonicalName(presets));
        } else {
            m_settingPresets = new HashMap<>((Map<String, String>)presets);
        }
    }
82861
private void setDefaultParseSettings() {
        if (!parseSettings.containsKey(CDATA_SECTIONS)) {
            parseSettings.put(CDATA_SECTIONS, true);
        }

        if (!parseSettings.containsKey(SPLIT_CDATA_SECTIONS)) {
            parseSettings.put(SPLIT_CDATA_SECTIONS, false);
        }

        if (!parseSettings.containsKey(VALIDATE_IF_SCHEMA)) {
            parseSettings.put(VALIDATE_IF_SCHEMA, true);
        }

        if (!parseSettings.containsKey(RESOURCE_RESOLVER)) {
            parseSettings.put(RESOURCE_RESOLVER, createLSResourceResolver());
        }

        if (!parseSettings.containsKey(ELEMENT_CONTENT_WHITESPACE)) {
            parseSettings.put(ELEMENT_CONTENT_WHITESPACE, false);
        }
    }
1099576
function(options) {
  	   inputEx.RTEField.superclass.setOptions.call(this, options);
  	   
  	   this.options.opts = options.opts || {};
  	   this.options.editorType = options.editorType;
   }
243814
protected void fillDefaultValues(Map<String, Value> params) {
        for (MethodParameter parameter : parameters.values()) {
            if (!parameter.isOptional() || parameter.getDefaultValue() == null || params.get(parameter.getName()) != null) continue;
            params.put(parameter.getName(), parameter.getDefaultValue());
        }
    }
1176216
public void setModels(java.util.Collection<ModelSummary> models) {
        if (models == null) {
            this.models = null;
            return;
        }

        this.models = new java.util.ArrayList<ModelSummary>(models);
    }
902758
public void setModel(Progression model) {
		this.model.removeProgressionListener(new WeakListener(this, this.model));
		if (model == null) {
			this.model = new DefaultProgression();
		} else {
			this.model = model;
		}
		this.previousValue = this.model.getValue();
		this.model.addProgressionListener(new WeakListener(this, this.model));
	}
376962
def set(self, models):
        
        # Do not add None values to selection
        if models is None:
            models = set()

        models = self._check_model_types(models)
        if len(models) > 1:
            models = reduce_to_parent_states(models)

        self._selected = set(models)
1148811
public void setModel(@Nonnull final MindMap model, final boolean notifyModelChangeListeners) {
    this.lock();
    try {
      if (this.elementUnderEdit != null) {
        Utils.safeSwingBlockingCall(new Runnable() {
          @Override
          public void run() {
            endEdit(false);
          }
        });
      }

      final List<int[]> selectedPaths = new ArrayList<int[]>();
      for (final Topic t : this.selectedTopics) {
        selectedPaths.add(t.getPositionPath());
      }

      this.selectedTopics.clear();

      final MindMap oldModel = this.model;
      this.model = assertNotNull("Model must not be null", model);

      for (final PanelAwarePlugin p : MindMapPluginRegistry.getInstance().findFor(PanelAwarePlugin.class)) {
        p.onPanelModelChange(this, oldModel, this.model);
      }

      doLayout();
      revalidate();

      boolean selectionChanged = false;
      for (final int[] posPath : selectedPaths) {
        final Topic topic = this.model.findForPositionPath(posPath);
        if (topic == null) {
          selectionChanged = true;
        } else if (!MindMapUtils.isHidden(topic)) {
          this.selectedTopics.add(topic);
        }
      }
      if (selectionChanged) {
        fireNotificationSelectionChanged();
      }
      repaint();
    } finally {
      this.unlock();
      if (notifyModelChangeListeners) {
        fireNotificationMindMapChanged(true);
      }
    }
  }
290760
public ConfigOptionBuilder setDefaultWith( Object defaultValue ) {
        co.setHasDefault( true );
        co.setValue( defaultValue );
        return setOptional();
    }
1120609
protected function setDefaults(array $defaultOptions = array())
    {
        $defaultOptions = array_merge(array(
            'depth' => null,
            'ancestorCurrencyDepth' => null,
            'currentClass' => 'active',
            'ancestorClass' => 'active',
            'firstClass' => null,
            'lastClass' => null
        ), $defaultOptions);

        parent::setDefaults($defaultOptions);
    }
1305190
public function setup(Model $model, $settings = array()) {
        $settings = array_merge($this->_defaults, $settings);
        $this->settings[$model->alias] = $settings;

        // Store the default model validate set
        if ($model->validate) {
            if (empty($model->validations)) {
                $model->validations = array();
            }

            $model->validations[$settings['defaultSet']] = $model->validate;
            $model->validate = array();
        }
    }
182461
public void setOptions(
			String[] labels, String[] descriptions, int defaultIndex) 
	{
		if (labels.length != descriptions.length) {
            throw new IllegalArgumentException("Labels/descriptions mismatch.");
        }
		
		if (labels.length > 0) {
			this.optionLabels = labels.clone();
			this.optionDescriptions = descriptions.clone();
			this.defaultOptionIndex = defaultIndex;
		}
		else {
			// use placeholders for empty list of choices
			this.optionLabels = new String[]{NO_CHOICES};
			this.optionDescriptions = new String[]{NO_CHOICES_DESCRIPTION};
			this.defaultOptionIndex = 0;
		}
		
		// reset to default value
        resetToDefault();
        
        // refresh the edit component
        if (this.editComponent != null) {
        	this.editComponent.refresh();
        }
	}
24557
void setDefaults(Settings defaultSettings) {

		Assert.notNull(defaultSettings, "Missing default settings!");

		for (String key : defaultSettings.keySet()) {

			CommandOption<?> option = findBySetting(key);

			if (option == null) {
				// option not present ... check next
				continue;
			}

			Object value = defaultSettings.get(key);
			option.defaultsTo(value);
		}

	}