Class RandomValuePropertySource
java.lang.Object
org.springframework.core.env.PropertySource<Random>
org.springframework.boot.env.RandomValuePropertySource
PropertySource that returns a random value for any property that starts with
"random.". Where the "unqualified property name" is the portion of the
requested property name beyond the "random." prefix, this PropertySource
returns:
- When "int", a random Integervalue, restricted by an optionally specified range.
- When "long", a random Longvalue, restricted by an optionally specified range.
- When "uuid", a random UUIDvalue.
- Otherwise, a byte[].
OPEN value (,max) CLOSE where the OPEN,CLOSE are any character and
value,max are integers. If max is not provided, then 0 is used as the
lower bound and value is the upper bound. If max is provided then
value is the minimum value and max is the maximum (exclusive).
- Since:
- 1.0.0
- Author:
- Dave Syer, Matt Benson, Madhura Bhave, Moritz Halbritter
- 
Nested Class SummaryNested classes/interfaces inherited from class PropertySourcePropertySource.StubPropertySource
- 
Field SummaryFieldsFields inherited from class PropertySourcename, source
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic voidaddToEnvironment(ConfigurableEnvironment environment) Add aRandomValuePropertySourceto the givenEnvironment.static voidaddToEnvironment(ConfigurableEnvironment environment, org.apache.commons.logging.Log logger) Add aRandomValuePropertySourceto the givenEnvironment.@Nullable ObjectgetProperty(String name) Methods inherited from class PropertySourcecontainsProperty, equals, getName, getSource, hashCode, named, toString
- 
Field Details- 
RANDOM_PROPERTY_SOURCE_NAME
 
- 
- 
Constructor Details- 
RandomValuePropertySourcepublic RandomValuePropertySource()
- 
RandomValuePropertySource
 
- 
- 
Method Details- 
getProperty- Specified by:
- getPropertyin class- PropertySource<Random>
 
- 
addToEnvironmentAdd aRandomValuePropertySourceto the givenEnvironment.- Parameters:
- environment- the environment to add the random property source to
 
- 
addToEnvironmentpublic static void addToEnvironment(ConfigurableEnvironment environment, org.apache.commons.logging.Log logger) Add aRandomValuePropertySourceto the givenEnvironment.- Parameters:
- environment- the environment to add the random property source to
- logger- logger used for debug and trace information
- Since:
- 4.0.0
 
 
-