/*
---------------- ------------------- CREATE AGENT STATES
------------------- ----------------
355429
function createAgentState (appname, moduleName, state, parentUrl) {
  createTemplate(appname, path.join('generated', 'agents', 'agentController.js'), {
    moduleName: moduleName,
    state: state,
    parentUrl: parentUrl
  })

  var oldControllerPath = path.join(appname, 'generated', 'agents', 'agentController.js'),
    newControllerPath = path.join(appname, 'generated', 'agents', moduleName, 'controllers', state.name + '.js')

  fs.renameSync(oldControllerPath, newControllerPath)
  if (state.elements) {
    for (childState in state.elements) {
      createAgentChildState(appname, moduleName, state.elements[childState], state.name, parentUrl)
    }
  }

  createTemplate(appname, path.join('generated', 'agents', 'agent.html'), {
    moduleName: moduleName,
    state: state,
    parentUrl: parentUrl
  })

  var oldHtmlPath = path.join(appname, 'generated', 'agents', 'agent.html'),
    newHtmlPath = path.join(appname, 'generated', 'partials', 'agents', moduleName, state.name + '.html')
  fs.renameSync(oldHtmlPath, newHtmlPath)
}
1348064
private void setState(FieldState state) {
        if (DEBUG)
            LOG.debug("{}:{} --> {}", _state, _fieldState, state);
        _fieldState = state;
    }
999950
private void setState(State state) {
    if (this.state != state) {
      this.state = state;
      log.debug("State changed: {}", state);
    }
  }
911379
private void addAgents() throws ShanksException {
        for (Entry<String, ShanksAgent> agentEntry : this.agents.entrySet()) {
            stoppables.put(agentEntry.getKey(), schedule.scheduleRepeating(Schedule.EPOCH, 2, agentEntry.getValue(), 1));
        }
    }
378421
function createReducer(defaultState, handlers) {
  if ((typeof defaultState === 'undefined' ? 'undefined' : _typeof(defaultState)) === 'object') {
    handlers = defaultState;
    defaultState = function defaultState() {
      return null;
    };
  }

  var handlerMap = new Map();
  Object.keys(handlers).forEach(function (key) {
    if (typeof key === 'function') {
      handlerMap.set(key.type, handlers[key]);
    } else {
      handlerMap.set(key, handlers[key]);
    }
  });
  handlers = undefined;

  return function () {
    var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultState();
    var action = arguments[1];

    if (action && handlerMap.has(action.type)) {
      return handlerMap.get(action.type)(state, action);
    }

    return state;
  };
}
408850
function create() {
  var defaultState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

  var state = clone(defaultState);
  var watchers = [];

  /**
   * Get a store value by path/key
   *
   * @param {String} path
   * @throws Error when specified store key is not found
   * @return value
   */
  function get(path) {
    var value = _get(state, path);

    if (value === undefined) {
      throw new Error('[toystore] Requested store key "' + path + '" was not found in store.');
    }

    return clone(value);
  }

  /**
   * Get multiple path values from store
   *
   * @param {String[]} paths
   * @return {Object} key/value pair of path => value
   */
  function getAll(paths) {
    if (paths === undefined) {
      return clone(state);
    }

    if (!paths instanceof Array) {
      throw new Error('[toystore] getAll() argument "paths" must be an array.');
    }

    var values = paths.map(get);

    return zipObject(paths, values);
  }

  /**
   * Get a store value by path/key
   *
   * @param {String} path
   * @return value
   */
  function getSilent(path) {
    return _get(state, path);
  }

  /**
   * Run all watchers with new/current values
   */
  function notifyAllWatchers() {
    watchers.map(function _notifyWatcher(watcher) {
      var watchedKeyValues = {};
      try {
        watchedKeyValues = getAll(watcher.paths);
      } catch (e) {}

      watcher.callback(watchedKeyValues);
    });
  }

  /**
   * Notify/update watcher functions for given paths
   *
   * @param {String[]} paths
   */
  function notifyWatchersOnPaths(paths) {
    var expandedPaths = _expandNestedPaths(paths);

    watchers.map(function _notifyWatcher(watcher) {
      var hasPath = intersect(expandedPaths, watcher.paths).length > 0;

      if (hasPath) {
        var watchedKeyValues = {};
        try {
          watchedKeyValues = getAll(paths);
        } catch (e) {}

        if (watcher.options.async !== false) {
          setTimeout(function () {
            watcher.callback(watchedKeyValues);
          }, watcher.options.async || 0);
        } else {
          watcher.callback(watchedKeyValues);
        }
      }
    });

    if (paths !== '*') {
      notifyGlobalWatchers();
    }
  }

  /**
   * Notify/update global watchers
   */
  function notifyGlobalWatchers() {
    notifyWatchersOnPaths('*');
  }

  /**
   * Set a store value at path/key to given value
   *
   * @param {String} path
   * @param {mixed} value
   * @param {Boolean} value
   * @return null
   */
  function set(path, value) {
    var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};

    var paths = _pathsArray(path);
    var existingValue = void 0;

    // If using options.compare = true.  JSON.strigify compare the two sets of data.
    // If they are exactly the same, abort the update.
    if (options.compare) {
      existingValue = getSilent(path);

      if (JSON.stringify(value) === JSON.stringify(existingValue)) {
        return;
      }
    }

    // Get all paths to notify for updates if given an object
    if (_isObject(value) === true) {
      existingValue = existingValue || getSilent(path);

      // If previous value was also an object, we need to see which keys have
      // changed to notify watchers on those keys
      if (_isObject(existingValue)) {

        var oldKeys = _deepKeys(existingValue, path);
        var removedKeys = void 0;

        paths = _deepKeys(value, path);
        removedKeys = difference(oldKeys, paths);

        // If keys were removed in set, we need to notify those watchers
        if (removedKeys.length > 0) {
          paths = paths.concat(removedKeys);
        }
      }
    }

    setSilent(path, value);
    notifyWatchersOnPaths(paths);
  }

  /**
   * Set a store value at path/key to given value WITHOUT notifying watchers
   *
   * @param {String} path
   * @param {mixed} value
   * @return null
   */
  function setSilent(path, value) {
    // Cannot set things that can't be serialized
    var valueType = typeof value === 'undefined' ? 'undefined' : _typeof(value);

    if (valueType === 'function') {
      throw new Error('[toystore] Cannot set "' + path + '" with value type "' + valueType + '". All store values must be serializable.');
    }

    // Setting 'undefined' on an object key here will remove it from the store,
    // so we switch it to null. Removing keys should only be done with 'unset'.
    if (value === undefined) {
      value = null;
    }

    _set(state, path, value);
  }

  /**
   * Set multiple paths with given values to the store
   *
   * @param {Object} key/value pair of path => value
   * @return null
   */
  function setAll(obj) {
    var paths = Object.keys(obj);

    paths.map(function (path) {
      return setSilent(path, obj[path]);
    });
    notifyWatchersOnPaths(paths);
  }

  /**
   * Reset the whole state object to provided one
   *
   * @param {Object} newState (optional) - Will reset to first provided state if none provided
   * @return null
   */
  function reset(newState) {
    state = clone(newState || defaultState);

    notifyAllWatchers();
  }

  /**
   * Watch for changes on a given key, and execute the provided callback when there are changes
   *
   * @param {String[]|String} String path or array of paths to watch
   * @param {Function} callback to execute when there are changes
   * @param {Object} options Options
   * @param {Boolean} options.async Callback execution is async (in next cycle) or sync (as soon as the key changes)
   * @param {Number} options.priority Controls the order the provided callback is called when multiple watches exist on the same key.
   * @return {String} id of watcher (useful for unwatch())
   */
  function watch(paths, callback) {
    var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};

    paths = paths === '*' ? paths : _pathsArray(paths);
    var id = randomString();
    var defaultOptions = { async: false, priority: 0 };

    options = Object.assign({}, defaultOptions, options);

    watchers.push({
      callback: callback,
      id: id,
      options: options,
      paths: paths
    });

    watchers = watchers.sort(_sortByPriority);

    return id;
  }

  /**
   * Watch ALL keys, and execute the provided callback on any and every key change
   */
  function watchAll(callback, options) {
    return watch('*', callback, options);
  }

  /**
   * Watch for changes on a given key once, and execute the provided callback
   * when there are changes. Callback removes itself after the first call so
   * that it is never called again.
   *
   * @param {String[]|String} String path or array of paths to watch
   * @param {Function} callback to execute when there are changes
   * @param {Object} options Options
   * @param {Number} options.priority Controls the order the provided callback is called when multiple watches exist on the same key.
   */
  function watchOnce(paths, callback) {
    var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : { priority: 0 };

    var id = void 0;
    var onceCallback = function _watchOnceCallback() {
      unwatch(id);
      callback.apply(undefined, arguments);
    };

    id = watch(paths, onceCallback, options);
  }

  /**
   * Remove key
   */
  function unset(path) {
    _set(state, path, undefined);
  }

  /**
   * Clear/remove specific watcher by id or callback function
   *
   * @param {String|Function} id - String id (returned from watch() or callback function)
   */
  function unwatch(id) {
    var type = typeof id === 'undefined' ? 'undefined' : _typeof(id);
    var index = watchers.findIndex(function _matchWatcher(watcher) {
      return watcher && (type === 'string' ? watcher.id === id : watcher.callback === id);
    });

    if (index !== -1) {
      // We can't delete the last watcher...
      if (watchers.length === 1) {
        unwatchAll();
      } else {
        delete watchers[index];
      }
    }
  }

  /**
   * Clear/remove all watchers
   */
  function unwatchAll() {
    watchers = [];
  }

  // Public API
  return {
    get: get,
    getAll: getAll,
    reset: reset,
    set: set,
    setAll: setAll,
    setSilent: setSilent,
    watch: watch,
    watchAll: watchAll,
    watchOnce: watchOnce,
    unset: unset,
    unwatch: unwatch,
    unwatchAll: unwatchAll
  };
}
558494
public void addUserAgent(String userAgent) {
    if (userAgent.equals("*")) {
      anyAgent = true;
    } else {
      this.userAgents.add(userAgent);
    }
  }
321731
protected void createRealizationAndState(
                                             MessageProcessor messageProcessor,
                                             TransactionCommon transaction)
                    throws SIResourceException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(
                        tc,
                        "createRealizationAndState",
                        new Object[] {
                                      messageProcessor,
                                      transaction });

        /*
         * Create associated protocol suppor of appropriate type
         */
        if (isPubSub())
        {
            _pubSubRealization = new PubSubRealization(this,
                            messageProcessor,
                            getLocalisationManager(),
                            transaction);
            _protoRealization = _pubSubRealization;
        }
        else
        {

            _ptoPRealization = new JSPtoPRealization(this,
                            messageProcessor,
                            getLocalisationManager());
            _protoRealization = _ptoPRealization;

        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "createRealizationAndState");
    }
893751
public void addState(TrafficLightState state)
    {
        if(this.states == null)
            this.states = new ArrayList<TrafficLightState>();
        this.states.add(state);
    }
433455
@Override
	public String createMachine( TargetHandlerParameters parameters ) throws TargetException {

		this.logger.fine( "Creating a new agent in memory." );
		Map<String,String> targetProperties = preventNull( parameters.getTargetProperties());

		// Need to wait?
		try {
			String delayAsString = targetProperties.get( DELAY );
			long delay = delayAsString != null ? Long.parseLong( delayAsString ) : this.defaultDelay.get();
			if( delay > 0 )
				Thread.sleep( delay );

		} catch( Exception e ) {
			this.logger.warning( "An error occurred while applying the delay property. " + e.getMessage());
			Utils.logException( this.logger, e );
		}

		String machineId = parameters.getScopedInstancePath() + " @ " + parameters.getApplicationName();
		Factory factory = findIPojoFactory( parameters );
		createIPojo(
				targetProperties,
				parameters.getMessagingProperties(),
				machineId,
				parameters.getScopedInstancePath(),
				parameters.getApplicationName(),
				parameters.getDomain(),
				factory );

		return machineId;
	}
982618
function (state, payload) {
        var entity = payload.entity;
        var data = payload.data;
        var options = OptionsBuilder.createPersistOptions(payload);
        var result = payload.result;
        result.data = (new Query(state, entity)).create(data, options);
    }
170156
function createState(props, keys) {
  return keys.reduce((acc, key) => {
    const value = props[key];
    if (value != null) {
      acc[key] = value;
    }
    return acc;
  }, {});
}
706448
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        createSharedPreferences();
        createMapViews();
        createTileCaches();
        checkPermissionsAndCreateLayersAndControls();
    }
841608
public void createAgent(String agent_name, String path) {
        IComponentIdentifier agent = cmsService.createComponent(agent_name,
                path, null, null).get(new ThreadSuspendable());
        createdAgents.put(agent_name, agent);
    }
373844
protected void createDefaultActionStates(final Flow flow) {
        createRealSubmitAction(flow);
        createInitialAuthenticationRequestValidationCheckAction(flow);
        createCreateTicketGrantingTicketAction(flow);
        createSendTicketGrantingTicketAction(flow);
        createGenerateServiceTicketAction(flow);
        createGatewayServicesMgmtAction(flow);
        createServiceAuthorizationCheckAction(flow);
        createRedirectToServiceActionState(flow);
        createHandleAuthenticationFailureAction(flow);
        createTerminateSessionAction(flow);
        createTicketGrantingTicketCheckAction(flow);
    }
685592
function (parser, compiler, actions, scope, state) {
	this.state    = state || {};
	this.scope    = scope;
	this.parser   = parser;
	this.actions  = actions;
	this.compiler = compiler;
}
1172863
public void appendUserAgent(String userAgent) {
        String marker = markers.get(Marker.USER_AGENT);
        if (marker == null)
            marker = "";
        marker = createUserAgentMarkerString(marker, userAgent);
        putClientMarker(Marker.USER_AGENT, marker);
    }