Package com.mysql.cj.conf
Class AbstractRuntimeProperty<T>
java.lang.Object
com.mysql.cj.conf.AbstractRuntimeProperty<T>
- All Implemented Interfaces:
RuntimeProperty<T>
,java.io.Serializable
- Direct Known Subclasses:
BooleanProperty
,EnumProperty
,IntegerProperty
,LongProperty
,StringProperty
public abstract class AbstractRuntimeProperty<T> extends java.lang.Object implements RuntimeProperty<T>, java.io.Serializable
- See Also:
- Serialized Form
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.mysql.cj.conf.RuntimeProperty
RuntimeProperty.RuntimePropertyListener
-
Field Summary
Fields Modifier and Type Field Description protected T
initialValue
protected T
value
protected boolean
wasExplicitlySet
-
Constructor Summary
Constructors Modifier Constructor Description AbstractRuntimeProperty()
protected
AbstractRuntimeProperty(PropertyDefinition<T> propertyDefinition)
-
Method Summary
Modifier and Type Method Description void
addListener(RuntimeProperty.RuntimePropertyListener l)
Add listener for this property changes.protected void
checkRange(T val, java.lang.String valueAsString, ExceptionInterceptor exceptionInterceptor)
For range-based property, checks that value fit into range given by PropertyDefinition.T
getInitialValue()
Get initial value (default or defined in connection string/Properties)PropertyDefinition<T>
getPropertyDefinition()
java.lang.String
getStringValue()
Get internal value representation as String.T
getValue()
Get internal value representation as Object.void
initializeFrom(java.util.Properties extractFrom, ExceptionInterceptor exceptionInterceptor)
Explicitly set value of this RuntimeProperty according to the self-titled property value contained in extractFrom.void
initializeFrom(javax.naming.Reference ref, ExceptionInterceptor exceptionInterceptor)
protected void
invokeListeners()
boolean
isExplicitlySet()
void
removeListener(RuntimeProperty.RuntimePropertyListener listener)
void
resetValue()
Reset to initial value (default or defined in connection string/Properties)void
setValue(T value)
Set the object value of a property directly.void
setValue(T value, ExceptionInterceptor exceptionInterceptor)
Set the object value of a property directly.void
setValueInternal(java.lang.String value, ExceptionInterceptor exceptionInterceptor)
Set the value of a property from a string value.void
setValueInternal(T value, java.lang.String valueAsString, ExceptionInterceptor exceptionInterceptor)
Internal method for setting property value; ignoring the RUNTIME_NOT_MODIFIABLE flag.
-
Field Details
-
value
-
initialValue
-
wasExplicitlySet
protected boolean wasExplicitlySet
-
-
Constructor Details
-
AbstractRuntimeProperty
public AbstractRuntimeProperty() -
AbstractRuntimeProperty
-
-
Method Details
-
getPropertyDefinition
- Specified by:
getPropertyDefinition
in interfaceRuntimeProperty<T>
-
initializeFrom
public void initializeFrom(java.util.Properties extractFrom, ExceptionInterceptor exceptionInterceptor)Description copied from interface:RuntimeProperty
Explicitly set value of this RuntimeProperty according to the self-titled property value contained in extractFrom. This method is called during PropertySet initialization thus ignores the RUNTIME_NOT_MODIFIABLE flag.This value will also be the initial one, i.e.
RuntimeProperty.resetValue()
will reset to this value, not the default one.If extractFrom does not contain such property then this RuntimeProperty remains unchanged.
- Specified by:
initializeFrom
in interfaceRuntimeProperty<T>
- Parameters:
extractFrom
-Properties
object containing key-value pairs usually passed from connection string.exceptionInterceptor
- exceptionInterceptor
-
initializeFrom
- Specified by:
initializeFrom
in interfaceRuntimeProperty<T>
-
resetValue
public void resetValue()Description copied from interface:RuntimeProperty
Reset to initial value (default or defined in connection string/Properties)- Specified by:
resetValue
in interfaceRuntimeProperty<T>
-
isExplicitlySet
public boolean isExplicitlySet()- Specified by:
isExplicitlySet
in interfaceRuntimeProperty<T>
-
addListener
Description copied from interface:RuntimeProperty
Add listener for this property changes.- Specified by:
addListener
in interfaceRuntimeProperty<T>
- Parameters:
l
-RuntimeProperty.RuntimePropertyListener
-
removeListener
- Specified by:
removeListener
in interfaceRuntimeProperty<T>
-
invokeListeners
protected void invokeListeners() -
getValue
Description copied from interface:RuntimeProperty
Get internal value representation as Object.- Specified by:
getValue
in interfaceRuntimeProperty<T>
- Returns:
- value
-
getInitialValue
Description copied from interface:RuntimeProperty
Get initial value (default or defined in connection string/Properties)- Specified by:
getInitialValue
in interfaceRuntimeProperty<T>
- Returns:
- value
-
getStringValue
public java.lang.String getStringValue()Description copied from interface:RuntimeProperty
Get internal value representation as String.- Specified by:
getStringValue
in interfaceRuntimeProperty<T>
- Returns:
- value
-
setValueInternal
Set the value of a property from a string value. It involves thePropertyDefinition.parseObject(String, ExceptionInterceptor)
to validate and parse the string.- Parameters:
value
- valueexceptionInterceptor
- exception interceptor
-
setValueInternal
public void setValueInternal(T value, java.lang.String valueAsString, ExceptionInterceptor exceptionInterceptor)Internal method for setting property value; ignoring the RUNTIME_NOT_MODIFIABLE flag.- Parameters:
value
- valuevalueAsString
- value represented by StringexceptionInterceptor
- exception interceptor
-
checkRange
protected void checkRange(T val, java.lang.String valueAsString, ExceptionInterceptor exceptionInterceptor)For range-based property, checks that value fit into range given by PropertyDefinition.- Parameters:
val
- valuevalueAsString
- value represented by StringexceptionInterceptor
- exception interceptor
-
setValue
Description copied from interface:RuntimeProperty
Set the object value of a property directly. Validation against allowable values will be performed.- Specified by:
setValue
in interfaceRuntimeProperty<T>
- Parameters:
value
- value
-
setValue
Description copied from interface:RuntimeProperty
Set the object value of a property directly. Validation against allowable values will be performed.- Specified by:
setValue
in interfaceRuntimeProperty<T>
- Parameters:
value
- valueexceptionInterceptor
- exception interceptor
-