Remove ConfigUtil getEnum methods that are available in JGit
ConfigUtil getEnum methods were duplicate of methods available in JGit Config. Change-Id: Icb86a42d8bb37b761f30b8bb0a38b57e8c7c59b4
This commit is contained in:
@@ -198,7 +198,7 @@ public class JettyServer {
|
||||
final URI[] listenUrls = listenURLs(cfg);
|
||||
final boolean reuseAddress = cfg.getBoolean("httpd", "reuseaddress", true);
|
||||
final int acceptors = cfg.getInt("httpd", "acceptorThreads", 2);
|
||||
final AuthType authType = ConfigUtil.getEnum(cfg, "auth", null, "type", AuthType.OPENID);
|
||||
final AuthType authType = cfg.getEnum("auth", null, "type", AuthType.OPENID);
|
||||
|
||||
reverseProxy = isReverseProxied(listenUrls);
|
||||
final Connector[] connectors = new Connector[listenUrls.length];
|
||||
|
||||
@@ -115,7 +115,7 @@ public class Section {
|
||||
public <T extends Enum<?>> T select(final String title, final String name,
|
||||
final T defValue, final boolean nullIfDefault) {
|
||||
final boolean set = get(name) != null;
|
||||
T oldValue = ConfigUtil.getEnum(flags.cfg, section, subsection, name, defValue);
|
||||
T oldValue = flags.cfg.getEnum(section, subsection, name, defValue);
|
||||
T newValue = ui.readEnum(oldValue, "%s", title);
|
||||
if (nullIfDefault && newValue == defValue) {
|
||||
newValue = null;
|
||||
|
||||
@@ -99,7 +99,7 @@ public class LdapRealm implements Realm {
|
||||
}
|
||||
|
||||
static SearchScope scope(final Config c, final String setting) {
|
||||
return ConfigUtil.getEnum(c, "ldap", null, setting, SearchScope.SUBTREE);
|
||||
return c.getEnum("ldap", null, setting, SearchScope.SUBTREE);
|
||||
}
|
||||
|
||||
static String optional(final Config config, final String name) {
|
||||
|
||||
@@ -111,7 +111,7 @@ public class AuthConfig {
|
||||
}
|
||||
|
||||
private static AuthType toType(final Config cfg) {
|
||||
return ConfigUtil.getEnum(cfg, "auth", null, "type", AuthType.OPENID);
|
||||
return cfg.getEnum("auth", null, "type", AuthType.OPENID);
|
||||
}
|
||||
|
||||
/** Type of user authentication used by this Gerrit server. */
|
||||
|
||||
@@ -26,24 +26,6 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class ConfigUtil {
|
||||
/**
|
||||
* Parse a Java enumeration from the configuration.
|
||||
*
|
||||
* @param <T> type of the enumeration object.
|
||||
* @param config the configuration file to read.
|
||||
* @param section section the key is in.
|
||||
* @param subsection subsection the key is in, or null if not in a subsection.
|
||||
* @param setting name of the setting to read.
|
||||
* @param defaultValue default value to return if the setting was not set.
|
||||
* Must not be null as the enumeration values are derived from this.
|
||||
* @return the selected enumeration value, or {@code defaultValue}.
|
||||
*/
|
||||
public static <T extends Enum<?>> T getEnum(final Config config,
|
||||
final String section, final String subsection, final String setting,
|
||||
final T defaultValue) {
|
||||
final T[] all = allValuesOf(defaultValue);
|
||||
return getEnum(config, section, subsection, setting, all, defaultValue);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <T> T[] allValuesOf(final T defaultValue) {
|
||||
@@ -62,31 +44,6 @@ public class ConfigUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a Java enumeration from the configuration.
|
||||
*
|
||||
* @param <T> type of the enumeration object.
|
||||
* @param config the configuration file to read.
|
||||
* @param section section the key is in.
|
||||
* @param subsection subsection the key is in, or null if not in a subsection.
|
||||
* @param setting name of the setting to read.
|
||||
* @param all all possible values in the enumeration which should be
|
||||
* recognized. This should be {@code EnumType.values()}.
|
||||
* @param defaultValue default value to return if the setting was not set.
|
||||
* This value may be null.
|
||||
* @return the selected enumeration value, or {@code defaultValue}.
|
||||
*/
|
||||
public static <T extends Enum<?>> T getEnum(final Config config,
|
||||
final String section, final String subsection, final String setting,
|
||||
final T[] all, final T defaultValue) {
|
||||
final String valueString = config.getString(section, subsection, setting);
|
||||
if (valueString == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
return getEnum(section, subsection, setting, valueString, all);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a Java enumeration from the configuration.
|
||||
*
|
||||
|
||||
@@ -506,8 +506,7 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
|
||||
NOTIFY, sectionName, KEY_TYPE,
|
||||
NotifyType.ALL));
|
||||
n.setTypes(types);
|
||||
n.setHeader(ConfigUtil.getEnum(rc,
|
||||
NOTIFY, sectionName, KEY_HEADER,
|
||||
n.setHeader(rc.getEnum(NOTIFY, sectionName, KEY_HEADER,
|
||||
NotifyConfig.Header.BCC));
|
||||
|
||||
for (String dst : rc.getStringList(NOTIFY, sectionName, KEY_EMAIL)) {
|
||||
|
||||
@@ -86,8 +86,7 @@ public class SmtpEmailSender implements EmailSender {
|
||||
}
|
||||
|
||||
smtpEncryption =
|
||||
ConfigUtil.getEnum(cfg, "sendemail", null, "smtpencryption",
|
||||
Encryption.NONE);
|
||||
cfg.getEnum("sendemail", null, "smtpencryption", Encryption.NONE);
|
||||
sslVerify = cfg.getBoolean("sendemail", null, "sslverify", true);
|
||||
|
||||
final int defaultPort;
|
||||
|
||||
Reference in New Issue
Block a user