{"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","random","nextInt","max","min","floor","StdUniqIdGenerator","BASE36","INTEGER_MAX_VALUE","generator","first","abs","second","calc","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","name","commonExConstructor","apply","EidNullPointerException","EidIllegalArgumentException","EidIllegalStateException","EidIndexOutOfBoundsException","prototype","./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,EAAAC,GAAA,IAAAJ,EAAAG,GAAA,CAAA,IAAAJ,EAAAI,GAAA,CAAA,GAAAE,GAAA,kBAAAC,UAAAA,OAAA,KAAAF,GAAAC,EAAA,MAAAA,GAAAF,GAAA,EA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AAC,GACA,KAAA,IAAAZ,GAAAe,EAAA3E,EAEA,OAAAuE,IAyBAP,EAAAiB,aAAA,SAAAC,EAAA7B,GACA,GAAAsB,GAAAP,EAAAf,EACA,KACA,MAAAW,GAAAU,iBAAAQ,EAAAP,GAAAnB,QACA,MAAA2B,GACA,KAAA,IAAA/B,GAAAuB,EAAAQ,KAIAtH,EAAAJ,QAAAuG,GACAnG,KJ+bGiG,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 random(LONG_MIN, LONG_MAX);\n };\n this.nextInt = function(max) {\n return random(0, max);\n };\n var random = 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 generator = new MathRandom();\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 return (Math.abs(calc) % INTEGER_MAX_VALUE).toString(BASE36);\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 var commonExConstructor = function(eid, message) {\n if (!(eid instanceof Eid)) {\n eid = new Eid(eid.toString());\n }\n this.message = message !== undefined ? (eid + \" \" + message) : eid;\n this.eid = eid;\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 this.name = 'EidRuntimeException';\n commonExConstructor.apply(this, [eid, message]);\n }\n EidRuntimeException.prototype = new Error();\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 this.name = 'EidNullPointerException';\n commonExConstructor.apply(this, [eid, message]);\n }\n EidNullPointerException.prototype = EidRuntimeException.prototype;\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 this.name = 'EidIllegalArgumentException';\n commonExConstructor.apply(this, [eid, message]);\n }\n EidIllegalArgumentException.prototype = EidRuntimeException.prototype;\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 this.name = 'EidIllegalStateException';\n commonExConstructor.apply(this, [eid, message]);\n }\n EidIllegalStateException.prototype = EidRuntimeException.prototype;\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 this.name = 'EidIndexOutOfBoundsException';\n commonExConstructor.apply(this, [eid, message]);\n }\n EidIndexOutOfBoundsException.prototype = EidRuntimeException.prototype;\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 random(LONG_MIN, LONG_MAX);\n };\n this.nextInt = function(max) {\n return random(0, max);\n };\n var random = 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 generator = new MathRandom();\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 return (Math.abs(calc) % INTEGER_MAX_VALUE).toString(BASE36);\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 var commonExConstructor = function(eid, message) {\n if (!(eid instanceof Eid)) {\n eid = new Eid(eid.toString());\n }\n this.message = message !== undefined ? (eid + \" \" + message) : eid;\n this.eid = eid;\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 this.name = 'EidRuntimeException';\n commonExConstructor.apply(this, [eid, message]);\n }\n EidRuntimeException.prototype = new Error();\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 this.name = 'EidNullPointerException';\n commonExConstructor.apply(this, [eid, message]);\n }\n EidNullPointerException.prototype = EidRuntimeException.prototype;\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 this.name = 'EidIllegalArgumentException';\n commonExConstructor.apply(this, [eid, message]);\n }\n EidIllegalArgumentException.prototype = EidRuntimeException.prototype;\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 this.name = 'EidIllegalStateException';\n commonExConstructor.apply(this, [eid, message]);\n }\n EidIllegalStateException.prototype = EidRuntimeException.prototype;\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 this.name = 'EidIndexOutOfBoundsException';\n commonExConstructor.apply(this, [eid, message]);\n }\n EidIndexOutOfBoundsException.prototype = EidRuntimeException.prototype;\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/"}