|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.emarsys.ecommon.prefs.config.GenericSetting
public class GenericSetting
GenericSetting
represents some kind of the
reference implementation of ISetting
.
TODO special equals() and hashCode() contract
Field Summary | |
---|---|
protected SettingMode |
mode
|
protected java.lang.String |
name
|
protected java.lang.String |
value
|
Fields inherited from interface com.emarsys.ecommon.prefs.config.ISetting |
---|
DEF_DATE_FORMAT |
Constructor Summary | |
---|---|
GenericSetting()
|
|
GenericSetting(ISetting isetting)
|
|
GenericSetting(java.lang.String name,
java.lang.String value)
|
|
GenericSetting(java.lang.String name,
java.lang.String value,
SettingMode mode)
|
Method Summary | |
---|---|
boolean |
equals(java.lang.Object that)
Returns false if the passed Object is
not an instance of ISetting or has a different
String name than this instance. |
static boolean |
getAsBoolean(java.lang.String value)
|
static java.util.Date |
getAsDate(java.lang.String value,
java.lang.String format)
|
static double |
getAsDouble(java.lang.String value)
|
static int |
getAsInt(java.lang.String value)
|
static java.util.List<java.lang.String> |
getAsList(java.lang.String value)
|
static long |
getAsLong(java.lang.String value)
|
boolean |
getBooleanValue()
Parses the setting's value and
converts it to a boolean value. |
java.util.Date |
getDateValue()
Parses the setting's value
assuming the default date format
and converts it to a Date instance. |
java.util.Date |
getDateValue(java.lang.String format)
Parses the setting's value
using the passed date format
and converts it to a Date instance. |
double |
getDoubleValue()
Parses the setting's value and
converts it to a double value. |
int |
getIntValue()
Parses the setting's value and
converts it to an int. |
java.util.List<java.lang.String> |
getListValues()
Parses the setting's value
which is assumed to be a comma seperated list and
converts it to a List instance. |
long |
getLongValue()
Parses the setting's value and
converts it to a long value. |
SettingMode |
getMode()
Retrieves the SettingMode associated with the
ISetting . |
java.lang.String |
getName()
The unique and persistent name of the setting. |
java.lang.String |
getValue()
Retrieves the persistent String value of the
ISetting . |
int |
hashCode()
Creates a hash code for this ISetting that solely
refers to its unique name. |
void |
setMode(SettingMode mode)
Set/updates the ISetting 's mode. |
void |
setName(java.lang.String name)
Sets/updates the unique name of the ISetting . |
void |
setValue(java.lang.String value)
Sets/updates the value of the ISetting . |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.lang.String name
protected java.lang.String value
protected SettingMode mode
Constructor Detail |
---|
public GenericSetting()
public GenericSetting(java.lang.String name, java.lang.String value)
name
- value
- public GenericSetting(java.lang.String name, java.lang.String value, SettingMode mode)
name
- value
- mode
- public GenericSetting(ISetting isetting)
isetting
- Method Detail |
---|
public static java.util.List<java.lang.String> getAsList(java.lang.String value)
value
-
public static int getAsInt(java.lang.String value)
value
-
public static long getAsLong(java.lang.String value)
value
-
public static double getAsDouble(java.lang.String value)
value
-
public static boolean getAsBoolean(java.lang.String value)
value
-
public static java.util.Date getAsDate(java.lang.String value, java.lang.String format) throws java.text.ParseException
value
- format
-
java.text.ParseException
public java.lang.String getName()
ISetting
getName
in interface ISetting
null
name of the ISetting
ISetting.getName()
public void setName(java.lang.String name)
ISetting
ISetting
.
The update needs not to have a persistent effect
(altough it might be case if your ISetting
is implemented as a managed JPA entity, for instance).
Thus if you want to persistently update your Configuration
you have to use ConfigurationBackend.set(ISetting)
.
setName
in interface ISetting
name
- - the name of the settingISetting.setName(java.lang.String)
public java.lang.String getValue()
ISetting
String
value of the
ISetting
.
getValue
in interface ISetting
null
value of the ISetting
ISetting.getValue()
public int getIntValue()
ISetting
value
and
converts it to an int.
Throws a an unchecked instance of RuntimeException
on parsing errors.
getIntValue
in interface ISetting
ISetting.getIntValue()
public long getLongValue()
ISetting
value
and
converts it to a long value.
Throws a an unchecked instance of RuntimeException
on parsing errors.
getLongValue
in interface ISetting
ISetting.getLongValue()
public double getDoubleValue()
ISetting
value
and
converts it to a double value.
Throws a an unchecked instance of RuntimeException
on parsing errors.
getDoubleValue
in interface ISetting
ISetting.getDoubleValue()
public boolean getBooleanValue()
ISetting
value
and
converts it to a boolean value.
Throws a an unchecked instance of RuntimeException
on parsing errors.
getBooleanValue
in interface ISetting
ISetting.getBooleanValue()
public java.util.Date getDateValue() throws java.text.ParseException
ISetting
value
assuming the default date format
and converts it to a Date
instance.
getDateValue
in interface ISetting
Date
value
java.text.ParseException
- - on any parsing error.ISetting.getDateValue()
public java.util.Date getDateValue(java.lang.String format) throws java.text.ParseException
ISetting
value
using the passed date format
and converts it to a Date
instance.
getDateValue
in interface ISetting
format
- - the SimpleDateFormat
in a String
form
Date
value
java.text.ParseException
- - on any parsing error.ISetting.getDateValue(java.lang.String)
public java.util.List<java.lang.String> getListValues()
ISetting
value
which is assumed to be a comma seperated list and
converts it to a List
instance.
Throws a an unchecked instance of RuntimeException
on parsing errors.
getListValues
in interface ISetting
List
valuesISetting.getListValues()
public void setValue(java.lang.String value)
ISetting
ISetting
.
The update needs not to have a persistent effect
(altough it might be case if your ISetting
is implemented as a managed JPA entity, for instance).
Thus if you want to persistently update your Configuration
you have to use ConfigurationBackend.set(ISetting)
.
setValue
in interface ISetting
value
- - the (new) value of the settingISetting.setValue(java.lang.String)
public SettingMode getMode()
ISetting
SettingMode
associated with the
ISetting
.
The SettingMode
is transient and volatile, that
means it needs not to be stored persistently in the
backend
and might
be changed by chained backends several times during
a call to ConfigurationBackend.get(String)
.
getMode
in interface ISetting
SettingMode
of this ISetting
,
never null
.ISetting.getMode()
public void setMode(SettingMode mode)
ISetting
ISetting
's mode.
The SettingMode
is not stored persistently for
settings and mighty change on its way through
ConfigurationBackend
s.
setMode
in interface ISetting
mode
- the mode to setcom.emarsys.ecommon.prefs.config.ISetting#setMode(com.emarsys.core.setting.config.SettingMode)
public boolean equals(java.lang.Object that)
ISetting
Returns false
if the passed Object
is
not an instance of ISetting
or has a different
String
name than this instance.
Only the name
is relevant
for an equality check of ISetting
instances,
this has to ensured in every subtype!
equals
in interface ISetting
equals
in class java.lang.Object
that
- the object with which to compare
true
if this object has the same
setting name as 'that'; false
otherwise.ISetting.equals(Object)
public int hashCode()
ISetting
ISetting
that solely
refers to its unique name.
This has to be ensured in subclasses too!
hashCode
in interface ISetting
hashCode
in class java.lang.Object
ISetting.hashCode()
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |