java.lang.Object
org.eclipse.jgit.lib.DefaultTypedConfigGetter
- All Implemented Interfaces:
TypedConfigGetter
An
TypedConfigGetter that throws
IllegalArgumentException on invalid values.- Since:
- 4.9
-
Field Summary
Fields inherited from interface org.eclipse.jgit.lib.TypedConfigGetter
UNSET_INT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleangetBoolean(Config config, String section, String subsection, String name, boolean defaultValue) Get a boolean value from a gitConfig.Get a boolean value from a gitConfig.<T extends Enum<?>>
TParse an enumeration from a gitConfig.intObtain an integer value from a gitConfig.Obtain an integer value from a gitConfig.intgetIntInRange(Config config, String section, String subsection, String name, int minValue, int maxValue, int defaultValue) Obtain an integer value from a gitConfigwhich must be in given range.getIntInRange(Config config, String section, String subsection, String name, int minValue, int maxValue, Integer defaultValue) Obtain an integer value from a gitConfigwhich must be in given range.longObtain a long value from a gitConfig.Obtain a long value from a gitConfig.getRefSpecs(Config config, String section, String subsection, String name) longgetTimeUnit(Config config, String section, String subsection, String name, long defaultValue, TimeUnit wantUnit) Parse a numerical time unit, such as "1 minute", from a gitConfig.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, waitMethods inherited from interface org.eclipse.jgit.lib.TypedConfigGetter
getPath
-
Constructor Details
-
DefaultTypedConfigGetter
public DefaultTypedConfigGetter()
-
-
Method Details
-
getBoolean
public boolean getBoolean(Config config, String section, String subsection, String name, boolean defaultValue) Description copied from interface:TypedConfigGetterGet a boolean value from a gitConfig.- Specified by:
getBooleanin 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
-
getBoolean
@Nullable public Boolean getBoolean(Config config, String section, String subsection, String name, @Nullable Boolean defaultValue) Description copied from interface:TypedConfigGetterGet a boolean value from a gitConfig.- Specified by:
getBooleanin 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
@Nullable public <T extends Enum<?>> T getEnum(Config config, T[] all, String section, String subsection, String name, @Nullable T defaultValue) Description copied from interface:TypedConfigGetterParse an enumeration from a gitConfig.- Specified by:
getEnumin interfaceTypedConfigGetter- Type Parameters:
T- type of the enum- 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
Description copied from interface:TypedConfigGetterObtain an integer value from a gitConfig.- Specified by:
getIntin 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.
-
getInt
@Nullable public Integer getInt(Config config, String section, String subsection, String name, @Nullable Integer defaultValue) Description copied from interface:TypedConfigGetterObtain an integer value from a gitConfig.- Specified by:
getIntin 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) Description copied from interface:TypedConfigGetterObtain an integer value from a gitConfigwhich must be in given range.- Specified by:
getIntInRangein 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_INTto set the default to unset.- Returns:
- an integer value from the configuration, or defaultValue.
#UNSET_INTif unset.
-
getIntInRange
public Integer getIntInRange(Config config, String section, String subsection, String name, int minValue, int maxValue, Integer defaultValue) Description copied from interface:TypedConfigGetterObtain an integer value from a gitConfigwhich must be in given range.- Specified by:
getIntInRangein 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_INTto set the default to unset.- Returns:
- an integer value from the configuration, or defaultValue.
#UNSET_INTif unset.
-
getLong
public long getLong(Config config, String section, String subsection, String name, long defaultValue) Description copied from interface:TypedConfigGetterObtain a long value from a gitConfig.- Specified by:
getLongin 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.
-
getLong
@Nullable public Long getLong(Config config, String section, String subsection, String name, @Nullable Long defaultValue) Description copied from interface:TypedConfigGetterObtain a long value from a gitConfig.- Specified by:
getLongin 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) Description copied from interface:TypedConfigGetterParse a numerical time unit, such as "1 minute", from a gitConfig.- Specified by:
getTimeUnitin 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 ofdefaultValueand 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
defaultValueif not set, expressed inunits.
-
getTimeUnit
public Long getTimeUnit(Config config, String section, String subsection, String name, @Nullable Long defaultValue, TimeUnit wantUnit) Description copied from interface:TypedConfigGetterParse a numerical time unit, such as "1 minute", from a gitConfig.- Specified by:
getTimeUnitin 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 ofdefaultValueand 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
defaultValueif not set, expressed inunits.
-
getRefSpecs
@NonNull public List<RefSpec> getRefSpecs(Config config, String section, String subsection, String name) Description copied from interface:TypedConfigGetter- Specified by:
getRefSpecsin 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
RefSpecs
-