class MultiUserUtils {

  public static int getUserIdFromAmParameters(@NotNull String amFlags) {
    String userFlag = "--user";

    int i = amFlags.indexOf(userFlag);
    if ((i < 0)) {
      return PRIMARY_USERID;
    }

    i += userFlag.length() + 1; // go past --user
    if (i > amFlags.length()) {
      return PRIMARY_USERID;
    }

    amFlags = amFlags.substring(i).trim();
    try {
      return Integer.parseInt(amFlags);
    }
    catch (NumberFormatException e) {
      return PRIMARY_USERID;
    }
  }

}