{"version":3,"sources":["node_modules/browser-pack/_prelude.js","gulp/build/toplevel.js","eid.min.js","lib/eid.js","lib/eid/eid.js","lib/eid/exceptions.js","lib/eid/preconditions.js"],"names":["e","t","n","r","s","o","u","a","require","i","f","Error","code","l","exports","call","length",1,"module","wnd","Eid","window","../../lib/eid",2,"preconditions","exceptions","./eid/eid","./eid/exceptions","./eid/preconditions",3,"JFormatter","format","this","arr","args","arguments","push","regex","_r","p","c","replace","reduce","id","ref","uniq","EidInternal","uniqIdGenerator","generateUniqId","undefined","makeLogMessage","logMessageFormat","parameters","message","getMessageFormat","toString","refFormat","getId","getRef","getUniq","MathRandom","LONG_MAX","Math","pow","LONG_MIN","nextLong","nextNumber","nextInt","max","min","floor","random","StdUniqIdGenerator","BASE36","INTEGER_MAX_VALUE","MIN_6_CHAR_HASH","generator","padding","first","abs","second","calc","hash","String","slice","DEFAULT_FORMAT","DEFAULT_REF_FORMAT","DEFAULT_MESSAGE_FORMAT","DEFAULT_UNIQ_ID_GENERATOR","Object","defineProperty","get","FORMAT_NUM_SPEC","REF_FORMAT_NUM_SPEC","MESSAGE_FORMAT_NUM_SPEC","messageFormat","validateFormat","numSpecifiers","TypeError","specifiers","formatted","specifier","indexOf","setUniqIdGenerator","previous","setFormat","previously","setRefFormat","setMessageFormat","oldFormat",4,"EidRuntimeException","eid","validateEid","prepareMessage","tmp","apply","name","correctStackTrace","EidNullPointerException","EidIllegalArgumentException","EidIllegalStateException","EidIndexOutOfBoundsException","CorrectStackTrace","modern","target","constructor","captureStackTrace","fixLegancyStackTrace","stack","stringified","st","trim","legancy","exceptionConstructor","handler","prototype","create","value","./eid",5,"EidPreconditions","isNullike","reference","checkNotNull","ensureEid","candidate","isIndexAndSizeIllegal","index","size","isSizeIllegal","checkNotNullable","checkedEid","checkNotUndefined","checkArgument","expression","checkState","checkElementIndex","tryToExecute","supplier","throwable","./exceptions"],"mappings":"CAAA,QAAAA,GAAAC,EAAAC,EAAAC,GAAA,QAAAC,GAAAC,EAA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AAAhC,GAAAgC,EAAAnG,IAcAwF,EAAAe,WAAA,SAAAD,EAAA3C,EAAA3D,GACA,GAAAmG,GAAAP,EAAAjC,EACA,KAAA6B,EAAAU,iBAAAI,EAAAH,GACA,KAAA,IAAA/B,GAAA+B,EAAAnG,IAwBAwF,EAAAgB,kBAAA,SAAAT,EAAAC,EAAArC,EAAA3D,GACA,GAAAmG,GAAAP,EAAAjC,EACA,IAAAsC,EAAAD,GACA,KAAA,IAAA7B,GAAAgC,EAAAnG,EAEA,IAAA8F,EAAAC,EAAAC,GACA,KAAA,IAAA3B,GAAA8B,EAAAnG,EAEA,OAAA+F,IAyBAP,EAAAiB,aAAA,SAAAC,EAAA/C,GACA,GAAAwC,GAAAP,EAAAjC,EACA,KACA,MAAA6B,GAAAU,iBAAAQ,EAAAP,GAAApC,QACA,MAAA4C,GACA,KAAA,IAAAjD,GAAAyC,EAAAQ,KAIA9I,EAAAJ,QAAA+H,GACA3H,KJmgBGyH,QAAQ,EAAEsB,eAAe,SAAS","file":"eid.min.js","sourcesContent":["(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;oThis class shouldn't be used in any public API or library. It is designed to be used for in-house development\n * of end user applications which will report Bugs in standardized error pages or post them to issue tracker.\n *

\n * Exception identifier for all Eid Runtime Exceptions.\n * @constructor\n * @param {string} id - the exception id, must be unique developer inserted string, from date\n * @param {string} ref - an optional reference\n */\nfunction Eid(id, ref) {\n var uniq = EidInternal.uniqIdGenerator.generateUniqId();\n ref = (ref === null || ref == undefined) ? \"\" : ref;\n\n /**\n * Makes a log message from this EID object\n *

\n *

This method is for convenience of usage of EID in logging. You can use it like this:\n *

\n *

\n   * log.debug(new Eid(\"20151025:202129\").makeLogMessage(\"A request: %s\", request));\n   * 
\n * @param {string} logMessageFormat - a log message format as accepted by {@link String#format(String, Object...)}\n * @param {Object...} parameters - a parameters for logMessageFormat to by passed to {@link String#format(String, Object...)}\n * @return {string} a formatted message\n */\n this.makeLogMessage = function(logMessageFormat) {\n var parameters = [];\n for (var i = 1; i < arguments.length; i++) {\n parameters.push(arguments[i]);\n }\n var message = new JFormatter(logMessageFormat).format(parameters);\n return new JFormatter(Eid.getMessageFormat()).format(this.toString(), message);\n }\n\n /**\n * Standard to string method\n */\n this.toString = function() {\n if (\"\" === ref) {\n return new JFormatter(EidInternal.format).format(id, uniq);\n }\n return new JFormatter(EidInternal.refFormat).format(id, ref, uniq);\n }\n\n /**\n * Getter for constant Exception ID\n *\n * @return {string} ID of exception\n */\n this.getId = function() {\n return id;\n }\n\n /**\n * Get custom ref passed to Exception ID\n *\n * @return {string} ID of exception\n */\n this.getRef = function() {\n return ref;\n }\n\n /**\n * Gets unique generated string for this instance of Eid\n *\n * @return {string} a unique string\n */\n this.getUniq = function() {\n return uniq;\n }\n}\n\nfunction MathRandom() {\n var LONG_MAX = Math.pow(2, 53) - 1;\n var LONG_MIN = -1 * Math.pow(2, 53);\n this.nextLong = function() {\n return this.nextNumber(LONG_MIN, LONG_MAX);\n };\n this.nextInt = function(max) {\n return this.nextNumber(0, max);\n };\n this.nextNumber = function(min, max) {\n return Math.floor(Math.random() * (max - min + 1)) + min;\n };\n}\n\nfunction StdUniqIdGenerator() {\n var BASE36 = 36;\n var INTEGER_MAX_VALUE = Math.pow(2, 31);\n var MIN_6_CHAR_HASH = 60466177; // for '100001' in base64\n var generator = new MathRandom();\n var padding = generator.nextNumber(MIN_6_CHAR_HASH, INTEGER_MAX_VALUE).toString(BASE36);\n this.generateUniqId = function() {\n var first = Math.abs(generator.nextLong() + 1);\n var second = Math.abs(generator.nextInt(INTEGER_MAX_VALUE));\n var calc = first + second;\n var hash = (Math.abs(calc) % INTEGER_MAX_VALUE).toString(BASE36);\n return String(padding + hash).slice(-6); // pad output string to six chars using random padding\n };\n}\n\nvar DEFAULT_FORMAT = \"[%s]<%s>\";\nvar DEFAULT_REF_FORMAT = \"[%s|%s]<%s>\";\nvar DEFAULT_MESSAGE_FORMAT = \"%s => %s\";\nvar DEFAULT_UNIQ_ID_GENERATOR = new StdUniqIdGenerator();\n\nObject.defineProperty(Eid, \"DEFAULT_FORMAT\", {\n get: function() { return DEFAULT_FORMAT; }\n});\nObject.defineProperty(Eid, \"DEFAULT_MESSAGE_FORMAT\", {\n get: function() { return DEFAULT_MESSAGE_FORMAT; }\n});\nObject.defineProperty(Eid, \"DEFAULT_REF_FORMAT\", {\n get: function() { return DEFAULT_REF_FORMAT; }\n});\nObject.defineProperty(Eid, \"DEFAULT_UNIQ_ID_GENERATOR\", {\n get: function() { return DEFAULT_UNIQ_ID_GENERATOR; }\n});\n\nvar FORMAT_NUM_SPEC = 2;\nvar REF_FORMAT_NUM_SPEC = 3;\nvar MESSAGE_FORMAT_NUM_SPEC = 2;\n\nvar EidInternal = {\n messageFormat: DEFAULT_MESSAGE_FORMAT,\n uniqIdGenerator: DEFAULT_UNIQ_ID_GENERATOR,\n format: DEFAULT_FORMAT,\n refFormat: DEFAULT_REF_FORMAT\n};\n\nvar validateFormat = function(format, numSpecifiers) {\n if (format === null || format === undefined) {\n throw new TypeError(\"Format can't be null, but just received one\");\n }\n var specifiers = [];\n for (var i = 0; i < numSpecifiers; i++) {\n specifiers.push(i + \"-test-id\");\n }\n var formatted = new JFormatter(format).format(specifiers);\n for (var specifier in specifiers) {\n if (formatted.indexOf(specifier) === -1) {\n throw new TypeError(\"Given format contains to little format specifiers, \" +\n \"expected \" + numSpecifiers + \" but given \\\"\" + format + \"\\\"\");\n }\n }\n};\n\n/**\n * Sets the actual unique ID generator that will be used to generate IDs for all Eid objects. It will return previously used\n * generator.\n *\n * @param {UniqIdGenerator} uniqIdGenerator - new instance of unique ID generator\n * @return {UniqIdGenerator} a previously used unique ID generator\n * @throws {TypeError} if given generator was null\n */\nEid.setUniqIdGenerator = function(uniqIdGenerator) {\n if (uniqIdGenerator === null || uniqIdGenerator === undefined) {\n throw new TypeError(\"Unique ID generator can't be null, but given one\");\n }\n var previous = EidInternal.uniqIdGenerator;\n EidInternal.uniqIdGenerator = uniqIdGenerator;\n return previous;\n};\n\n/**\n * Sets the actual format that will be used in {@link #toString()} method. It will return previously used format.\n *\n * @param {string} format - a format compliant with {@link String#format(String, Object...)} with 2 object arguments\n * @return {string} a previously used format\n * @throws {TypeError} if given format hasn't got two format specifiers \"%s\", or if given format was\n * null\n */\nEid.setFormat = function(format) {\n validateFormat(format, FORMAT_NUM_SPEC);\n var previously = EidInternal.format;\n EidInternal.format = format;\n return previously;\n};\n\n/**\n * Sets the actual format that will be used in {@link #toString()} method\n *\n * @param {string} refFormat - a format compliant with {@link String#format(String, Object...)} with 3 object arguments\n * @return {string} a previously used format\n * @throws {TypeError} if given format hasn't got tree format specifiers \"%s\", or if given format was\n * null\n */\nEid.setRefFormat = function(refFormat) {\n validateFormat(refFormat, REF_FORMAT_NUM_SPEC);\n var previously = EidInternal.refFormat;\n EidInternal.refFormat = refFormat;\n return previously;\n};\n\n/**\n * Sets a format that will be used for all Eid exceptions when printing a detail message.\n *

\n * Format must be non-null and contain two format specifiers \"%s\"\n *\n * @param {string} format - a format that will be used, must be non-null and contain two format specifiers \"%s\"\n * @return {string} previously used format\n * @throws {TypeError} if given format hasn't got two format specifiers \"%s\", or if given format was\n * null\n */\nEid.setMessageFormat = function(format) {\n validateFormat(format, MESSAGE_FORMAT_NUM_SPEC);\n var oldFormat = EidInternal.messageFormat;\n EidInternal.messageFormat = format;\n return oldFormat;\n};\n\n/**\n * Gets actually set message format\n *\n * @return {string} actually setted message format\n */\nEid.getMessageFormat = function() {\n return EidInternal.messageFormat;\n};\n\nmodule.exports = Eid;\n\n})(module);\n\n},{}],4:[function(require,module,exports){\n/*\n * Copyright 2016 Wave Software\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n(function(exports) {\n 'use strict';\n\n var Eid = require('./eid');\n\n var prepareMessage = function(eid, message) {\n return message !== undefined ? (eid + \" \" + message) : eid;\n };\n\n var validateEid = function(eid) {\n if (eid === undefined) {\n throw new TypeError('You need to provide an valid Eid number to EidRuntimeExceptions, but given undefined');\n }\n if (!(eid instanceof Eid)) {\n eid = new Eid(eid.toString());\n }\n return eid;\n };\n\n var CorrectStackTrace = {\n modern: function(target, constructor) {\n Error.captureStackTrace(target, constructor);\n },\n fixLegancyStackTrace: function(stack, stringified) {\n var st = stack;\n if (typeof(stack) !== 'string') {\n // On IE the stack field is empty so setting to toString() :-/\n st = stringified;\n }\n // Hands down, if all fails, just replace Error with nice Eid string\n if (st.indexOf(stringified) < 0) {\n st = st.replace(/^(?:Error\\n)?/, stringified + \"\\n\").trim();\n }\n return st;\n },\n legancy: function(target, constructor, exceptionConstructor) {\n // Hacks for IE an Edge\n var stringified = target.toString();\n // try to fetch stacktrace from JS standard Error\n var st = (new exceptionConstructor()).stack;\n target.stack = CorrectStackTrace.fixLegancyStackTrace(st, stringified);\n }\n };\n CorrectStackTrace.fixLegancyStackTrace('Error\\n');\n CorrectStackTrace.legancy({}, null, Object);\n\n var correctStackTrace = function(target, constructor) {\n var handler = typeof(Error.captureStackTrace) === 'function' ?\n CorrectStackTrace.modern : CorrectStackTrace.legancy;\n handler(target, constructor, Error);\n };\n\n /**\n * This class shouldn't be used in any public API or library. It is designed to be used for in-house development\n * of end user applications which will report Bugs in standardized error pages or post them to issue tracker.\n *

\n * This exception class is baseline of all Eid runtime exception classes. It is designed to ease of use and provide strict ID for\n * given Exception usage. This approach speed up development of large application and helps support teams to by giving the both\n * static and random ID for each possible unpredicted bug.\n *

\n * This is best to use with tools and plugins like\n * EidGenerator for Netbeans IDE\n *

\n * For convenience use {@link eid.Preconditions}\n *\n * @constructor\n * @param {string} eid - an exception Id, should be generated\n * @param {string} message - an message for the exception\n * @author Krzysztof Suszyński \n */\n function EidRuntimeException(eid, message) {\n eid = validateEid(eid);\n message = prepareMessage(eid, message);\n var tmp = Error.apply(this, [message]);\n tmp.name = this.name = 'EidRuntimeException';\n this.message = tmp.message;\n this.eid = eid;\n correctStackTrace(this, EidRuntimeException);\n\n return this;\n }\n EidRuntimeException.prototype = Object.create(Error.prototype, {\n constructor: { value: EidRuntimeException }\n });\n\n /**\n * This class shouldn't be used in any public API or library. It is designed to be used for in-house development\n * of end user applications which will report Bugs in standardized error pages or post them to issue tracker.\n *

\n * This id Eid version of {@link NullPointerException}\n *\n * @constructor\n * @param {string} eid - an exception Id, should be generated\n * @param {string} message - an message for the exception\n * @see NullPointerException\n * @see EidRuntimeException\n * @author Krzysztof Suszyński \n */\n function EidNullPointerException(eid, message) {\n var tmp = EidRuntimeException.apply(this, [eid, message]);\n tmp.name = this.name = 'EidNullPointerException';\n correctStackTrace(this, EidNullPointerException);\n return this;\n }\n EidNullPointerException.prototype = Object.create(EidRuntimeException.prototype, {\n constructor: { value: EidNullPointerException }\n });\n\n /**\n * This class shouldn't be used in any public API or library. It is designed to be used for in-house development\n * of end user applications which will report Bugs in standardized error pages or post them to issue tracker.\n *

\n * This is Eid version of {@link IllegalArgumentException}\n *\n * @constructor\n * @param {string} eid - an exception Id, should be generated\n * @param {string} message - an message for the exception\n * @see IllegalArgumentException\n * @see EidRuntimeException\n * @author Krzysztof Suszyński \n */\n function EidIllegalArgumentException(eid, message) {\n var tmp = EidRuntimeException.apply(this, [eid, message]);\n tmp.name = this.name = 'EidIllegalArgumentException';\n correctStackTrace(this, EidIllegalArgumentException);\n return this;\n }\n EidIllegalArgumentException.prototype = Object.create(EidRuntimeException.prototype, {\n constructor: { value: EidIllegalArgumentException }\n });\n\n /**\n * This class shouldn't be used in any public API or library. It is designed to be used for in-house development\n * of end user applications which will report Bugs in standardized error pages or post them to issue tracker.\n *

\n * This id Eid version of {@link IllegalStateException}\n *\n * @constructor\n * @param {string} eid - an exception Id, should be generated\n * @param {string} message - an message for the exception\n * @see IllegalStateException\n * @see EidRuntimeException\n * @author Krzysztof Suszyński \n */\n function EidIllegalStateException(eid, message) {\n var tmp = EidRuntimeException.apply(this, [eid, message]);\n tmp.name = this.name = 'EidIllegalStateException';\n correctStackTrace(this, EidIllegalStateException);\n return this;\n }\n EidIllegalStateException.prototype = Object.create(EidRuntimeException.prototype, {\n constructor: { value: EidIllegalStateException }\n });\n\n /**\n * This class shouldn't be used in any public API or library. It is designed to be used for in-house development\n * of end user applications which will report Bugs in standardized error pages or post them to issue tracker.\n *

\n * This id Eid version of {@link IndexOutOfBoundsException}\n *\n * @constructor\n * @param {string} eid - an exception Id, should be generated\n * @param {string} message - an message for the exception\n * @see IndexOutOfBoundsException\n * @see EidRuntimeException\n * @author Krzysztof Suszyński \n */\n function EidIndexOutOfBoundsException(eid, message) {\n var tmp = EidRuntimeException.apply(this, [eid, message]);\n tmp.name = this.name = 'EidIndexOutOfBoundsException';\n correctStackTrace(this, EidIndexOutOfBoundsException);\n return this;\n }\n EidIndexOutOfBoundsException.prototype = Object.create(EidRuntimeException.prototype, {\n constructor: { value: EidIndexOutOfBoundsException }\n });\n\n exports.EidRuntimeException = EidRuntimeException;\n exports.EidNullPointerException = EidNullPointerException;\n exports.EidIllegalArgumentException = EidIllegalArgumentException;\n exports.EidIllegalStateException = EidIllegalStateException;\n exports.EidIndexOutOfBoundsException = EidIndexOutOfBoundsException;\n\n})(exports);\n\n},{\"./eid\":3}],5:[function(require,module,exports){\n/*\n * Copyright 2016 Wave Software\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n(function(module) {\n'use strict';\n\nvar Eid = require('./eid');\nvar EidRuntimeException = require('./exceptions').EidRuntimeException;\nvar EidNullPointerException = require('./exceptions').EidNullPointerException;\nvar EidIllegalArgumentException = require('./exceptions').EidIllegalArgumentException;\nvar EidIllegalStateException = require('./exceptions').EidIllegalStateException;\nvar EidIndexOutOfBoundsException = require('./exceptions').EidIndexOutOfBoundsException;\n\n/**\n * This class shouldn't be used in any public API or library. It is designed to be used for in-house development\n * of end user applications which will report Bugs in standardized error pages or post them to issue tracker.\n *

\n * Static convenience methods that help a method or constructor check whether it was invoked correctly (whether its\n * preconditions\n * have been met). These methods generally accept a {@code boolean} expression which is expected to be {@code true} (or in the\n * case of {@code\n * checkNotNull}, an object reference which is expected to be non-null). When {@code false} (or {@code null}) is passed instead,\n * the {@code EidPreconditions} method throws an unchecked exception, which helps the calling method communicate to its\n * caller that\n * that caller has made a mistake.\n *

\n * Each method accepts a EID String or {@link Eid} object, which is designed to ease of use and provide strict ID for given\n * Exception usage. This approach speed up development of large application and helps support teams to by giving the both static\n * and random ID for each possible unpredicted bug.\n *

\n * This is best to use with tools and plugins like\n * EidGenerator for Netbeans IDE\n *

\n * Example:\n *

   {@code\n *\n *   /**\n *    * Returns the positive square root of the given value.\n *    *\n *    * @throws EidIllegalArgumentException if the value is negative\n *    *}{@code /\n *   public static double sqrt(double value) {\n *     EidPreconditions.checkArgument(value >= 0.0, \"20150718:012333\");\n *     // calculate the square root\n *   }\n *\n *   void exampleBadCaller() {\n *     double d = sqrt(-1.0);\n *   }\n * }
\n *

\n * In this example, {@code checkArgument} throws an {@code EidIllegalArgumentException} to indicate that {@code exampleBadCaller}\n * made an error in its call to {@code sqrt}. Exception, when it will be printed will contain user given Eid and also\n * Randomly generated ID. Those fields can be displayed to user on error page on posted directly to issue tracker.\n *

\n * Example:\n *

\n *

\n *\n * {@code\n *   // Main application class for ex.: http servlet\n *    try {\n *        performRequest(request, response);\n *    } catch (EidRuntimeException ex) {\n *        issuesTracker.put(ex);\n *        throw ex;\n *    }\n * }
\n *

\n *

\n *

Functional try to execute blocks

\n *

\n *

\n * Using functional blocks to handle operations, that are intended to operate properly, simplify the code and makes it more\n * readable. It's also good way to deal with untested, uncovered {@code catch} blocks. It's easy and gives developers nice way of\n * dealing with countless operations that suppose to work as intended.\n *

\n *

\n * Example:\n *

\n *\n *     InputStream is = EidPreconditions.tryToExecute({@code new UnsafeSupplier}() {\n *        {@literal @}Override\n *         public InputStream get() throws IOException {\n *             return this.getClass().getClassLoader()\n *                 .getResourceAsStream(\"project.properties\");\n *         }\n *     }, \"20150718:121521\");\n * 
\n *\n * @constructor\n * @author Krzysztof Suszyński \n * @since 0.1.0 (idea imported from Guava Library and COI code)\n */\nfunction EidPreconditions() {}\n\nfunction isNullike(reference) {\n return reference === null || reference === undefined;\n}\n\nfunction checkNotNull(reference) {\n if (isNullike(reference)) {\n throw new TypeError(\"Pass not-null Eid to EidPreconditions first!\");\n }\n return reference;\n}\n\nfunction ensureEid(candidate) {\n candidate = checkNotNull(candidate);\n var eid;\n if (!(candidate instanceof Eid)) {\n eid = new Eid(candidate + '');\n } else {\n eid = candidate;\n }\n return eid;\n}\n\n/**\n * Ensures that an object reference passed as a parameter to the calling method is not null-like.\n *\n * @param {Object} reference - an object reference\n * @param {string|Eid} eid - the exception ID to use if the check fails\n * @param {string} message - message for produced exception\n * @return {Object} the non-null reference that was validated\n * @throws {EidNullPointerException} if {@code reference} is null-like\n */\nEidPreconditions.checkNotNullable = function(reference, eid, message) {\n var checkedEid = ensureEid(eid);\n if (isNullike(reference)) {\n throw new EidNullPointerException(checkedEid, message);\n }\n return reference;\n};\n\n/**\n * Ensures that an object reference passed as a parameter to the calling method is not null.\n *\n * @param {Object} reference - an object reference\n * @param {string|Eid} eid - the exception ID to use if the check fails\n * @param {string} message - message for produced exception\n * @return {Object} the non-null reference that was validated\n * @throws {EidNullPointerException} if {@code reference} is null-like\n */\nEidPreconditions.checkNotNull = function(reference, eid, message) {\n var checkedEid = ensureEid(eid);\n if (reference === null) {\n throw new EidNullPointerException(checkedEid, message);\n }\n return reference;\n};\n\n/**\n * Ensures that an object reference passed as a parameter to the calling method is not undefined.\n *\n * @param {Object} reference - an object reference\n * @param {string|Eid} eid - the exception ID to use if the check fails\n * @param {string} message - message for produced exception\n * @return {Object} the non-null reference that was validated\n * @throws {EidNullPointerException} if {@code reference} is null-like\n */\nEidPreconditions.checkNotUndefined = function(reference, eid, message) {\n var checkedEid = ensureEid(eid);\n if (reference === undefined) {\n throw new EidNullPointerException(checkedEid, message);\n }\n return reference;\n};\n\n/**\n * Ensures the truth of an expression involving one or more parameters to the calling method.\n *\n * @param {boolean} expression - a boolean expression\n * @param {string|Eid} eid - the exception ID to use if the check fails\n * @param {string} message - optional message for generated exception\n * @throws {EidIllegalArgumentException} if {@code expression} is false\n * @throws {EidNullPointerException} if {@code expression} is null\n */\nEidPreconditions.checkArgument = function(expression, eid, message) {\n var checkedEid = ensureEid(eid);\n if (!EidPreconditions.checkNotNullable(expression, checkedEid)) {\n throw new EidIllegalArgumentException(checkedEid, message)\n }\n};\n\n/**\n * Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the\n * calling method.\n *\n * @param {boolean} expression - a boolean expression\n * @param {string|Eid} eid - the exception ID to use if the check fails\n * @param {string} message - optional message for generated exception\n * @throws {EidIllegalStateException} if {@code expression} is false\n * @throws {EidNullPointerException} if {@code expression} is null\n */\nEidPreconditions.checkState = function(expression, eid, message) {\n var checkedEid = ensureEid(eid);\n if (!EidPreconditions.checkNotNullable(expression, checkedEid)) {\n throw new EidIllegalStateException(checkedEid, message);\n }\n};\n\nfunction isIndexAndSizeIllegal(index, size) {\n return index < 0 || index > size;\n}\n\nfunction isSizeIllegal(size) {\n return size < 0;\n}\n\n/**\n * Ensures that {@code index} specifies a valid element in an array, list or string of size {@code size}. An element\n * index may range from zero, inclusive, to {@code size}, exclusive.\n *\n * @param {number} index - a user-supplied index identifying an element of an array, list or string\n * @param {numer} size - the size of that array, list or string\n * @param {string|Eid} eid - the text to use to describe this index in an error message\n * @param {string} message - optional message for generated exception\n * @return {number} the value of {@code index}\n * @throws {EidIndexOutOfBoundsException} if {@code index} is negative or is not less than {@code size}\n * @throws {EidIllegalArgumentException} if {@code size} is negative\n */\nEidPreconditions.checkElementIndex = function(index, size, eid, message) {\n var checkedEid = ensureEid(eid);\n if (isSizeIllegal(size)) {\n throw new EidIllegalArgumentException(checkedEid, message);\n }\n if (isIndexAndSizeIllegal(index, size)) {\n throw new EidIndexOutOfBoundsException(checkedEid, message);\n }\n return index;\n};\n\n/**\n * Tries to execute code in given unsafe supplier code block, and if exception is thrown, it will gets rethrown as a\n * {@link EidRuntimeException} with eid given as a argument. This is because this exception is threaded as a software bug!\n *

\n * Example:\n *

\n *\n * Document doc = EidPreconditions.tryToExecute({@code new UnsafeSupplier}() {\n *    {@literal @}Override\n *     public Document get() throws IOException {\n *          DocumentBuilder docBuilder = ...\n *          return docBuilder.parse(new InputSource(reader));\n *     }\n * }, new Eid(\"20150718:121521\"));\n * 
\n *\n * @param return type\n * @param supplier unsafe supplier code to be executed within a try-catch block\n * @param eid unique developer identifier from date for ex.: \"20150716:123200\"\n * @return A block of code return type, if exception is not thrown\n * @throws EidRuntimeException if code block thrown any exception, which in that case is wrapped in EidRuntimeException\n */\nEidPreconditions.tryToExecute = function(supplier, eid) {\n var checkedEid = ensureEid(eid);\n try {\n return EidPreconditions.checkNotNullable(supplier, checkedEid).apply();\n } catch (throwable) {\n throw new EidRuntimeException(checkedEid, throwable);\n }\n};\n\nmodule.exports = EidPreconditions;\n})(module);\n\n},{\"./eid\":3,\"./exceptions\":4}]},{},[1])\n\n","/*\n * Copyright 2016 Wave Software\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n(function(module) {\n'use strict';\n\nvar Eid = require('./eid/eid');\nEid.preconditions = require('./eid/preconditions');\nEid.exceptions = require('./eid/exceptions');\n\nmodule.exports = Eid;\n\n})(module);\n","/*\n * Copyright 2016 Wave Software\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n(function(module) {\n'use strict';\n\nfunction JFormatter(format) {\n this.format = function(arr) {\n var args = [];\n if (arguments.length === 1 && typeof(arr) === 'object') {\n args = arr;\n } else {\n for (var i = 0; i < arguments.length; i++) {\n args.push(arguments[i]);\n }\n }\n var regex = /%s/;\n var _r = function(p,c) { return p.replace(regex, c); }\n return args.reduce(_r, format);\n };\n}\n\n/**\n * This class shouldn't be used in any public API or library. It is designed to be used for in-house development\n * of end user applications which will report Bugs in standardized error pages or post them to issue tracker.\n *

\n * Exception identifier for all Eid Runtime Exceptions.\n * @constructor\n * @param {string} id - the exception id, must be unique developer inserted string, from date\n * @param {string} ref - an optional reference\n */\nfunction Eid(id, ref) {\n var uniq = EidInternal.uniqIdGenerator.generateUniqId();\n ref = (ref === null || ref == undefined) ? \"\" : ref;\n\n /**\n * Makes a log message from this EID object\n *

\n *

This method is for convenience of usage of EID in logging. You can use it like this:\n *

\n *

\n   * log.debug(new Eid(\"20151025:202129\").makeLogMessage(\"A request: %s\", request));\n   * 
\n * @param {string} logMessageFormat - a log message format as accepted by {@link String#format(String, Object...)}\n * @param {Object...} parameters - a parameters for logMessageFormat to by passed to {@link String#format(String, Object...)}\n * @return {string} a formatted message\n */\n this.makeLogMessage = function(logMessageFormat) {\n var parameters = [];\n for (var i = 1; i < arguments.length; i++) {\n parameters.push(arguments[i]);\n }\n var message = new JFormatter(logMessageFormat).format(parameters);\n return new JFormatter(Eid.getMessageFormat()).format(this.toString(), message);\n }\n\n /**\n * Standard to string method\n */\n this.toString = function() {\n if (\"\" === ref) {\n return new JFormatter(EidInternal.format).format(id, uniq);\n }\n return new JFormatter(EidInternal.refFormat).format(id, ref, uniq);\n }\n\n /**\n * Getter for constant Exception ID\n *\n * @return {string} ID of exception\n */\n this.getId = function() {\n return id;\n }\n\n /**\n * Get custom ref passed to Exception ID\n *\n * @return {string} ID of exception\n */\n this.getRef = function() {\n return ref;\n }\n\n /**\n * Gets unique generated string for this instance of Eid\n *\n * @return {string} a unique string\n */\n this.getUniq = function() {\n return uniq;\n }\n}\n\nfunction MathRandom() {\n var LONG_MAX = Math.pow(2, 53) - 1;\n var LONG_MIN = -1 * Math.pow(2, 53);\n this.nextLong = function() {\n return this.nextNumber(LONG_MIN, LONG_MAX);\n };\n this.nextInt = function(max) {\n return this.nextNumber(0, max);\n };\n this.nextNumber = function(min, max) {\n return Math.floor(Math.random() * (max - min + 1)) + min;\n };\n}\n\nfunction StdUniqIdGenerator() {\n var BASE36 = 36;\n var INTEGER_MAX_VALUE = Math.pow(2, 31);\n var MIN_6_CHAR_HASH = 60466177; // for '100001' in base64\n var generator = new MathRandom();\n var padding = generator.nextNumber(MIN_6_CHAR_HASH, INTEGER_MAX_VALUE).toString(BASE36);\n this.generateUniqId = function() {\n var first = Math.abs(generator.nextLong() + 1);\n var second = Math.abs(generator.nextInt(INTEGER_MAX_VALUE));\n var calc = first + second;\n var hash = (Math.abs(calc) % INTEGER_MAX_VALUE).toString(BASE36);\n return String(padding + hash).slice(-6); // pad output string to six chars using random padding\n };\n}\n\nvar DEFAULT_FORMAT = \"[%s]<%s>\";\nvar DEFAULT_REF_FORMAT = \"[%s|%s]<%s>\";\nvar DEFAULT_MESSAGE_FORMAT = \"%s => %s\";\nvar DEFAULT_UNIQ_ID_GENERATOR = new StdUniqIdGenerator();\n\nObject.defineProperty(Eid, \"DEFAULT_FORMAT\", {\n get: function() { return DEFAULT_FORMAT; }\n});\nObject.defineProperty(Eid, \"DEFAULT_MESSAGE_FORMAT\", {\n get: function() { return DEFAULT_MESSAGE_FORMAT; }\n});\nObject.defineProperty(Eid, \"DEFAULT_REF_FORMAT\", {\n get: function() { return DEFAULT_REF_FORMAT; }\n});\nObject.defineProperty(Eid, \"DEFAULT_UNIQ_ID_GENERATOR\", {\n get: function() { return DEFAULT_UNIQ_ID_GENERATOR; }\n});\n\nvar FORMAT_NUM_SPEC = 2;\nvar REF_FORMAT_NUM_SPEC = 3;\nvar MESSAGE_FORMAT_NUM_SPEC = 2;\n\nvar EidInternal = {\n messageFormat: DEFAULT_MESSAGE_FORMAT,\n uniqIdGenerator: DEFAULT_UNIQ_ID_GENERATOR,\n format: DEFAULT_FORMAT,\n refFormat: DEFAULT_REF_FORMAT\n};\n\nvar validateFormat = function(format, numSpecifiers) {\n if (format === null || format === undefined) {\n throw new TypeError(\"Format can't be null, but just received one\");\n }\n var specifiers = [];\n for (var i = 0; i < numSpecifiers; i++) {\n specifiers.push(i + \"-test-id\");\n }\n var formatted = new JFormatter(format).format(specifiers);\n for (var specifier in specifiers) {\n if (formatted.indexOf(specifier) === -1) {\n throw new TypeError(\"Given format contains to little format specifiers, \" +\n \"expected \" + numSpecifiers + \" but given \\\"\" + format + \"\\\"\");\n }\n }\n};\n\n/**\n * Sets the actual unique ID generator that will be used to generate IDs for all Eid objects. It will return previously used\n * generator.\n *\n * @param {UniqIdGenerator} uniqIdGenerator - new instance of unique ID generator\n * @return {UniqIdGenerator} a previously used unique ID generator\n * @throws {TypeError} if given generator was null\n */\nEid.setUniqIdGenerator = function(uniqIdGenerator) {\n if (uniqIdGenerator === null || uniqIdGenerator === undefined) {\n throw new TypeError(\"Unique ID generator can't be null, but given one\");\n }\n var previous = EidInternal.uniqIdGenerator;\n EidInternal.uniqIdGenerator = uniqIdGenerator;\n return previous;\n};\n\n/**\n * Sets the actual format that will be used in {@link #toString()} method. It will return previously used format.\n *\n * @param {string} format - a format compliant with {@link String#format(String, Object...)} with 2 object arguments\n * @return {string} a previously used format\n * @throws {TypeError} if given format hasn't got two format specifiers \"%s\", or if given format was\n * null\n */\nEid.setFormat = function(format) {\n validateFormat(format, FORMAT_NUM_SPEC);\n var previously = EidInternal.format;\n EidInternal.format = format;\n return previously;\n};\n\n/**\n * Sets the actual format that will be used in {@link #toString()} method\n *\n * @param {string} refFormat - a format compliant with {@link String#format(String, Object...)} with 3 object arguments\n * @return {string} a previously used format\n * @throws {TypeError} if given format hasn't got tree format specifiers \"%s\", or if given format was\n * null\n */\nEid.setRefFormat = function(refFormat) {\n validateFormat(refFormat, REF_FORMAT_NUM_SPEC);\n var previously = EidInternal.refFormat;\n EidInternal.refFormat = refFormat;\n return previously;\n};\n\n/**\n * Sets a format that will be used for all Eid exceptions when printing a detail message.\n *

\n * Format must be non-null and contain two format specifiers \"%s\"\n *\n * @param {string} format - a format that will be used, must be non-null and contain two format specifiers \"%s\"\n * @return {string} previously used format\n * @throws {TypeError} if given format hasn't got two format specifiers \"%s\", or if given format was\n * null\n */\nEid.setMessageFormat = function(format) {\n validateFormat(format, MESSAGE_FORMAT_NUM_SPEC);\n var oldFormat = EidInternal.messageFormat;\n EidInternal.messageFormat = format;\n return oldFormat;\n};\n\n/**\n * Gets actually set message format\n *\n * @return {string} actually setted message format\n */\nEid.getMessageFormat = function() {\n return EidInternal.messageFormat;\n};\n\nmodule.exports = Eid;\n\n})(module);\n","/*\n * Copyright 2016 Wave Software\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n(function(exports) {\n 'use strict';\n\n var Eid = require('./eid');\n\n var prepareMessage = function(eid, message) {\n return message !== undefined ? (eid + \" \" + message) : eid;\n };\n\n var validateEid = function(eid) {\n if (eid === undefined) {\n throw new TypeError('You need to provide an valid Eid number to EidRuntimeExceptions, but given undefined');\n }\n if (!(eid instanceof Eid)) {\n eid = new Eid(eid.toString());\n }\n return eid;\n };\n\n var CorrectStackTrace = {\n modern: function(target, constructor) {\n Error.captureStackTrace(target, constructor);\n },\n fixLegancyStackTrace: function(stack, stringified) {\n var st = stack;\n if (typeof(stack) !== 'string') {\n // On IE the stack field is empty so setting to toString() :-/\n st = stringified;\n }\n // Hands down, if all fails, just replace Error with nice Eid string\n if (st.indexOf(stringified) < 0) {\n st = st.replace(/^(?:Error\\n)?/, stringified + \"\\n\").trim();\n }\n return st;\n },\n legancy: function(target, constructor, exceptionConstructor) {\n // Hacks for IE an Edge\n var stringified = target.toString();\n // try to fetch stacktrace from JS standard Error\n var st = (new exceptionConstructor()).stack;\n target.stack = CorrectStackTrace.fixLegancyStackTrace(st, stringified);\n }\n };\n CorrectStackTrace.fixLegancyStackTrace('Error\\n');\n CorrectStackTrace.legancy({}, null, Object);\n\n var correctStackTrace = function(target, constructor) {\n var handler = typeof(Error.captureStackTrace) === 'function' ?\n CorrectStackTrace.modern : CorrectStackTrace.legancy;\n handler(target, constructor, Error);\n };\n\n /**\n * This class shouldn't be used in any public API or library. It is designed to be used for in-house development\n * of end user applications which will report Bugs in standardized error pages or post them to issue tracker.\n *

\n * This exception class is baseline of all Eid runtime exception classes. It is designed to ease of use and provide strict ID for\n * given Exception usage. This approach speed up development of large application and helps support teams to by giving the both\n * static and random ID for each possible unpredicted bug.\n *

\n * This is best to use with tools and plugins like\n * EidGenerator for Netbeans IDE\n *

\n * For convenience use {@link eid.Preconditions}\n *\n * @constructor\n * @param {string} eid - an exception Id, should be generated\n * @param {string} message - an message for the exception\n * @author Krzysztof Suszyński \n */\n function EidRuntimeException(eid, message) {\n eid = validateEid(eid);\n message = prepareMessage(eid, message);\n var tmp = Error.apply(this, [message]);\n tmp.name = this.name = 'EidRuntimeException';\n this.message = tmp.message;\n this.eid = eid;\n correctStackTrace(this, EidRuntimeException);\n\n return this;\n }\n EidRuntimeException.prototype = Object.create(Error.prototype, {\n constructor: { value: EidRuntimeException }\n });\n\n /**\n * This class shouldn't be used in any public API or library. It is designed to be used for in-house development\n * of end user applications which will report Bugs in standardized error pages or post them to issue tracker.\n *

\n * This id Eid version of {@link NullPointerException}\n *\n * @constructor\n * @param {string} eid - an exception Id, should be generated\n * @param {string} message - an message for the exception\n * @see NullPointerException\n * @see EidRuntimeException\n * @author Krzysztof Suszyński \n */\n function EidNullPointerException(eid, message) {\n var tmp = EidRuntimeException.apply(this, [eid, message]);\n tmp.name = this.name = 'EidNullPointerException';\n correctStackTrace(this, EidNullPointerException);\n return this;\n }\n EidNullPointerException.prototype = Object.create(EidRuntimeException.prototype, {\n constructor: { value: EidNullPointerException }\n });\n\n /**\n * This class shouldn't be used in any public API or library. It is designed to be used for in-house development\n * of end user applications which will report Bugs in standardized error pages or post them to issue tracker.\n *

\n * This is Eid version of {@link IllegalArgumentException}\n *\n * @constructor\n * @param {string} eid - an exception Id, should be generated\n * @param {string} message - an message for the exception\n * @see IllegalArgumentException\n * @see EidRuntimeException\n * @author Krzysztof Suszyński \n */\n function EidIllegalArgumentException(eid, message) {\n var tmp = EidRuntimeException.apply(this, [eid, message]);\n tmp.name = this.name = 'EidIllegalArgumentException';\n correctStackTrace(this, EidIllegalArgumentException);\n return this;\n }\n EidIllegalArgumentException.prototype = Object.create(EidRuntimeException.prototype, {\n constructor: { value: EidIllegalArgumentException }\n });\n\n /**\n * This class shouldn't be used in any public API or library. It is designed to be used for in-house development\n * of end user applications which will report Bugs in standardized error pages or post them to issue tracker.\n *

\n * This id Eid version of {@link IllegalStateException}\n *\n * @constructor\n * @param {string} eid - an exception Id, should be generated\n * @param {string} message - an message for the exception\n * @see IllegalStateException\n * @see EidRuntimeException\n * @author Krzysztof Suszyński \n */\n function EidIllegalStateException(eid, message) {\n var tmp = EidRuntimeException.apply(this, [eid, message]);\n tmp.name = this.name = 'EidIllegalStateException';\n correctStackTrace(this, EidIllegalStateException);\n return this;\n }\n EidIllegalStateException.prototype = Object.create(EidRuntimeException.prototype, {\n constructor: { value: EidIllegalStateException }\n });\n\n /**\n * This class shouldn't be used in any public API or library. It is designed to be used for in-house development\n * of end user applications which will report Bugs in standardized error pages or post them to issue tracker.\n *

\n * This id Eid version of {@link IndexOutOfBoundsException}\n *\n * @constructor\n * @param {string} eid - an exception Id, should be generated\n * @param {string} message - an message for the exception\n * @see IndexOutOfBoundsException\n * @see EidRuntimeException\n * @author Krzysztof Suszyński \n */\n function EidIndexOutOfBoundsException(eid, message) {\n var tmp = EidRuntimeException.apply(this, [eid, message]);\n tmp.name = this.name = 'EidIndexOutOfBoundsException';\n correctStackTrace(this, EidIndexOutOfBoundsException);\n return this;\n }\n EidIndexOutOfBoundsException.prototype = Object.create(EidRuntimeException.prototype, {\n constructor: { value: EidIndexOutOfBoundsException }\n });\n\n exports.EidRuntimeException = EidRuntimeException;\n exports.EidNullPointerException = EidNullPointerException;\n exports.EidIllegalArgumentException = EidIllegalArgumentException;\n exports.EidIllegalStateException = EidIllegalStateException;\n exports.EidIndexOutOfBoundsException = EidIndexOutOfBoundsException;\n\n})(exports);\n","/*\n * Copyright 2016 Wave Software\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n(function(module) {\n'use strict';\n\nvar Eid = require('./eid');\nvar EidRuntimeException = require('./exceptions').EidRuntimeException;\nvar EidNullPointerException = require('./exceptions').EidNullPointerException;\nvar EidIllegalArgumentException = require('./exceptions').EidIllegalArgumentException;\nvar EidIllegalStateException = require('./exceptions').EidIllegalStateException;\nvar EidIndexOutOfBoundsException = require('./exceptions').EidIndexOutOfBoundsException;\n\n/**\n * This class shouldn't be used in any public API or library. It is designed to be used for in-house development\n * of end user applications which will report Bugs in standardized error pages or post them to issue tracker.\n *

\n * Static convenience methods that help a method or constructor check whether it was invoked correctly (whether its\n * preconditions\n * have been met). These methods generally accept a {@code boolean} expression which is expected to be {@code true} (or in the\n * case of {@code\n * checkNotNull}, an object reference which is expected to be non-null). When {@code false} (or {@code null}) is passed instead,\n * the {@code EidPreconditions} method throws an unchecked exception, which helps the calling method communicate to its\n * caller that\n * that caller has made a mistake.\n *

\n * Each method accepts a EID String or {@link Eid} object, which is designed to ease of use and provide strict ID for given\n * Exception usage. This approach speed up development of large application and helps support teams to by giving the both static\n * and random ID for each possible unpredicted bug.\n *

\n * This is best to use with tools and plugins like\n * EidGenerator for Netbeans IDE\n *

\n * Example:\n *

   {@code\n *\n *   /**\n *    * Returns the positive square root of the given value.\n *    *\n *    * @throws EidIllegalArgumentException if the value is negative\n *    *}{@code /\n *   public static double sqrt(double value) {\n *     EidPreconditions.checkArgument(value >= 0.0, \"20150718:012333\");\n *     // calculate the square root\n *   }\n *\n *   void exampleBadCaller() {\n *     double d = sqrt(-1.0);\n *   }\n * }
\n *

\n * In this example, {@code checkArgument} throws an {@code EidIllegalArgumentException} to indicate that {@code exampleBadCaller}\n * made an error in its call to {@code sqrt}. Exception, when it will be printed will contain user given Eid and also\n * Randomly generated ID. Those fields can be displayed to user on error page on posted directly to issue tracker.\n *

\n * Example:\n *

\n *

\n *\n * {@code\n *   // Main application class for ex.: http servlet\n *    try {\n *        performRequest(request, response);\n *    } catch (EidRuntimeException ex) {\n *        issuesTracker.put(ex);\n *        throw ex;\n *    }\n * }
\n *

\n *

\n *

Functional try to execute blocks

\n *

\n *

\n * Using functional blocks to handle operations, that are intended to operate properly, simplify the code and makes it more\n * readable. It's also good way to deal with untested, uncovered {@code catch} blocks. It's easy and gives developers nice way of\n * dealing with countless operations that suppose to work as intended.\n *

\n *

\n * Example:\n *

\n *\n *     InputStream is = EidPreconditions.tryToExecute({@code new UnsafeSupplier}() {\n *        {@literal @}Override\n *         public InputStream get() throws IOException {\n *             return this.getClass().getClassLoader()\n *                 .getResourceAsStream(\"project.properties\");\n *         }\n *     }, \"20150718:121521\");\n * 
\n *\n * @constructor\n * @author Krzysztof Suszyński \n * @since 0.1.0 (idea imported from Guava Library and COI code)\n */\nfunction EidPreconditions() {}\n\nfunction isNullike(reference) {\n return reference === null || reference === undefined;\n}\n\nfunction checkNotNull(reference) {\n if (isNullike(reference)) {\n throw new TypeError(\"Pass not-null Eid to EidPreconditions first!\");\n }\n return reference;\n}\n\nfunction ensureEid(candidate) {\n candidate = checkNotNull(candidate);\n var eid;\n if (!(candidate instanceof Eid)) {\n eid = new Eid(candidate + '');\n } else {\n eid = candidate;\n }\n return eid;\n}\n\n/**\n * Ensures that an object reference passed as a parameter to the calling method is not null-like.\n *\n * @param {Object} reference - an object reference\n * @param {string|Eid} eid - the exception ID to use if the check fails\n * @param {string} message - message for produced exception\n * @return {Object} the non-null reference that was validated\n * @throws {EidNullPointerException} if {@code reference} is null-like\n */\nEidPreconditions.checkNotNullable = function(reference, eid, message) {\n var checkedEid = ensureEid(eid);\n if (isNullike(reference)) {\n throw new EidNullPointerException(checkedEid, message);\n }\n return reference;\n};\n\n/**\n * Ensures that an object reference passed as a parameter to the calling method is not null.\n *\n * @param {Object} reference - an object reference\n * @param {string|Eid} eid - the exception ID to use if the check fails\n * @param {string} message - message for produced exception\n * @return {Object} the non-null reference that was validated\n * @throws {EidNullPointerException} if {@code reference} is null-like\n */\nEidPreconditions.checkNotNull = function(reference, eid, message) {\n var checkedEid = ensureEid(eid);\n if (reference === null) {\n throw new EidNullPointerException(checkedEid, message);\n }\n return reference;\n};\n\n/**\n * Ensures that an object reference passed as a parameter to the calling method is not undefined.\n *\n * @param {Object} reference - an object reference\n * @param {string|Eid} eid - the exception ID to use if the check fails\n * @param {string} message - message for produced exception\n * @return {Object} the non-null reference that was validated\n * @throws {EidNullPointerException} if {@code reference} is null-like\n */\nEidPreconditions.checkNotUndefined = function(reference, eid, message) {\n var checkedEid = ensureEid(eid);\n if (reference === undefined) {\n throw new EidNullPointerException(checkedEid, message);\n }\n return reference;\n};\n\n/**\n * Ensures the truth of an expression involving one or more parameters to the calling method.\n *\n * @param {boolean} expression - a boolean expression\n * @param {string|Eid} eid - the exception ID to use if the check fails\n * @param {string} message - optional message for generated exception\n * @throws {EidIllegalArgumentException} if {@code expression} is false\n * @throws {EidNullPointerException} if {@code expression} is null\n */\nEidPreconditions.checkArgument = function(expression, eid, message) {\n var checkedEid = ensureEid(eid);\n if (!EidPreconditions.checkNotNullable(expression, checkedEid)) {\n throw new EidIllegalArgumentException(checkedEid, message)\n }\n};\n\n/**\n * Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the\n * calling method.\n *\n * @param {boolean} expression - a boolean expression\n * @param {string|Eid} eid - the exception ID to use if the check fails\n * @param {string} message - optional message for generated exception\n * @throws {EidIllegalStateException} if {@code expression} is false\n * @throws {EidNullPointerException} if {@code expression} is null\n */\nEidPreconditions.checkState = function(expression, eid, message) {\n var checkedEid = ensureEid(eid);\n if (!EidPreconditions.checkNotNullable(expression, checkedEid)) {\n throw new EidIllegalStateException(checkedEid, message);\n }\n};\n\nfunction isIndexAndSizeIllegal(index, size) {\n return index < 0 || index > size;\n}\n\nfunction isSizeIllegal(size) {\n return size < 0;\n}\n\n/**\n * Ensures that {@code index} specifies a valid element in an array, list or string of size {@code size}. An element\n * index may range from zero, inclusive, to {@code size}, exclusive.\n *\n * @param {number} index - a user-supplied index identifying an element of an array, list or string\n * @param {numer} size - the size of that array, list or string\n * @param {string|Eid} eid - the text to use to describe this index in an error message\n * @param {string} message - optional message for generated exception\n * @return {number} the value of {@code index}\n * @throws {EidIndexOutOfBoundsException} if {@code index} is negative or is not less than {@code size}\n * @throws {EidIllegalArgumentException} if {@code size} is negative\n */\nEidPreconditions.checkElementIndex = function(index, size, eid, message) {\n var checkedEid = ensureEid(eid);\n if (isSizeIllegal(size)) {\n throw new EidIllegalArgumentException(checkedEid, message);\n }\n if (isIndexAndSizeIllegal(index, size)) {\n throw new EidIndexOutOfBoundsException(checkedEid, message);\n }\n return index;\n};\n\n/**\n * Tries to execute code in given unsafe supplier code block, and if exception is thrown, it will gets rethrown as a\n * {@link EidRuntimeException} with eid given as a argument. This is because this exception is threaded as a software bug!\n *

\n * Example:\n *

\n *\n * Document doc = EidPreconditions.tryToExecute({@code new UnsafeSupplier}() {\n *    {@literal @}Override\n *     public Document get() throws IOException {\n *          DocumentBuilder docBuilder = ...\n *          return docBuilder.parse(new InputSource(reader));\n *     }\n * }, new Eid(\"20150718:121521\"));\n * 
\n *\n * @param return type\n * @param supplier unsafe supplier code to be executed within a try-catch block\n * @param eid unique developer identifier from date for ex.: \"20150716:123200\"\n * @return A block of code return type, if exception is not thrown\n * @throws EidRuntimeException if code block thrown any exception, which in that case is wrapped in EidRuntimeException\n */\nEidPreconditions.tryToExecute = function(supplier, eid) {\n var checkedEid = ensureEid(eid);\n try {\n return EidPreconditions.checkNotNullable(supplier, checkedEid).apply();\n } catch (throwable) {\n throw new EidRuntimeException(checkedEid, throwable);\n }\n};\n\nmodule.exports = EidPreconditions;\n})(module);\n"],"sourceRoot":"/source/"}