Source:
<code>public void postRun() throws Exception { AuthType authType = flags.cfg.getEnum(AuthType.values(), "auth", null, "type", null); <START> if (!AuthType.DEVELOPMENT_BECOME_ANY_ACCOUNT.equals(authType)) { <END> return; } ui.header("Gerrit Administrator"); ReviewDb db = dbFactory.open(); try { if (db.accounts().anyAccounts().toList().isEmpty() && ui.yesno(true, "Create administrator user")) { Account.Id id = new Account.Id(db.nextAccountId()); String username = ui.readString("admin", "username"); String name = ui.readString("Administrator", "name"); String email = readEmail(); String httpPassword = ui.readString("secret", "HTTP password"); AccountExternalId extUser = new AccountExternalId(id, new AccountExternalId.Key( AccountExternalId.SCHEME_USERNAME, username)); if (!Strings.isNullOrEmpty(httpPassword)) { extUser.setPassword(httpPassword); } db.accountExternalIds().insert(Collections.singleton(extUser)); if (email != null) { AccountExternalId extMailto = new AccountExternalId(id, new AccountExternalId.Key( AccountExternalId.SCHEME_MAILTO, email)); extMailto.setEmailAddress(email); db.accountExternalIds().insert(Collections.singleton(extMailto)); } Account a = new Account(id, TimeUtil.nowTs()); a.setFullName(name); a.setPreferredEmail(email); db.accounts().insert(Collections.singleton(a)); AccountGroupMember m = new AccountGroupMember(new AccountGroupMember.Key(id, new AccountGroup.Id(1))); db.accountGroupMembers().insert(Collections.singleton(m)); } } finally { db.close(); } }</code><technical_language>equality comparison of enum values worry order of parameters equals for NPE prevention [1]: if (authType == AuthType.DEVELOPMENT_BECOME_ANY_ACCOUNT) { [1] <LINK_0></technical_language>

Target:
public void postRun() throws Exception { AuthType authType = flags.cfg.getEnum(AuthType.values(), "auth", null, "type", null); if (authType != AuthType.DEVELOPMENT_BECOME_ANY_ACCOUNT) { return; } ui.header("Gerrit Administrator"); ReviewDb db = dbFactory.open(); try { if (db.accounts().anyAccounts().toList().isEmpty() && ui.yesno(true, "Create administrator user")) { Account.Id id = new Account.Id(db.nextAccountId()); String username = ui.readString("admin", "username"); String name = ui.readString("Administrator", "name"); String email = readEmail(); String httpPassword = ui.readString("secret", "HTTP password"); AccountExternalId extUser = new AccountExternalId(id, new AccountExternalId.Key( AccountExternalId.SCHEME_USERNAME, username)); if (!Strings.isNullOrEmpty(httpPassword)) { extUser.setPassword(httpPassword); } db.accountExternalIds().insert(Collections.singleton(extUser)); if (email != null) { AccountExternalId extMailto = new AccountExternalId(id, new AccountExternalId.Key( AccountExternalId.SCHEME_MAILTO, email)); extMailto.setEmailAddress(email); db.accountExternalIds().insert(Collections.singleton(extMailto)); } Account a = new Account(id, TimeUtil.nowTs()); a.setFullName(name); a.setPreferredEmail(email); db.accounts().insert(Collections.singleton(a)); AccountGroupMember m = new AccountGroupMember(new AccountGroupMember.Key(id, new AccountGroup.Id(1))); db.accountGroupMembers().insert(Collections.singleton(m)); } } finally { db.close(); } }