Package com.github.ambry.config
Class VerifiableProperties
- java.lang.Object
-
- com.github.ambry.config.VerifiableProperties
-
public class VerifiableProperties extends java.lang.Object
Verifiable properties for configs
-
-
Constructor Summary
Constructors Constructor Description VerifiableProperties(java.util.Properties props)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsKey(java.lang.String name)
boolean
getBoolean(java.lang.String name)
boolean
getBoolean(java.lang.String name, boolean defaultVal)
Read a boolean value from the properties instancedouble
getDouble(java.lang.String name)
Get a required argument as a doubledouble
getDouble(java.lang.String name, double defaultVal)
Get an optional argument as a doublejava.lang.Double
getDoubleInRange(java.lang.String name, java.lang.Double defaultVal, java.lang.Double start, java.lang.Double end)
<E extends java.lang.Enum<E>>
EgetEnum(java.lang.String name, java.lang.Class<E> type, E defaultVal)
int
getInt(java.lang.String name)
Read a required integer property value or throw an exception if no such property is foundint
getInt(java.lang.String name, int defaultVal)
Read an integer from the properties instancejava.lang.Integer
getInteger(java.lang.String name, java.lang.Integer defaultVal)
int
getIntInRange(java.lang.String name, int start, int end)
int
getIntInRange(java.lang.String name, int defaultVal, int start, int end)
Read an integer from the properties instance.long
getLong(java.lang.String name)
Read a required long property value or throw an exception if no such property is foundlong
getLong(java.lang.String name, long defaultVal)
Read an long from the properties instancelong
getLongInRange(java.lang.String name, long defaultVal, long start, long end)
Read an long from the properties instance.java.lang.String
getProperty(java.lang.String name)
java.lang.Short
getShort(java.lang.String name, java.lang.Short defaultVal)
java.lang.Short
getShortFromAllowedValues(java.lang.String name, java.lang.Short defaultVal, java.lang.Short[] allowedValues)
Read a short from the properties instance.java.lang.Short
getShortInRange(java.lang.String name, java.lang.Short defaultVal, java.lang.Short start, java.lang.Short end)
java.lang.String
getString(java.lang.String name)
Get a string property or throw and exception if no such property is defined.java.lang.String
getString(java.lang.String name, java.lang.String defaultVal)
Get a string property, or, if no such property is defined, return the given default valuejava.lang.String
toString()
void
verify()
-
-
-
Method Detail
-
containsKey
public boolean containsKey(java.lang.String name)
-
getProperty
public java.lang.String getProperty(java.lang.String name)
-
getInt
public int getInt(java.lang.String name)
Read a required integer property value or throw an exception if no such property is found
-
getIntInRange
public int getIntInRange(java.lang.String name, int start, int end)
-
getInt
public int getInt(java.lang.String name, int defaultVal)
Read an integer from the properties instance- Parameters:
name
- The property namedefaultVal
- The default value to use if the property is not found- Returns:
- the integer value
-
getInteger
public java.lang.Integer getInteger(java.lang.String name, java.lang.Integer defaultVal)
-
getShort
public java.lang.Short getShort(java.lang.String name, java.lang.Short defaultVal)
-
getIntInRange
public int getIntInRange(java.lang.String name, int defaultVal, int start, int end)
Read an integer from the properties instance. Throw an exception if the value is not in the given range (inclusive)- Parameters:
name
- The property namedefaultVal
- The default value to use if the property is not foundstart
- The start of the range in which the value must fall (inclusive)end
- The end of the range in which the value must fall- Returns:
- the integer value
- Throws:
java.lang.IllegalArgumentException
- If the value is not in the given range
-
getShortInRange
public java.lang.Short getShortInRange(java.lang.String name, java.lang.Short defaultVal, java.lang.Short start, java.lang.Short end)
-
getShortFromAllowedValues
public java.lang.Short getShortFromAllowedValues(java.lang.String name, java.lang.Short defaultVal, java.lang.Short[] allowedValues)
Read a short from the properties instance. Throw an exception if the value is not among the allowed values- Parameters:
name
- The property namedefaultVal
- The default value to use if the property is not foundallowedValues
- The array of allowed values for this property.- Returns:
- the Short value
-
getDoubleInRange
public java.lang.Double getDoubleInRange(java.lang.String name, java.lang.Double defaultVal, java.lang.Double start, java.lang.Double end)
-
getLong
public long getLong(java.lang.String name)
Read a required long property value or throw an exception if no such property is found
-
getLong
public long getLong(java.lang.String name, long defaultVal)
Read an long from the properties instance- Parameters:
name
- The property namedefaultVal
- The default value to use if the property is not found- Returns:
- the long value
-
getLongInRange
public long getLongInRange(java.lang.String name, long defaultVal, long start, long end)
Read an long from the properties instance. Throw an exception if the value is not in the given range (inclusive)- Parameters:
name
- The property namedefaultVal
- The default value to use if the property is not foundstart
- The start of the range in which the value must fall (inclusive)end
- The end of the range in which the value must fall- Returns:
- the long value
- Throws:
java.lang.IllegalArgumentException
- If the value is not in the given range
-
getDouble
public double getDouble(java.lang.String name)
Get a required argument as a double- Parameters:
name
- The property name- Returns:
- the value
-
getDouble
public double getDouble(java.lang.String name, double defaultVal)
Get an optional argument as a double- Parameters:
name
- The property name
-
getBoolean
public boolean getBoolean(java.lang.String name, boolean defaultVal)
Read a boolean value from the properties instance- Parameters:
name
- The property namedefaultVal
- The default value to use if the property is not found- Returns:
- the boolean value
-
getBoolean
public boolean getBoolean(java.lang.String name)
-
getEnum
public <E extends java.lang.Enum<E>> E getEnum(java.lang.String name, java.lang.Class<E> type, E defaultVal)
- Parameters:
name
- The property name.type
- The type of enum to parse.defaultVal
- The default value to use if the property is not found.- Returns:
- The enum value.
-
getString
public java.lang.String getString(java.lang.String name, java.lang.String defaultVal)
Get a string property, or, if no such property is defined, return the given default value
-
getString
public java.lang.String getString(java.lang.String name)
Get a string property or throw and exception if no such property is defined.
-
verify
public void verify()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-