org.springframework.boot.env

Class RandomValuePropertySource

  • java.lang.Object
    • org.springframework.core.env.PropertySource<java.util.Random>
      • org.springframework.boot.env.RandomValuePropertySource


  • public class RandomValuePropertySource
    extends org.springframework.core.env.PropertySource<java.util.Random>
    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 Integer value, restricted by an optionally specified range.
    • When "long", a random Long value, restricted by an optionally specified range.
    • Otherwise, a byte[].
    The "random.int" and "random.long" properties supports a range suffix whose syntax is:

    OPEN value (,max) CLOSE where the OPEN,CLOSE are any character and value,max are integers. If max is provided then value is the minimum value and max is the maximum (exclusive).

    Since:
    1.0.0
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.springframework.core.env.PropertySource

        org.springframework.core.env.PropertySource.StubPropertySource
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String RANDOM_PROPERTY_SOURCE_NAME
      Name of the random PropertySource.
      • Fields inherited from class org.springframework.core.env.PropertySource

        name, source
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      static void addToEnvironment(org.springframework.core.env.ConfigurableEnvironment environment) 
      java.lang.Object getProperty(java.lang.String name) 
      • Methods inherited from class org.springframework.core.env.PropertySource

        containsProperty, equals, getName, getSource, hashCode, named, toString
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • RANDOM_PROPERTY_SOURCE_NAME

        public static final java.lang.String RANDOM_PROPERTY_SOURCE_NAME
        Name of the random PropertySource.
        See Also:
        Constant Field Values
    • Constructor Detail

      • RandomValuePropertySource

        public RandomValuePropertySource(java.lang.String name)
      • RandomValuePropertySource

        public RandomValuePropertySource()
    • Method Detail

      • getProperty

        public java.lang.Object getProperty(java.lang.String name)
        Specified by:
        getProperty in class org.springframework.core.env.PropertySource<java.util.Random>
      • addToEnvironment

        public static void addToEnvironment(org.springframework.core.env.ConfigurableEnvironment environment)