UNPKG

@sap-cloud-sdk/core

Version:
76 lines 3.49 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.EnumField = void 0; var filter_1 = require("../filter"); var field_1 = require("./field"); var complex_type_field_1 = require("./complex-type-field"); /** * Represents a property with an enum value. * @typeparam EntityT - Type of the entity the field belongs to. * @typeparam EnumT - Enum type that contains all valid enum entries for this field. * @typeparam NullableT - Boolean type that represents whether the field is nullable. * @typeparam SelectableT - Boolean type that represents whether the field is selectable. */ var EnumField = /** @class */ (function (_super) { __extends(EnumField, _super); /** * Creates an instance of EnumField. * @param fieldName - Actual name of the field used in the OData request. * @param _fieldOf - The constructor of the entity or the complex type field this field belongs to. * @param enumType - Enum type of the field according to the metadata description. * @param fieldOptions - Optional settings for this field. */ function EnumField(fieldName, _fieldOf, enumType, fieldOptions) { var _this = _super.call(this, fieldName, (0, complex_type_field_1.getEntityConstructor)(_fieldOf), fieldOptions) || this; _this._fieldOf = _fieldOf; _this.enumType = enumType; /** * @deprecated Since v1.48.0. This property is not used anymore. */ _this.edmType = 'Edm.Enum'; return _this; } /** * Gets the path to the complex type property represented by this. * @returns The path to the complex type property. */ EnumField.prototype.fieldPath = function () { return this._fieldOf instanceof complex_type_field_1.ComplexTypeField ? "".concat(this._fieldOf.fieldPath(), "/").concat(this._fieldName) : this._fieldName; }; /** * Creates an instance of Filter for this field and the given value using the operator 'eq', i.e. `==`. * @param value - Value to be used in the filter * @returns The resulting filter */ EnumField.prototype.equals = function (value) { return new filter_1.Filter(this.fieldPath(), 'eq', value, this.edmType); }; /** * Creates an instance of Filter for this field and the given value using the operator 'ne', i.e. `!=`. * @param value - Value to be used in the filter * @returns The resulting filter */ EnumField.prototype.notEquals = function (value) { return new filter_1.Filter(this.fieldPath(), 'eq', value, this.edmType); }; return EnumField; }(field_1.Field)); exports.EnumField = EnumField; //# sourceMappingURL=enum-field.js.map