UNPKG

3.49 kBJavaScriptView Raw
1"use strict";
2var __extends = (this && this.__extends) || (function () {
3 var extendStatics = function (d, b) {
4 extendStatics = Object.setPrototypeOf ||
5 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7 return extendStatics(d, b);
8 };
9 return function (d, b) {
10 if (typeof b !== "function" && b !== null)
11 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12 extendStatics(d, b);
13 function __() { this.constructor = d; }
14 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15 };
16})();
17Object.defineProperty(exports, "__esModule", { value: true });
18exports.EnumField = void 0;
19var filter_1 = require("../filter");
20var field_1 = require("./field");
21var complex_type_field_1 = require("./complex-type-field");
22/**
23 * Represents a property with an enum value.
24 * @typeparam EntityT - Type of the entity the field belongs to.
25 * @typeparam EnumT - Enum type that contains all valid enum entries for this field.
26 * @typeparam NullableT - Boolean type that represents whether the field is nullable.
27 * @typeparam SelectableT - Boolean type that represents whether the field is selectable.
28 */
29var EnumField = /** @class */ (function (_super) {
30 __extends(EnumField, _super);
31 /**
32 * Creates an instance of EnumField.
33 * @param fieldName - Actual name of the field used in the OData request.
34 * @param _fieldOf - The constructor of the entity or the complex type field this field belongs to.
35 * @param enumType - Enum type of the field according to the metadata description.
36 * @param fieldOptions - Optional settings for this field.
37 */
38 function EnumField(fieldName, _fieldOf, enumType, fieldOptions) {
39 var _this = _super.call(this, fieldName, (0, complex_type_field_1.getEntityConstructor)(_fieldOf), fieldOptions) || this;
40 _this._fieldOf = _fieldOf;
41 _this.enumType = enumType;
42 /**
43 * @deprecated Since v1.48.0. This property is not used anymore.
44 */
45 _this.edmType = 'Edm.Enum';
46 return _this;
47 }
48 /**
49 * Gets the path to the complex type property represented by this.
50 * @returns The path to the complex type property.
51 */
52 EnumField.prototype.fieldPath = function () {
53 return this._fieldOf instanceof complex_type_field_1.ComplexTypeField
54 ? "".concat(this._fieldOf.fieldPath(), "/").concat(this._fieldName)
55 : this._fieldName;
56 };
57 /**
58 * Creates an instance of Filter for this field and the given value using the operator 'eq', i.e. `==`.
59 * @param value - Value to be used in the filter
60 * @returns The resulting filter
61 */
62 EnumField.prototype.equals = function (value) {
63 return new filter_1.Filter(this.fieldPath(), 'eq', value, this.edmType);
64 };
65 /**
66 * Creates an instance of Filter for this field and the given value using the operator 'ne', i.e. `!=`.
67 * @param value - Value to be used in the filter
68 * @returns The resulting filter
69 */
70 EnumField.prototype.notEquals = function (value) {
71 return new filter_1.Filter(this.fieldPath(), 'eq', value, this.edmType);
72 };
73 return EnumField;
74}(field_1.Field));
75exports.EnumField = EnumField;
76//# sourceMappingURL=enum-field.js.map
\No newline at end of file