spring-filter-query-builder
Version:
<!-- Improved compatibility of back to top link: See: https://github.com/othneildrew/Best-README-Template/pull/73 -->
179 lines (178 loc) • 6.6 kB
JavaScript
"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.NotIn = exports.In = exports.IsNotEmpty = exports.IsEmpty = exports.IsNotNull = exports.IsNull = exports.Le = exports.Lt = exports.Ge = exports.Gt = exports.NotEqual = exports.Equal = exports.Like = exports.Comparator = void 0;
var item_1 = require("./item");
var Comparator = /** @class */ (function () {
// false positive
// eslint-disable-next-line @typescript-eslint/ban-types
function Comparator(selector, comparatorKeyWord, value) {
this.selector = selector;
this.comparatorKeyWord = comparatorKeyWord;
this.value = value;
}
Comparator.prototype.toString = function () {
if (typeof this.value === 'undefined' || this.value === null) {
return this.selector + " " + this.comparatorKeyWord;
}
if (typeof this.value === 'number') {
return this.selector + " " + this.comparatorKeyWord + " " + this.value;
}
else {
return this.selector + " " + this.comparatorKeyWord + " '" + this.value + "'";
}
};
return Comparator;
}());
exports.Comparator = Comparator;
var Like = /** @class */ (function (_super) {
__extends(Like, _super);
// false positive
// eslint-disable-next-line @typescript-eslint/ban-types
function Like(selector, value, caseInsensitive) {
if (caseInsensitive === void 0) { caseInsensitive = false; }
return _super.call(this, selector, caseInsensitive ? '~~' : '~', value) || this;
}
return Like;
}(Comparator));
exports.Like = Like;
var Equal = /** @class */ (function (_super) {
__extends(Equal, _super);
// false positive
// eslint-disable-next-line @typescript-eslint/ban-types
function Equal(selector, value) {
return _super.call(this, selector, ':', value) || this;
}
return Equal;
}(Comparator));
exports.Equal = Equal;
var NotEqual = /** @class */ (function (_super) {
__extends(NotEqual, _super);
// false positive
// eslint-disable-next-line @typescript-eslint/ban-types
function NotEqual(selector, value) {
return _super.call(this, selector, '!', value) || this;
}
return NotEqual;
}(Comparator));
exports.NotEqual = NotEqual;
var Gt = /** @class */ (function (_super) {
__extends(Gt, _super);
// false positive
// eslint-disable-next-line @typescript-eslint/ban-types
function Gt(selector, value) {
return _super.call(this, selector, '>', value) || this;
}
return Gt;
}(Comparator));
exports.Gt = Gt;
var Ge = /** @class */ (function (_super) {
__extends(Ge, _super);
// false positive
// eslint-disable-next-line @typescript-eslint/ban-types
function Ge(selector, value) {
return _super.call(this, selector, '>:', value) || this;
}
return Ge;
}(Comparator));
exports.Ge = Ge;
var Lt = /** @class */ (function (_super) {
__extends(Lt, _super);
// false positive
// eslint-disable-next-line @typescript-eslint/ban-types
function Lt(selector, value) {
return _super.call(this, selector, '<', value) || this;
}
return Lt;
}(Comparator));
exports.Lt = Lt;
var Le = /** @class */ (function (_super) {
__extends(Le, _super);
// false positive
// eslint-disable-next-line @typescript-eslint/ban-types
function Le(selector, value) {
return _super.call(this, selector, '<:', value) || this;
}
return Le;
}(Comparator));
exports.Le = Le;
var IsNull = /** @class */ (function (_super) {
__extends(IsNull, _super);
// false positive
// eslint-disable-next-line @typescript-eslint/ban-types
function IsNull(selector) {
return _super.call(this, selector, 'is null') || this;
}
return IsNull;
}(Comparator));
exports.IsNull = IsNull;
var IsNotNull = /** @class */ (function (_super) {
__extends(IsNotNull, _super);
// false positive
// eslint-disable-next-line @typescript-eslint/ban-types
function IsNotNull(selector) {
return _super.call(this, selector, 'is not null') || this;
}
return IsNotNull;
}(Comparator));
exports.IsNotNull = IsNotNull;
var IsEmpty = /** @class */ (function (_super) {
__extends(IsEmpty, _super);
// false positive
// eslint-disable-next-line @typescript-eslint/ban-types
function IsEmpty(selector) {
return _super.call(this, selector, 'is empty') || this;
}
return IsEmpty;
}(Comparator));
exports.IsEmpty = IsEmpty;
var IsNotEmpty = /** @class */ (function (_super) {
__extends(IsNotEmpty, _super);
// false positive
// eslint-disable-next-line @typescript-eslint/ban-types
function IsNotEmpty(selector) {
return _super.call(this, selector, 'is not empty') || this;
}
return IsNotEmpty;
}(Comparator));
exports.IsNotEmpty = IsNotEmpty;
var In = /** @class */ (function (_super) {
__extends(In, _super);
// false positive
// eslint-disable-next-line @typescript-eslint/ban-types
function In(selector, values) {
return _super.call(this, selector, 'in', "[" + (0, item_1.valuesToValue)(values) + "]") || this;
}
In.prototype.toString = function () {
return this.selector + " " + this.comparatorKeyWord + " " + this.value;
};
return In;
}(Comparator));
exports.In = In;
var NotIn = /** @class */ (function (_super) {
__extends(NotIn, _super);
// false positive
// eslint-disable-next-line @typescript-eslint/ban-types
function NotIn(selector, values) {
return _super.call(this, selector, 'not in', "[" + (0, item_1.valuesToValue)(values) + "]") || this;
}
NotIn.prototype.toString = function () {
return this.selector + " " + this.comparatorKeyWord + " " + this.value;
};
return NotIn;
}(Comparator));
exports.NotIn = NotIn;