T
- the type of the value to instantiatepublic class DefaultClassPropertyReaderContext<T> extends Object implements ClassPropertyReaderContext<T>
PropertyReaderContext
which allows to retrieve properties by instantiating a given implementation type,
e.g. specified as fully-qualified class name or class object.Modifier and Type | Method and Description |
---|---|
T |
getTypedValue()
To be implemented in sub-classes to convert the configured value into an object of the property target type.
|
T |
getValue()
Returns the value of the specified property.
|
ClassPropertyReaderContext<T> |
instantiate()
Returns a context which allows to specify how the implementation type represented by the given property should be
instantiated.
|
PropertyReaderContext<T> |
required()
Marks the given property as required.
|
PropertyReaderContext<T> |
withDefault(T defaultValue)
Sets a default value in case no value is specified for the given property.
|
DefaultClassPropertyReaderContext<T> |
withDefaultImplementation(Class<? extends T> defaultImplementation)
Sets the default implementation type for the property in case no value is found.
|
DefaultClassPropertyReaderContext<T> |
withDefaultImplementation(String defaultImplementationName)
Sets the name of default implementation type for the property in case no value is found.
|
DefaultClassPropertyReaderContext<T> |
withInstantiator(Instantiator<T> instantiator)
Sets an instantiator to be used to create an instance of the property.
|
DefaultClassPropertyReaderContext<T> |
withShortNameResolver(ShortNameResolver shortNameResolver)
Sets a short name resolver to be applied in case the property is given as string
|
PropertyReaderContext<T> |
withValidator(PropertyValidator<T> validator)
Adds a validator used to validate the value of the given property.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getValue, instantiate, required, withDefault, withValidator
public DefaultClassPropertyReaderContext<T> withDefaultImplementation(Class<? extends T> defaultImplementation)
ClassPropertyReaderContext
withDefaultImplementation
in interface ClassPropertyReaderContext<T>
defaultImplementation
- the implementation to use if none is configuredpublic DefaultClassPropertyReaderContext<T> withDefaultImplementation(String defaultImplementationName)
ClassPropertyReaderContext
withDefaultImplementation
in interface ClassPropertyReaderContext<T>
defaultImplementationName
- the implementation to use if none is configuredpublic DefaultClassPropertyReaderContext<T> withInstantiator(Instantiator<T> instantiator)
instantiator
- the Instantiator
to use to create the instance of the propertypublic DefaultClassPropertyReaderContext<T> withShortNameResolver(ShortNameResolver shortNameResolver)
ClassPropertyReaderContext
withShortNameResolver
in interface ClassPropertyReaderContext<T>
shortNameResolver
- the resolver to use when an implementation short name is providedpublic T getTypedValue()
getTypedValue
in interface ClassPropertyReaderContext<T>
null
public PropertyReaderContext<T> withDefault(T defaultValue)
PropertyReaderContext
withDefault
in interface PropertyReaderContext<T>
defaultValue
- the default value used when non is specifiedpublic PropertyReaderContext<T> required()
PropertyReaderContext
required
in interface PropertyReaderContext<T>
public PropertyReaderContext<T> withValidator(PropertyValidator<T> validator)
PropertyReaderContext
withValidator
in interface PropertyReaderContext<T>
validator
- the validator to use for the value of the propertypublic ClassPropertyReaderContext<T> instantiate()
PropertyReaderContext
instantiate
in interface PropertyReaderContext<T>
public T getValue()
PropertyReaderContext
getValue
in interface PropertyReaderContext<T>
null
in case the property is not present in the given
configuration map and no default implementation has been specifiedCopyright © 2010-2017 Red Hat, Inc., Emmanuel Bernard and various contributors. All Rights Reserved.