Source: bemap-services-v2/acl/bemap-geoserver-service-limit.js

/**
 * BeNomad BeMap JavaScript API - GeoServerServiceLimit
 *
 * One entry in `GeoServerInfoResponse.serviceLimits[]`. Describes a single
 * resource-limit applied to a service for the selected geoserver. Mirrors
 * the server DTO `ServiceLmt`:
 *
 *   {
 *     "serviceName": "BenomadNearPoiService",
 *     "key":         "MaxDistance",
 *     "argument":    "MAX",          // "MAX" | "MIN"
 *     "type":        "LONG",         // "INT" | "LONG" | ...
 *     "value":       "1000",         // string (always)
 *     "unit":        "NA"            // "METER" | "SECOND" | "SQUARE_METER" | "NA"
 *   }
 *
 * The `value` field is a String on the wire (the server emits every limit
 * as a string regardless of the underlying type, to preserve precision and
 * avoid Number-precision issues for large longs). `getNumericValue()`
 * returns the parsed Number when `type` is INT or LONG.
 *
 * @since 1.5.0
 * @public
 * @constructor
 */
bemap.GeoServerServiceLimit = function(options) {
    var opts = options || {};
    this.serviceName = opts.serviceName || null;
    this.key = opts.key || null;
    this.argument = opts.argument || null;
    this.type = opts.type || null;
    this.value = (opts.value !== undefined && opts.value !== null) ? String(opts.value) : null;
    this.unit = opts.unit || null;
};

bemap.GeoServerServiceLimit.prototype.getServiceName = function() { return this.serviceName; };
bemap.GeoServerServiceLimit.prototype.getKey = function() { return this.key; };
/** `"MAX"` or `"MIN"`. */
bemap.GeoServerServiceLimit.prototype.getArgument = function() { return this.argument; };
bemap.GeoServerServiceLimit.prototype.getType = function() { return this.type; };
/** Always a String — see class doc. */
bemap.GeoServerServiceLimit.prototype.getValue = function() { return this.value; };
/** `"METER"` / `"SECOND"` / `"SQUARE_METER"` / `"NA"`. */
bemap.GeoServerServiceLimit.prototype.getUnit = function() { return this.unit; };

/**
 * Returns the value as a Number when `type` is INT or LONG, else `NaN`.
 * @return {Number}
 */
bemap.GeoServerServiceLimit.prototype.getNumericValue = function() {
    if (this.value === null) return NaN;
    if (this.type === 'INT' || this.type === 'LONG' || this.type === 'DOUBLE' || this.type === 'FLOAT') {
        return Number(this.value);
    }
    return Number(this.value);
};

bemap.GeoServerServiceLimit.fromJson = function(raw) {
    if (!raw) return new bemap.GeoServerServiceLimit();
    return new bemap.GeoServerServiceLimit({
        serviceName: raw.serviceName,
        key: raw.key,
        argument: raw.argument,
        type: raw.type,
        value: raw.value,
        unit: raw.unit
    });
};