Package org.eclipse.jgit.lib
Class DefaultTypedConfigGetter
- java.lang.Object
-
- org.eclipse.jgit.lib.DefaultTypedConfigGetter
-
- All Implemented Interfaces:
TypedConfigGetter
public class DefaultTypedConfigGetter extends Object implements TypedConfigGetter
AnTypedConfigGetter
that throwsIllegalArgumentException
on invalid values.- Since:
- 4.9
-
-
Field Summary
-
Fields inherited from interface org.eclipse.jgit.lib.TypedConfigGetter
UNSET_INT
-
-
Constructor Summary
Constructors Constructor Description DefaultTypedConfigGetter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
getBoolean(Config config, String section, String subsection, String name, boolean defaultValue)
Get a boolean value from a gitConfig
.<T extends Enum<?>>
TgetEnum(Config config, T[] all, String section, String subsection, String name, T defaultValue)
Parse an enumeration from a gitConfig
.int
getInt(Config config, String section, String subsection, String name, int defaultValue)
Obtain an integer value from a gitConfig
.int
getIntInRange(Config config, String section, String subsection, String name, int minValue, int maxValue, int defaultValue)
Obtain an integer value from a gitConfig
which must be in given range.long
getLong(Config config, String section, String subsection, String name, long defaultValue)
Obtain a long value from a gitConfig
.List<RefSpec>
getRefSpecs(Config config, String section, String subsection, String name)
long
getTimeUnit(Config config, String section, String subsection, String name, long defaultValue, TimeUnit wantUnit)
Parse a numerical time unit, such as "1 minute", from a gitConfig
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.jgit.lib.TypedConfigGetter
getPath
-
-
-
-
Method Detail
-
getBoolean
public boolean getBoolean(Config config, String section, String subsection, String name, boolean defaultValue)
Get a boolean value from a gitConfig
.- Specified by:
getBoolean
in interfaceTypedConfigGetter
- Parameters:
config
- to get the value fromsection
- section the key is grouped within.subsection
- subsection name, such a remote or branch name.name
- name of the key to get.defaultValue
- default value to return if no value was present.- Returns:
- true if any value or defaultValue is true, false for missing or explicit false
-
getEnum
public <T extends Enum<?>> T getEnum(Config config, T[] all, String section, String subsection, String name, T defaultValue)
Parse an enumeration from a gitConfig
.- Specified by:
getEnum
in interfaceTypedConfigGetter
- Parameters:
config
- to get the value fromall
- all possible values in the enumeration which should be recognized. TypicallyEnumType.values()
.section
- section the key is grouped within.subsection
- subsection name, such a remote or branch name.name
- name of the key to get.defaultValue
- default value to return if no value was present.- Returns:
- the selected enumeration value, or
defaultValue
.
-
getInt
public int getInt(Config config, String section, String subsection, String name, int defaultValue)
Obtain an integer value from a gitConfig
.- Specified by:
getInt
in interfaceTypedConfigGetter
- Parameters:
config
- to get the value fromsection
- section the key is grouped within.subsection
- subsection name, such a remote or branch name.name
- name of the key to get.defaultValue
- default value to return if no value was present.- Returns:
- an integer value from the configuration, or defaultValue.
-
getIntInRange
public int getIntInRange(Config config, String section, String subsection, String name, int minValue, int maxValue, int defaultValue)
Obtain an integer value from a gitConfig
which must be in given range.- Specified by:
getIntInRange
in interfaceTypedConfigGetter
- Parameters:
config
- to get the value fromsection
- section the key is grouped within.subsection
- subsection name, such a remote or branch name.name
- name of the key to get.minValue
- minimal valuemaxValue
- maximum valuedefaultValue
- default value to return if no value was present. Use#UNSET_INT
to set the default to unset.- Returns:
- an integer value from the configuration, or defaultValue.
#UNSET_INT
if unset.
-
getLong
public long getLong(Config config, String section, String subsection, String name, long defaultValue)
Obtain a long value from a gitConfig
.- Specified by:
getLong
in interfaceTypedConfigGetter
- Parameters:
config
- to get the value fromsection
- section the key is grouped within.subsection
- subsection name, such a remote or branch name.name
- name of the key to get.defaultValue
- default value to return if no value was present.- Returns:
- a long value from the configuration, or defaultValue.
-
getTimeUnit
public long getTimeUnit(Config config, String section, String subsection, String name, long defaultValue, TimeUnit wantUnit)
Parse a numerical time unit, such as "1 minute", from a gitConfig
.- Specified by:
getTimeUnit
in interfaceTypedConfigGetter
- Parameters:
config
- to get the value fromsection
- section the key is in.subsection
- subsection the key is in, or null if not in a subsection.name
- the key name.defaultValue
- default value to return if no value was present.wantUnit
- the units ofdefaultValue
and the return value, as well as the units to assume if the value does not contain an indication of the units.- Returns:
- the value, or
defaultValue
if not set, expressed inunits
.
-
getRefSpecs
@NonNull public List<RefSpec> getRefSpecs(Config config, String section, String subsection, String name)
- Specified by:
getRefSpecs
in interfaceTypedConfigGetter
- Parameters:
config
- to get the list fromsection
- section the key is in.subsection
- subsection the key is in, or null if not in a subsection.name
- the key name.- Returns:
- a possibly empty list of
RefSpec
s
-
-