@Override
  public boolean isActive(FeatureState state, FeatureUser user) {

    if (user != null && Strings.isNotBlank(user.getName())) {

      String percentageAsString = state.getParameter(PARAM_PERCENTAGE);
      try {

        int percentage = Integer.valueOf(percentageAsString);

        if (percentage > 0) {
          int hashCode = Math.abs(calculateHashCode(user, state.getFeature()));
          return (hashCode % 100) < percentage;
        }

      } catch (NumberFormatException e) {
        log.error(
            "Invalid gradual rollout percentage for feature "
                + state.getFeature().name()
                + ": "
                + percentageAsString);
      }
    }

    return false;
  }
  protected int calculateHashCode(FeatureUser user, Feature feature) {

    Validate.notNull(user, "user is required");

    return new StringBuilder()
        .append(user.getName().toLowerCase(Locale.ENGLISH).trim())
        .append(":")
        .append(feature != null ? feature.name() : "")
        .toString()
        .hashCode();
  }