src/sap.ui.core/src/sap/ui/model/odata/v4/ODataModel.js
function parseAndValidateSystemQueryOption (mOptions, sOptionName, aAllowed) {
			var sExpandOptionName,
				mExpandOptions,
				sExpandPath,
				vValue = mOptions[sOptionName];

			if (!bSystemQueryOptionsAllowed || aAllowed.indexOf(sOptionName) < 0) {
					throw new Error("System query option " + sOptionName + " is not supported");
			}
			if ((sOptionName === "$expand" || sOptionName === "$select")
					&& typeof vValue === "string") {
				vValue = _Parser.parseSystemQueryOption(sOptionName + "=" + vValue)[sOptionName];
				mOptions[sOptionName] = vValue;
			}
			if (sOptionName === "$expand") {
				for (sExpandPath in vValue) {
					mExpandOptions = vValue[sExpandPath];
					if (mExpandOptions === null || typeof mExpandOptions !== "object") {
						// normalize empty expand options to {}
						mExpandOptions = vValue[sExpandPath] = {};
					}
					for (sExpandOptionName in mExpandOptions) {
						parseAndValidateSystemQueryOption(mExpandOptions, sExpandOptionName,
							aExpandQueryOptions);
					}
				}
			} else if (sOptionName === "$count") {
				if (typeof vValue  === "boolean") {
					if (!vValue) {
						delete mOptions.$count;
					}
				} else {
					switch (typeof vValue === "string" && vValue.toLowerCase()) {
						case "false":
							delete mOptions.$count;
							break;
						case "true":
							mOptions.$count = true;
							break;
						default:
							throw new Error("Invalid value for $count: " + vValue);
					}
				}
			}
		}
function parseAndValidateSystemQueryOption (mOptions, sOptionName, aAllowed) {
			var sExpandOptionName,
				mExpandOptions,
				sExpandPath,
				vValue = mOptions[sOptionName];

			if (!bSystemQueryOptionsAllowed || aAllowed.indexOf(sOptionName) < 0) {
					throw new Error("System query option " + sOptionName + " is not supported");
			}
			if ((sOptionName === "$expand" || sOptionName === "$select")
					&& typeof vValue === "string") {
				vValue = _Parser.parseSystemQueryOption(sOptionName + "=" + vValue)[sOptionName];
				mOptions[sOptionName] = vValue;
			}
			if (sOptionName === "$expand") {
				for (sExpandPath in vValue) {
					mExpandOptions = vValue[sExpandPath];
					if (mExpandOptions === null || typeof mExpandOptions !== "object") {
						// normalize empty expand options to {}
						mExpandOptions = vValue[sExpandPath] = {};
					}
					for (sExpandOptionName in mExpandOptions) {
						parseAndValidateSystemQueryOption(mExpandOptions, sExpandOptionName,
							aExpandQueryOptions);
					}
				}
			} else if (sOptionName === "$count") {
				if (typeof vValue  === "boolean") {
					if (!vValue) {
						delete mOptions.$count;
					}
				} else {
					switch (typeof vValue === "string" && vValue.toLowerCase()) {
						case "false":
							delete mOptions.$count;
							break;
						case "true":
							mOptions.$count = true;
							break;
						default:
							throw new Error("Invalid value for $count: " + vValue);
					}
				}
			}
		}
function parseAndValidateSystemQueryOption ( mOptions , sOptionName , aAllowed ) { var sExpandOptionName , mExpandOptions , sExpandPath , vValue = mOptions [ sOptionName ] ; if ( ! bSystemQueryOptionsAllowed || aAllowed . indexOf ( sOptionName ) < 0 ) { throw new Error ( "System query option " + sOptionName + " is not supported" ) ; } if ( ( sOptionName === "$expand" || sOptionName === "$select" ) && typeof vValue === "string" ) { vValue = _Parser . parseSystemQueryOption ( sOptionName + "=" + vValue ) [ sOptionName ] ; mOptions [ sOptionName ] = vValue ; } if ( sOptionName === "$expand" ) { for ( sExpandPath in vValue ) { mExpandOptions = vValue [ sExpandPath ] ; if ( mExpandOptions === null || typeof mExpandOptions !== "object" ) { // normalize empty expand options to {} mExpandOptions = vValue [ sExpandPath ] = { } ; } for ( sExpandOptionName in mExpandOptions ) { parseAndValidateSystemQueryOption ( mExpandOptions , sExpandOptionName , aExpandQueryOptions ) ; } } } else if ( sOptionName === "$count" ) { if ( typeof vValue === "boolean" ) { if ( ! vValue ) { delete mOptions . $count ; } } else { switch ( typeof vValue === "string" && vValue . toLowerCase ( ) ) { case "false" : delete mOptions . $count ; break ; case "true" : mOptions . $count = true ; break ; default : throw new Error ( "Invalid value for $count: " + vValue ) ; } } } }
Parses the query options for the given option name "sOptionName" in the given map of
query options "mOptions" to an object if necessary.
Validates if the given query option name is allowed.

@param {object} mOptions Map of query options by name
@param {string} sOptionName Name of the query option
@param {string[]} aAllowed The allowed system query options
@throws {error} If the given query option name is not allowed
Parses the query options for the given option name sOptionName in the given map of query options mOptions to an object if necessary . Validates if the given query option name is allowed .