fiql-query-builder
Version:
This module provides the utility to generate valid FIQL query strings by using a JSON objects or the custom classes provided.
47 lines (36 loc) • 1.57 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.GroupNode = undefined;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _exception = require('../exception');
var _ = require('./');
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* Wraps the child expresison in parentheses to
* provide higher precendence in evaulation.
*/
var GroupNode = exports.GroupNode = function () {
/**
* Initialise new GroupNode
* @param {ExpNode} exp
*/
function GroupNode(exp) {
_classCallCheck(this, GroupNode);
this.exp = exp;
}
/**
* Wrap and build child
*/
_createClass(GroupNode, [{
key: 'build',
value: function build() {
if (!(this.exp instanceof _.ExpNode)) {
throw new _exception.InvalidGroupChildError('Only boolean expressions can be wrapped in parentheses.');
}
return '(' + this.exp.build() + ')';
}
}]);
return GroupNode;
}();