public class ConfigUtil extends Object
Modifier and Type | Method and Description |
---|---|
static <T extends Enum<?>> |
getEnumList(org.eclipse.jgit.lib.Config config,
String section,
String subsection,
String setting,
T defaultValue)
Parse a Java enumeration list from the configuration.
|
static <T extends Enum<?>> |
getEnumList(org.eclipse.jgit.lib.Config config,
String section,
String subsection,
String setting,
T[] all,
T defaultValue)
Parse a Java enumeration list from the configuration.
|
static String |
getRequired(org.eclipse.jgit.lib.Config cfg,
String section,
String name) |
static long |
getTimeUnit(org.eclipse.jgit.lib.Config config,
String section,
String subsection,
String setting,
long defaultValue,
TimeUnit wantUnit)
Parse a numerical time unit, such as "1 minute", from the configuration.
|
static long |
getTimeUnit(String valueString,
long defaultValue,
TimeUnit wantUnit)
Parse a numerical time unit, such as "1 minute", from a string.
|
static <T> T |
loadSection(org.eclipse.jgit.lib.Config cfg,
String section,
String sub,
T s,
T defaults,
T i)
Load section by inspecting Java class attributes.
|
static boolean |
skipField(Field field) |
static <T> void |
storeSection(org.eclipse.jgit.lib.Config cfg,
String section,
String sub,
T s,
T defaults)
Store section by inspecting Java class attributes.
|
public static <T extends Enum<?>> List<T> getEnumList(org.eclipse.jgit.lib.Config config, String section, String subsection, 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 Enum<?>> List<T> getEnumList(org.eclipse.jgit.lib.Config config, String section, String subsection, 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, String section, String subsection, String setting, long defaultValue, 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(String valueString, long defaultValue, 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 String getRequired(org.eclipse.jgit.lib.Config cfg, String section, String name)
public static <T> void storeSection(org.eclipse.jgit.lib.Config cfg, String section, String sub, T s, T defaults) throws org.eclipse.jgit.errors.ConfigInvalidException
Optimize the storage by unsetting a variable if it is being set to default value by the server.
Fields marked with final or transient modifiers are skipped.
cfg
- config in which the values should be storedsection
- sectionsub
- subsections
- instance of class with config valuesdefaults
- instance of class with default valuesorg.eclipse.jgit.errors.ConfigInvalidException
public static <T> T loadSection(org.eclipse.jgit.lib.Config cfg, String section, String sub, T s, T defaults, T i) throws org.eclipse.jgit.errors.ConfigInvalidException
Config values are stored optimized: no default values are stored. The loading is performed eagerly: all values are set.
Fields marked with final or transient modifiers are skipped.
cfg
- config from which the values are loadedsection
- sectionsub
- subsections
- instance of class in which the values are setdefaults
- instance of class with default valuesi
- instance to merge during the load. When present, the boolean fields are not nullified
when their values are falseorg.eclipse.jgit.errors.ConfigInvalidException
public static boolean skipField(Field field)