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 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, 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 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 and submitting pull requests. (#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. The script is loaded by using the maven-frontend-plugin which installs NodeJS locally and runs 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