title: Computed hashcode to lie within a particular range of values?
body: <p>I have a function which looks like this:</p>
  
  <pre><code>public int getHashcode(int shardCount){
  
      String personid = "&lt;some long string value&gt;";
      String servicedate = "2019-12-22T01:31:30.000Z";
      HashCodeBuilder hashCodeBuilder = new HashCodeBuilder();
      return hashCodeBuilder.append(personid).append(servicedate).toHashCode() % shardCount;
  
  //the shard count key comes in from a config file and has various values
  // like 2,5,15,25 etc depending on some criteria
  }
  </code></pre>
  
  <p>Now, the requirement is that I want this method to return the hashcode such that it falls in the range of 0-10 and should not exceed 10. Simplest way according to me, is adding a conditional check before returning the value and then return a random value as per my wish, but is that an optimal solution to this, or should I put a fixed "shardCount" value to achieve the result?</p>