Enum AfterGenerate

java.lang.Object
java.lang.Enum<AfterGenerate>
org.instancio.generator.AfterGenerate
All Implemented Interfaces:
Serializable, Comparable<AfterGenerate>, java.lang.constant.Constable

public enum AfterGenerate extends Enum<AfterGenerate>
An action hint that is passed from a generator to the engine via the Generator.hints() method.

This hint indicates to the engine what action, if any, should be applied to the object(s) created by the generator.

Since:
2.0.0
See Also:
  • Enum Constant Details

    • DO_NOT_MODIFY

      public static final AfterGenerate DO_NOT_MODIFY
      Indicates that an object created by the generator should not be modified. The engine will treat the object as read-only and assign it to the target field as is.

      The following methods with matching selectors will not be applied to the object:

      Note: callbacks provided via the onComplete() method will still be executed.

      Since:
      2.0.0
    • APPLY_SELECTORS

      public static final AfterGenerate APPLY_SELECTORS
      Indicates that an object created by the generator can be modified using any of the following methods:
      Since:
      2.0.0
    • POPULATE_NULLS

      public static final AfterGenerate POPULATE_NULLS
      Indicates that null fields declared by an object that was created by the generator should be populated by the engine. In addition, the object can be also be modified as described by APPLY_SELECTORS.
      Since:
      2.0.0
    • POPULATE_NULLS_AND_DEFAULT_PRIMITIVES

      public static final AfterGenerate POPULATE_NULLS_AND_DEFAULT_PRIMITIVES
      Indicates that primitive fields with default values declared by an object that was created by the generator should be populated by the engine. In addition, the behaviour described by POPULATE_NULLS applies as well.

      Default values for primitive fields are defined as:

      • Zero for all numeric types
      • false for boolean
      • '' null character for char

      For instance, if a boolean field was initialised to true, it will not be "populated". However, if it is false, then it will be randomised to either true or false.

      Since:
      2.0.0
    • POPULATE_ALL

      public static final AfterGenerate POPULATE_ALL
      A hint to populate all fields, regardless of their initial values. This action will cause all the values to be overwritten with random data.

      This is the default mode of internal generators.

      Since:
      2.0.0
  • Method Details

    • values

      public static AfterGenerate[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static AfterGenerate valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null