Package com.authlete.common.util
Class TypedProperties
- java.lang.Object
-
- com.authlete.common.util.TypedProperties
-
- Direct Known Subclasses:
StringBasedTypedProperties
public abstract class TypedProperties extends Object
This is an abstract class that provides getters and setters for key-value pairs. Subclasses are required to implement the following abstract methods.void
clear()
boolean
contains(String key)
boolean
getBoolean(String key, boolean defaultValue)
float
getFloat(String key, float defaultValue)
int
getInt(String key, int defaultValue)
long
getLong(String key, long defaultValue)
String
getString(String key, String defaultValue)
void
remove(String key)
void
setBoolean(String key, boolean value)
void
setFloat(String key, float value)
void
setInt(String key, int value)
void
setLong(String key, long value)
void
setString(String key, String value)
All non-abstract methods in this class are just wrappers over the abstract methods listed above.
- Author:
- Takahiko Kawasaki
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
TypedProperties()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
clear()
Clear all properties.boolean
contains(Enum<?> key)
Equivalent tocontains
(key.name())
.abstract boolean
contains(String key)
Check if the property identified by the key exists.String
get(Enum<?> key)
Equivalent togetString
(key)
.boolean
get(Enum<?> key, boolean defaultValue)
Equivalent togetBoolean
(key, defaultValue)
.float
get(Enum<?> key, float defaultValue)
Equivalent togetFloat
(key, defaultValue)
.int
get(Enum<?> key, int defaultValue)
Equivalent togetInt
(key, defaultValue)
.long
get(Enum<?> key, long defaultValue)
Equivalent togetLong
(key, defaultValue)
.<TEnum extends Enum<TEnum>>
TEnumget(Enum<?> key, Class<TEnum> enumClass, TEnum defaultValue)
Equivalent togetEnum
(key, enumClass, defaultValue)
.String
get(Enum<?> key, String defaultValue)
Equivalent togetString
(key, defaultValue)
.<TEnum extends Enum<TEnum>>
TEnumget(Enum<?> key, TEnum defaultValue)
Equivalent togetEnum
(key, (Class<TEnum>)defaultValue.getClass(), defaultValue)
.String
get(String key)
Equivalent togetString
(key)
.boolean
get(String key, boolean defaultValue)
Equivalent togetBoolean
(key, defaultValue)
.float
get(String key, float defaultValue)
Equivalent togetFloat
(key, defaultValue)
.int
get(String key, int defaultValue)
Equivalent togetInt
(key, defaultValue)
.long
get(String key, long defaultValue)
Equivalent togetLong
(key, defaultValue)
.<TEnum extends Enum<TEnum>>
TEnumget(String key, Class<TEnum> enumClass, TEnum defaultValue)
Equivalent togetEnum
(key, enumClass, defaultValue)
.String
get(String key, String defaultValue)
Equivalent togetString
(key, defaultValue)
.<TEnum extends Enum<TEnum>>
TEnumget(String key, TEnum defaultValue)
Equivalent togetEnum
(key, (Class<TEnum>)defaultValue.getClass(), defaultValue)
.boolean
getBoolean(Enum<?> key)
Equivalent togetBoolean
(key.name())
.boolean
getBoolean(Enum<?> key, boolean defaultValue)
Equivalent togetBoolean
(key.name(), defaultValue)
.boolean
getBoolean(String key)
Equivalent togetBoolean
(key, false)
.abstract boolean
getBoolean(String key, boolean defaultValue)
Get the value of the property identified by the key as boolean.<TEnum extends Enum<TEnum>>
TEnumgetEnum(Enum<?> key, Class<TEnum> enumClass)
Equivalent togetEnum
(key.name(), enumClass)
.<TEnum extends Enum<TEnum>>
TEnumgetEnum(Enum<?> key, Class<TEnum> enumClass, TEnum defaultValue)
Equivalent togetEnum
(key.name(), enumClass, defaultValue)
.<TEnum extends Enum<TEnum>>
TEnumgetEnum(Enum<?> key, TEnum defaultValue)
Equivalent togetEnum
(key, (Class<TEnum>)defaultValue.getClass(), defaultValue)
.<TEnum extends Enum<TEnum>>
TEnumgetEnum(String key, Class<TEnum> enumClass)
Equivalent togetEnum
(key, enumClass, null)
.<TEnum extends Enum<TEnum>>
TEnumgetEnum(String key, Class<TEnum> enumClass, TEnum defaultValue)
Get the value of the property identified by the key as Enum.<TEnum extends Enum<TEnum>>
TEnumgetEnum(String key, TEnum defaultValue)
Equivalent togetEnum
(key, (Class<TEnum>)defaultValue.getClass(), defaultValue)
.float
getFloat(Enum<?> key)
Equivalent togetFloat
(key.name())
.float
getFloat(Enum<?> key, float defaultValue)
Equivalent togetFloat
(key.name(), defaultValue)
.float
getFloat(String key)
Equivalent togetFloat
(key, 0.0F)
.abstract float
getFloat(String key, float defaultValue)
Get the value of the property identified by the key as float.int
getInt(Enum<?> key)
Equivalent togetInt
(key.name())
.int
getInt(Enum<?> key, int defaultValue)
Equivalent togetInt
(key.name(), defaultValue)
.int
getInt(String key)
Equivalent togetInt
(key, 0)
.abstract int
getInt(String key, int defaultValue)
Get the value of the property identified by the key as int.long
getLong(Enum<?> key)
Equivalent togetLong
(key.name())
.long
getLong(Enum<?> key, long defaultValue)
Equivalent togetLong
(key.name(), defaultValue)
.long
getLong(String key)
Equivalent togetLong
(key, 0L)
.abstract long
getLong(String key, long defaultValue)
Get the value of the property identified by the key as long.String
getString(Enum<?> key)
Equivalent togetString
(key.name())
.String
getString(Enum<?> key, String defaultValue)
Equivalent togetString
(key.name(), defaultValue)
.String
getString(String key)
Equivalent togetString
(key, null)
.abstract String
getString(String key, String defaultValue)
Get the value of the property identified by the key as String.void
remove(Enum<?> key)
Equivalent toremove
(key.name())
.abstract void
remove(String key)
Remove the property identified by the key.void
set(Enum<?> key, boolean value)
Equivalent tosetBoolean
(key, value)
.void
set(Enum<?> key, float value)
Equivalent tosetFloat
(key, value)
.void
set(Enum<?> key, int value)
Equivalent tosetInt
(key, value)
.void
set(Enum<?> key, long value)
Equivalent tosetLong
(key, value)
.void
set(Enum<?> key, String value)
Equivalent tosetString
(key, value)
.<TEnum extends Enum<TEnum>>
voidset(Enum<?> key, TEnum value)
Equivalent tosetEnum
(key, value)
.void
set(String key, boolean value)
Equivalent tosetBoolean
(key, value)
.void
set(String key, float value)
Equivalent tosetFloat
(key, value)
.void
set(String key, int value)
Equivalent tosetInt
(key, value)
.void
set(String key, long value)
Equivalent tosetLong
(key, value)
.void
set(String key, String value)
Equivalent tosetString
(key, value)
.<TEnum extends Enum<TEnum>>
voidset(String key, TEnum value)
Equivalent tosetEnum
(key, value)
.void
setBoolean(Enum<?> key, boolean value)
Equivalent tosetBoolean
(key.name(), value)
.abstract void
setBoolean(String key, boolean value)
Set the value to the property identified by the key.<TEnum extends Enum<TEnum>>
voidsetEnum(Enum<?> key, TEnum value)
Equivalent tosetEnum
(key.name(), value)
.<TEnum extends Enum<TEnum>>
voidsetEnum(String key, TEnum value)
Equivalent tosetString
(key, (value == null) ? null : value.name())
.void
setFloat(Enum<?> key, float value)
Equivalent tosetFloat
(key.name(), value)
.abstract void
setFloat(String key, float value)
Set the value to the property identified by the key.void
setInt(Enum<?> key, int value)
Equivalent tosetInt
(key.name(), value)
.abstract void
setInt(String key, int value)
Set the value to the property identified by the key.void
setLong(Enum<?> key, long value)
Equivalent tosetLong
(key.name(), value)
.abstract void
setLong(String key, long value)
Set the value to the property identified by the key.void
setString(Enum<?> key, String value)
Equivalent tosetString
(key.name(), value)
.abstract void
setString(String key, String value)
Set the value to the property identified by the key.
-
-
-
Method Detail
-
contains
public abstract boolean contains(String key)
Check if the property identified by the key exists.
-
getBoolean
public abstract boolean getBoolean(String key, boolean defaultValue)
Get the value of the property identified by the key as boolean. Ifkey
is null or there is no property for the key,defaultValue
is returned.
-
get
public boolean get(String key, boolean defaultValue)
Equivalent togetBoolean
(key, defaultValue)
.
-
getBoolean
public boolean getBoolean(String key)
Equivalent togetBoolean
(key, false)
.
-
getBoolean
public boolean getBoolean(Enum<?> key, boolean defaultValue)
-
get
public boolean get(Enum<?> key, boolean defaultValue)
Equivalent togetBoolean
(key, defaultValue)
.
-
getBoolean
public boolean getBoolean(Enum<?> key)
-
getFloat
public abstract float getFloat(String key, float defaultValue)
Get the value of the property identified by the key as float. Ifkey
is null or there is no property for the key,defaultValue
is returned.
-
getFloat
public float getFloat(Enum<?> key, float defaultValue)
-
getFloat
public float getFloat(Enum<?> key)
-
getInt
public abstract int getInt(String key, int defaultValue)
Get the value of the property identified by the key as int. Ifkey
is null or there is no property for the key,defaultValue
is returned.
-
getInt
public int getInt(Enum<?> key, int defaultValue)
-
getInt
public int getInt(Enum<?> key)
-
getLong
public abstract long getLong(String key, long defaultValue)
Get the value of the property identified by the key as long. Ifkey
is null or there is no property for the key,defaultValue
is returned.
-
getLong
public long getLong(Enum<?> key, long defaultValue)
-
getLong
public long getLong(Enum<?> key)
-
getEnum
public <TEnum extends Enum<TEnum>> TEnum getEnum(String key, Class<TEnum> enumClass, TEnum defaultValue)
Get the value of the property identified by the key as Enum. Ifkey
is null or there is no property for the key,defaultValue
is returned.
-
getEnum
public <TEnum extends Enum<TEnum>> TEnum getEnum(String key, TEnum defaultValue)
Equivalent togetEnum
(key, (Class<TEnum>)defaultValue.getClass(), defaultValue)
.defaultValue
must not benull
.
-
get
public <TEnum extends Enum<TEnum>> TEnum get(String key, Class<TEnum> enumClass, TEnum defaultValue)
Equivalent togetEnum
(key, enumClass, defaultValue)
.
-
get
public <TEnum extends Enum<TEnum>> TEnum get(String key, TEnum defaultValue)
Equivalent togetEnum
(key, (Class<TEnum>)defaultValue.getClass(), defaultValue)
.defaultValue
must not benull
.
-
getEnum
public <TEnum extends Enum<TEnum>> TEnum getEnum(String key, Class<TEnum> enumClass)
Equivalent togetEnum
(key, enumClass, null)
.
-
getEnum
public <TEnum extends Enum<TEnum>> TEnum getEnum(Enum<?> key, Class<TEnum> enumClass, TEnum defaultValue)
Equivalent togetEnum
(key.name(), enumClass, defaultValue)
. Ifkey
is null,defaultValue
is returned.
-
getEnum
public <TEnum extends Enum<TEnum>> TEnum getEnum(Enum<?> key, TEnum defaultValue)
Equivalent togetEnum
(key, (Class<TEnum>)defaultValue.getClass(), defaultValue)
.defaultValue
must not benull
.
-
get
public <TEnum extends Enum<TEnum>> TEnum get(Enum<?> key, Class<TEnum> enumClass, TEnum defaultValue)
Equivalent togetEnum
(key, enumClass, defaultValue)
.
-
get
public <TEnum extends Enum<TEnum>> TEnum get(Enum<?> key, TEnum defaultValue)
Equivalent togetEnum
(key, (Class<TEnum>)defaultValue.getClass(), defaultValue)
.defaultValue
must not benull
.
-
getString
public abstract String getString(String key, String defaultValue)
Get the value of the property identified by the key as String. Ifkey
is null or there is no property for the key,defaultValue
is returned.
-
get
public String get(Enum<?> key, String defaultValue)
Equivalent togetString
(key, defaultValue)
.
-
setBoolean
public abstract void setBoolean(String key, boolean value)
Set the value to the property identified by the key. Ifkey
is null, nothing is done.
-
set
public void set(String key, boolean value)
Equivalent tosetBoolean
(key, value)
.
-
setBoolean
public void setBoolean(Enum<?> key, boolean value)
-
set
public void set(Enum<?> key, boolean value)
Equivalent tosetBoolean
(key, value)
.
-
setFloat
public abstract void setFloat(String key, float value)
Set the value to the property identified by the key. Ifkey
is null, nothing is done.
-
setFloat
public void setFloat(Enum<?> key, float value)
-
setInt
public abstract void setInt(String key, int value)
Set the value to the property identified by the key. Ifkey
is null, nothing is done.
-
setInt
public void setInt(Enum<?> key, int value)
-
setLong
public abstract void setLong(String key, long value)
Set the value to the property identified by the key. Ifkey
is null, nothing is done.
-
setLong
public void setLong(Enum<?> key, long value)
-
setEnum
public <TEnum extends Enum<TEnum>> void setEnum(String key, TEnum value)
Equivalent tosetString
(key, (value == null) ? null : value.name())
.
-
set
public <TEnum extends Enum<TEnum>> void set(String key, TEnum value)
Equivalent tosetEnum
(key, value)
.
-
set
public <TEnum extends Enum<TEnum>> void set(Enum<?> key, TEnum value)
Equivalent tosetEnum
(key, value)
.
-
setString
public abstract void setString(String key, String value)
Set the value to the property identified by the key. Ifkey
is null, nothing is done.
-
remove
public abstract void remove(String key)
Remove the property identified by the key. Ifkey
is null, nothing is done.
-
remove
public void remove(Enum<?> key)
-
clear
public abstract void clear()
Clear all properties.
-
-