public class ConfigUtil
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static <T extends java.lang.Enum<?>> |
getEnum(org.eclipse.jgit.lib.Config config,
java.lang.String section,
java.lang.String subsection,
java.lang.String setting,
T defaultValue)
Parse a Java enumeration from the configuration.
|
static <T extends java.lang.Enum<?>> |
getEnum(org.eclipse.jgit.lib.Config config,
java.lang.String section,
java.lang.String subsection,
java.lang.String setting,
T[] all,
T defaultValue)
Parse a Java enumeration from the configuration.
|
static <T extends java.lang.Enum<?>> |
getEnumList(org.eclipse.jgit.lib.Config config,
java.lang.String section,
java.lang.String subsection,
java.lang.String setting,
T defaultValue)
Parse a Java enumeration list from the configuration.
|
static <T extends java.lang.Enum<?>> |
getEnumList(org.eclipse.jgit.lib.Config config,
java.lang.String section,
java.lang.String subsection,
java.lang.String setting,
T[] all,
T defaultValue)
Parse a Java enumeration list from the configuration.
|
static java.lang.String |
getRequired(org.eclipse.jgit.lib.Config cfg,
java.lang.String section,
java.lang.String name) |
static long |
getTimeUnit(org.eclipse.jgit.lib.Config config,
java.lang.String section,
java.lang.String subsection,
java.lang.String setting,
long defaultValue,
java.util.concurrent.TimeUnit wantUnit)
Parse a numerical time unit, such as "1 minute", from the configuration.
|
static long |
getTimeUnit(java.lang.String valueString,
long defaultValue,
java.util.concurrent.TimeUnit wantUnit)
Parse a numerical time unit, such as "1 minute", from a string.
|
public static <T extends java.lang.Enum<?>> T getEnum(org.eclipse.jgit.lib.Config config, java.lang.String section, java.lang.String subsection, java.lang.String setting, T defaultValue)
T
- type of the enumeration object.config
- the configuration file to read.section
- section the key is in.subsection
- subsection the key is in, or null if not in a subsection.setting
- name of the setting to read.defaultValue
- default value to return if the setting was not set.
Must not be null as the enumeration values are derived from this.defaultValue
.public static <T extends java.lang.Enum<?>> T getEnum(org.eclipse.jgit.lib.Config config, java.lang.String section, java.lang.String subsection, java.lang.String setting, T[] all, T defaultValue)
T
- type of the enumeration object.config
- the configuration file to read.section
- section the key is in.subsection
- subsection the key is in, or null if not in a subsection.setting
- name of the setting to read.all
- all possible values in the enumeration which should be
recognized. This should be EnumType.values()
.defaultValue
- default value to return if the setting was not set.
This value may be null.defaultValue
.public static <T extends java.lang.Enum<?>> java.util.List<T> getEnumList(org.eclipse.jgit.lib.Config config, java.lang.String section, java.lang.String subsection, java.lang.String setting, T defaultValue)
T
- type of the enumeration object.config
- the configuration file to read.section
- section the key is in.subsection
- subsection the key is in, or null if not in a subsection.setting
- name of the setting to read.defaultValue
- default value to return if the setting was not set.
Must not be null as the enumeration values are derived from this.defaultValue
.public static <T extends java.lang.Enum<?>> java.util.List<T> getEnumList(org.eclipse.jgit.lib.Config config, java.lang.String section, java.lang.String subsection, java.lang.String setting, T[] all, T defaultValue)
T
- type of the enumeration object.config
- the configuration file to read.section
- section the key is in.subsection
- subsection the key is in, or null if not in a subsection.setting
- name of the setting to read.all
- all possible values in the enumeration which should be
recognized. This should be EnumType.values()
.defaultValue
- default value to return if the setting was not set.
This value may be null.defaultValue
.public static long getTimeUnit(org.eclipse.jgit.lib.Config config, java.lang.String section, java.lang.String subsection, java.lang.String setting, long defaultValue, java.util.concurrent.TimeUnit wantUnit)
config
- the configuration file to read.section
- section the key is in.subsection
- subsection the key is in, or null if not in a subsection.setting
- name of the setting to read.defaultValue
- default value to return if no value was set in the
configuration file.wantUnit
- the units of defaultValue
and the return value, as
well as the units to assume if the value does not contain an
indication of the units.defaultValue
if not set, expressed in
units
.public static long getTimeUnit(java.lang.String valueString, long defaultValue, java.util.concurrent.TimeUnit wantUnit)
valueString
- the string to parse.defaultValue
- default value to return if no value was set in the
configuration file.wantUnit
- the units of defaultValue
and the return value, as
well as the units to assume if the value does not contain an
indication of the units.defaultValue
if not set, expressed in
units
.public static java.lang.String getRequired(org.eclipse.jgit.lib.Config cfg, java.lang.String section, java.lang.String name)