class OptionsHelper {

  public static boolean objectToBoolean(Object optValue) throws OptionsException {
    throwOptionsExceptionIfConditionFails(nonNull(optValue), ".option value can not be NULL");
    if (optValue instanceof String) {
      String value = String.valueOf(optValue);
      if ("true".equalsIgnoreCase(value)) {
        return true;
      } else if ("false".equalsIgnoreCase(value)) {
        return false;
      } else {
        throwOptionsException("Invalid boolean type options value: %s. \nBoolean type options value is only 'true' or 'false' (case insensitive).", Objects.toString(optValue));
      }
    }

    if (optValue instanceof Boolean) {
      return (boolean) optValue;
    }
    throw new OptionsException("Invalid boolean type options value: " + Objects.toString(optValue));
  }

  private  OptionsHelper();

}