Releases: arcticicestudio/icecore-hashids
0.4.0
This version represents a large milestone which is a revise of the whole project to improve the clarity, performance and stability.
Detailed information about each new API feature- and change can be found in the project documentation.
Features
API
❯ The public- and internal APIs have been redesigned and rewritten from scratch regarding optimizations for Java 8, reduction of complexity and the new code style guide conventions.
❯ The new com.arcticicestudio.icecore.hashids.HashidsFeature
enum contains constants for various [features][docs-features] which can be enabled per instance through the Hashids.Builder
method features(HashidFeature) : Builder
.
❯ The public API now also provides the decodeOne(String) : Optional<Long>
method to simplify the use-case where the amount of resulting numbers is known before to handle the return value as single value instead of an array. This improves the prevention of an ArrayIndexOutOfBounceException
when users try to access an non-existent array index due to an failed encoding- or decoding.
Public API Breaking Changes
❯ The obsolete class com.arcticicestudio.icecore.hashids.Hashid
has been removed which was previously added to simplify the binding handling of the numbers and their hash value, but users should implement the simple POJO on their own instead of forcing them to use this approach.
The public API methods now returning the primitive values which have been hold by the Hashid
class. (#9 closed by PR #22, 6d5b21f)
❯ Due to the removement of the Hashid
class some public API methods have become unnecessary and have also been removed. (#9 closed by PR #22, 8e21e96)
decodeLongNumbers(String) : long[]
- The removedHashid
class has been used as a kind of container to store both the numbers and their associated hash values. This method allowed to directly receive theLong
numbers instead of theHashid
POJO which is now be provided by thedecode(String) : long[]
method.decodeIntegerNumbers(String) : int[]
- The algorithm is designed forLong
numbers. This method has been implemented to provide an easy conversion interface to use the library with integer IDs which should now be handled by the user.encodeToString(long...) : String
andencodeToString(int...) : String
- These methods are the counterparts for the decoding logic methods described above. Both have been removed for the same reason and the functionality is now available through theencode(String) : long[]
method.
❯ Removed all overloaded constructors due to the already provided interfaces through the Hashids.Builder
class. It provides methods for a accurate instance configuration while an instance with the default interoperable configurations is still available through the default constructor or by using default constructed builder instance. It allows a finer grained instance building since it doesn't depends on parameter ordering. The default constructor is still available for brevity and the functionality of all other removed constructors can now be achieved with the builder. (#9 closed by PR #22, 40231ad)
❯ The Hashids.Builder
method minHashLength(int) : Builder
has been renamed to minLength(int) : Builder
to adapt to the the builder methods naming style. (#9 closed by PR #22, 8617f4c)
❯ Separators are not customizable anymore since the curse word protection of the reference algorithm implementation does
not allow to modify the separators. The API provided methods to change those separators causing invalid and inconsistent hash- and numbers values. (#9 closed by PR #22, 1a08268)
Internal API Changes
❯ The private main logic methods doEncode(long...)
and doDecode(String, String)
have been removed and rewritten from scratch into the associated public API methods. (#9 closed by PR #22)
❯ The private method consistentShuffle(String, String) : String
has been rewritten from scratch and renamed to shuffle(char[], char[]) : char[]
. (#9 closed by PR #22, 8617f4c)
❯ The private methods hash(long, String)
and unhash(String, String)
have been rewritten from scratch and renamed to transform(long, char[], StringBuilder, int)
and transform(char[], char"])
. (#9 closed by PR #22, 8617f4c)
❯ The primary algorithm logic, which was mainly implemented in the private methods doEncode
and doDecode
, has been rewritten from scratch and modularized into the new methods deriveNewAlphabet(char[], char[], char) : char[]
and filterSeparators(char[], char[]) : char[]
. (#9 closed by PR #22, 8617f4c)
❯ The private support methods toArray(List<Long>) : long[]
and isEmpty(String) : boolean
have been removed. (#9 closed by PR #22, 8617f4c)
Documentation
❯ The new project documentation includes detailed information on how to [get started][docs-get-started], the new API overview and API guide and how to build the project and run the tests. (#11 closed by PR #23)
❯ Next to the project documentation the new GitHub Open Source community standards have been added to complete the project's community profile and adapt to the [Open Source Guides][open-source-guides] consisting of the Contributing Guidelines and the Code of Conduct. (#12 closed by PR #20)
❯ The new GitHub templates providing support for contributors to [create issues][issue-template] and [submitting pull requests][pr-template]. (#13 closed by PR #19)
❯ To improve the code review process the new GitHub code owner feature has been adapted. (#14 closed by PR #15)
Tests
All unit tests have been rewritten from scratch to match the new API and include as much use-cases as possible to increase the code coverage. The new interoperability tests run against the matching version of the reference implementation [hashids.js][hashids-js]. The script is loaded by using the [maven-frontend-plugin][maven-frontend-plugin] which installs [NodeJS][nodejs] locally and runs [NPM][npm] to install all dependencies defined in the package.json
. The parameterized InteropHashidsTest
class compares the results of both
algorithms to ensure interoperability. (#9 closed by PR #22, 8617f4c)
Detailed information about the functionality and how to run the unit- and interoperability tests can be found in the project documentation.
Improvements
❯ The POM has been refactored to
- update all plugin- and dependency versions
- remove the unnecessary comment documentation header
- fix the copyright year for generated JavaDoc
- add the
maven-enforcer-plugin
- remove unused profiles and configured core plugins
- remove unused test dependencies
The full changelog ist available here
0.3.0
Version Details
Release Date: 2017-07-17
Milestone
Project Board
Features
API
❯ Implemented a non-parameter constructor as an equivalent to the default Hashids.Builder
instance. The builder supports the creation of an Hashids instance without parameters for custom configurations, but there was no equivalent constructor for this case. (#1)
Improvements
API
Performance
Internal
❯ The private method consistentShuffle(String,String)
now uses char
arrays instead of String
operations. This removes five additional String
operations/methods and six String concatenations to three simple array assignments. (#7)
❯ Replaced toCharArray(int)
methods with charAt(int)
since Strings
are implemented as array internally so there is no need to convert to a char array.
❯ Adapted to SonarQube minor rule squid:S3400. (#5)
❯ Adapted to SonarQube minor rule squid:S3400 to improve the performance. (#6)
Documentation
❯ Adapted to a new project setup and documentation style. (#2)
Tests
❯ Slighly increased the code coverage by implementation unit tests for the Hashid
equals symmetric. (#8)
Bug Fixes
API
❯ Fixed a ArrayIndexOutOfBoundsException
when using a invalid decode salt.
JavaDoc
❯ Fixed JavaDoc lint compilation errors for self-closed tags. (#3)
The full changelog ist available here
0.2.0
Features
API
- Implemented public API Builder methods:
Class | Constructor | Description |
---|---|---|
com.arcticicestudio.icecore.hashids.Hashids |
+ getVersion(String):Builder |
Returns the ArcVer / SemVer version of the public API. |
Improvements
API
-
Now using
StringBuilder
class for non-constantString
attributes to avoid unnecessaryString
primitive-wrapping -
No more boxing of primitive for
String
conversion only
Make use of the static JDK method+ String.valueOf(char):String
to avoid waste of memory and cycles by not using a primitive-wrapper with concatenating empty string""
to a primitive.
This change fulfills the Eclipse SonarQube rulesquid:S2131
:Primitives should not be boxed just for
String
conversion -
Changed private methods without access to instance data to be
static
Clarifies that these methods will not modify the state of the object.
This change fulfills the Eclipse SonarQube rulesquid:S2325
:Private methods that don't access instance data should be static
-
Pre-compile regex
Pattern
pattern
Improves the performance (less memory and CPU cycles) by using pre-compiled regex pattern instead of creating instances for eachPattern
call.
The full changelog ist available here
0.1.0
Features
API
- Implemented public API classes:
Class | Description |
---|---|
com.arcticicestudio.icecore.hashids.Hashids |
Generates short, unique, non-sequential and decodable hashids from positive unsigned (long) integer numbers. Serves as the entry point to the "IceCore - JSON" public API. |
com.arcticicestudio.icecore.hashids.Hashids.Builder |
An immutable and reusable Hashids builder. Each method returns a new builder instance. |
com.arcticicestudio.icecore.hashids.Hashid |
Represents a hashid which holds all numbers and the encoded string. |
- Implemented public API constructors:
Class | Constructor | Description |
---|---|---|
com.arcticicestudio.icecore.hashids.Hashids |
+ Hashids(String) |
- |
com.arcticicestudio.icecore.hashids.Hashids |
+ Hashids(String,int) |
- |
com.arcticicestudio.icecore.hashids.Hashids |
+ Hashids(String,int,String) |
- |
com.arcticicestudio.icecore.hashids.Hashids |
+ Hashids(String,int,String,String) |
- |
- Implemented public API Builder constructors:
Class | Constructor | Description |
---|---|---|
com.arcticicestudio.icecore.hashids.Hashids.Builder |
+ Builder() |
- |
- Implemented public API Builder methods:
Class | Constructor | Description |
---|---|---|
com.arcticicestudio.icecore.hashids.Hashids.Builder |
+ salt(String):Builder |
- |
com.arcticicestudio.icecore.hashids.Hashids.Builder |
+ alphabet(String):Builder |
- |
com.arcticicestudio.icecore.hashids.Hashids.Builder |
+ minHashLength(int):Builder |
- |
com.arcticicestudio.icecore.hashids.Hashids.Builder |
+ build(int):Hashids |
- |
- Implemented public API methods:
Class | Method | Description |
---|---|---|
com.arcticicestudio.icecore.hashids.Hashids |
+ encode(long...):Hashid |
Encode number(s). |
com.arcticicestudio.icecore.hashids.Hashids |
+ encodeToString(long...):String |
Encode number(s) to string. |
com.arcticicestudio.icecore.hashids.Hashids |
+ encodeToString(int...):String |
Encode number(s) to string. |
com.arcticicestudio.icecore.hashids.Hashids |
+ encodeHex(String):String |
Encode an hexadecimal string to string. |
com.arcticicestudio.icecore.hashids.Hashids |
+ decode(String):Hashid |
Decode an encoded string. |
com.arcticicestudio.icecore.hashids.Hashids |
+ decodeLongNumbers(String):long[] |
Decode an encoded string to long numbers. |
com.arcticicestudio.icecore.hashids.Hashids |
+ decodeIntegerNumbers(String):int[] |
Decode an encoded string to integer numbers. |
com.arcticicestudio.icecore.hashids.Hashids |
+ decodeHex(String):String |
Decode an string to hexadecimal numbers. |
- Implemented public API static constants:
Class | Constructor | Value | Description |
---|---|---|---|
com.arcticicestudio.icecore.hashids.Hashids |
+ DEFAULT_ALPHABET:String |
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 |
Holds the default alphabet. |
com.arcticicestudio.icecore.hashids.Hashids |
+ DEFAULT_SEPARATORS:String |
´cfhistuCFHISTU |
Holds the default separators. Used to prevent the generation of strings that contain bad, offensive or rude words. |
com.arcticicestudio.icecore.hashids.Hashids |
+ MAX_NUMBER_VALUE:long |
9_007_199_254_740_992L - 1 |
Holds the maximum number value. This limit is mandatory in order to ensure interoperability. |
Documentation
- Added a usage guide for the API.
This includes all currently implemented public API methods and general notes to the library algorithm.
Tests
- Implemented public API test classes:
Class | Description |
---|---|
com.arcticicestudio.icecore.hashids.HashidsTest |
Tests the "IceCore - Hashids" public API class Hashids . |
The full changelog ist available here