- All Known Implementing Classes:
DefaultTypedConfigGetter
public interface TypedConfigGetter
Something that knows how to convert plain strings from a git
Config
to typed values.- Since:
- 4.9
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intUseInteger#MIN_VALUEas unset int value -
Method Summary
Modifier and TypeMethodDescriptionbooleangetBoolean(Config config, String section, String subsection, String name, boolean defaultValue) Deprecated.Get a boolean value from a gitConfig.<T extends Enum<?>>
TParse an enumeration from a gitConfig.intDeprecated.usegetInt(Config, String, String, String, Integer)insteadObtain an integer value from a gitConfig.intgetIntInRange(Config config, String section, String subsection, String name, int minValue, int maxValue, int defaultValue) Deprecated.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.longDeprecated.usegetLong(Config, String, String, String, Long)insteadObtain a long value from a gitConfig.default PathgetPath(Config config, String section, String subsection, String name, FS fs, File resolveAgainst, Path defaultValue) Parse a string value from a gitConfigand treat it as a file path, replacing a ~/ prefix by the user's home directory.getRefSpecs(Config config, String section, String subsection, String name) longgetTimeUnit(Config config, String section, String subsection, String name, long defaultValue, TimeUnit wantUnit) Deprecated.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.
-
Field Details
-
UNSET_INT
static final int UNSET_INTUseInteger#MIN_VALUEas unset int value- Since:
- 6.1
- See Also:
-
-
Method Details
-
getBoolean
@Deprecated boolean getBoolean(Config config, String section, String subsection, String name, boolean defaultValue) Deprecated.Get a boolean value from a gitConfig.- 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 Boolean getBoolean(Config config, String section, String subsection, String name, @Nullable Boolean defaultValue) Get a boolean value from a gitConfig.- 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
- Since:
- 7.2
-
getEnum
@Nullable <T extends Enum<?>> T getEnum(Config config, T[] all, String section, String subsection, String name, @Nullable T defaultValue) Parse an enumeration from a gitConfig.- 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
@Deprecated int getInt(Config config, String section, String subsection, String name, int defaultValue) Deprecated.usegetInt(Config, String, String, String, Integer)insteadObtain an integer value from a gitConfig.- 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 Integer getInt(Config config, String section, String subsection, String name, @Nullable Integer defaultValue) Obtain an integer value from a gitConfig.- 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.
- Since:
- 7.2
-
getIntInRange
@Deprecated int getIntInRange(Config config, String section, String subsection, String name, int minValue, int maxValue, int defaultValue) Deprecated.Obtain an integer value from a gitConfigwhich must be in given range.- 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. - Since:
- 6.1
-
getIntInRange
@Nullable Integer getIntInRange(Config config, String section, String subsection, String name, int minValue, int maxValue, @Nullable Integer defaultValue) Obtain an integer value from a gitConfigwhich must be in given range.- 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. - Since:
- 7.2
-
getLong
@Deprecated long getLong(Config config, String section, String subsection, String name, long defaultValue) Deprecated.usegetLong(Config, String, String, String, Long)insteadObtain a long value from a gitConfig.- 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 Long getLong(Config config, String section, String subsection, String name, @Nullable Long defaultValue) Obtain a long value from a gitConfig.- 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.
- Since:
- 7.2
-
getTimeUnit
@Deprecated long getTimeUnit(Config config, String section, String subsection, String name, long defaultValue, TimeUnit wantUnit) Deprecated.Parse a numerical time unit, such as "1 minute", from a gitConfig.- 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
@Nullable Long getTimeUnit(Config config, String section, String subsection, String name, @Nullable Long defaultValue, TimeUnit wantUnit) Parse a numerical time unit, such as "1 minute", from a gitConfig.- 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. - Since:
- 7.2
-
getPath
@Nullable default Path getPath(Config config, String section, String subsection, String name, @NonNull FS fs, File resolveAgainst, @Nullable Path defaultValue) Parse a string value from a gitConfigand treat it as a file path, replacing a ~/ prefix by the user's home directory.Note: this may throw
InvalidPathExceptionif the string is not a valid path.- Parameters:
config- to get the path from.section- section the key is in.subsection- subsection the key is in, or null if not in a subsection.name- the key name.fs- to use to convert the string into a path.resolveAgainst- directory to resolve the path against if it is a relative path.defaultValue- to return if no value was present- Returns:
- the
Path, ordefaultValueif not set - Since:
- 5.10
-
getRefSpecs
- 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
-
getBoolean(Config, String, String, String, Boolean)instead