You can use the constant ElasticHashinator.TOKEN_MASK Stefano added for this instead of having a magic number here. A static method on ElasticHashinator that takes a token and returns the int representation would be even better.