Class Keys

java.lang.Object
org.instancio.settings.Keys

public final class Keys extends Object
Defines all keys supported by Instancio.
Since:
1.1.10
See Also:
  • Field Details

    • ARRAY_ELEMENTS_NULLABLE

      public static final SettingKey<Boolean> ARRAY_ELEMENTS_NULLABLE
      Specifies whether a null can be generated for array elements; default is false; property name array.elements.nullable.
    • ARRAY_MAX_LENGTH

      public static final SettingKey<Integer> ARRAY_MAX_LENGTH
      Specifies maximum length for arrays; default is 6; property name array.max.length.
    • ARRAY_MIN_LENGTH

      public static final SettingKey<Integer> ARRAY_MIN_LENGTH
      Specifies minimum length for arrays; default is 2; property name array.min.length.
    • ARRAY_NULLABLE

      public static final SettingKey<Boolean> ARRAY_NULLABLE
      Specifies whether a null can be generated for arrays; default is false; property name array.nullable.
    • BOOLEAN_NULLABLE

      public static final SettingKey<Boolean> BOOLEAN_NULLABLE
      Specifies whether a null can be generated for Boolean type; default is false; property name boolean.nullable.
    • BYTE_MAX

      public static final SettingKey<Byte> BYTE_MAX
      Specifies maximum value for bytes; default is 127; property name byte.max.
    • BYTE_MIN

      public static final SettingKey<Byte> BYTE_MIN
      Specifies minimum value for bytes; default is 1; property name byte.min.
    • BYTE_NULLABLE

      public static final SettingKey<Boolean> BYTE_NULLABLE
      Specifies whether a null can be generated for Byte type; default is false; property name byte.nullable.
    • CHARACTER_NULLABLE

      public static final SettingKey<Boolean> CHARACTER_NULLABLE
      Specifies whether a null can be generated for Character type; default is false; property name character.nullable.
    • COLLECTION_ELEMENTS_NULLABLE

      public static final SettingKey<Boolean> COLLECTION_ELEMENTS_NULLABLE
      Specifies whether a null can be generated for collection elements; default is false; property name collection.elements.nullable.
    • COLLECTION_MAX_SIZE

      public static final SettingKey<Integer> COLLECTION_MAX_SIZE
      Specifies maximum size for collections; default is 6; property name collection.max.size.
    • COLLECTION_MIN_SIZE

      public static final SettingKey<Integer> COLLECTION_MIN_SIZE
      Specifies minimum size for collections; default is 2; property name collection.min.size.
    • COLLECTION_NULLABLE

      public static final SettingKey<Boolean> COLLECTION_NULLABLE
      Specifies whether a null can be generated for collections; default is false; property name collection.nullable.
    • DOUBLE_MAX

      public static final SettingKey<Double> DOUBLE_MAX
      Specifies maximum value for doubles; default is 10000; property name double.max.
    • DOUBLE_MIN

      public static final SettingKey<Double> DOUBLE_MIN
      Specifies minimum value for doubles; default is 1; property name double.min.
    • DOUBLE_NULLABLE

      public static final SettingKey<Boolean> DOUBLE_NULLABLE
      Specifies whether a null can be generated for Double type; default is false; property name double.nullable.
    • FLOAT_MAX

      public static final SettingKey<Float> FLOAT_MAX
      Specifies maximum value for floats; default is 10000; property name float.max.
    • FLOAT_MIN

      public static final SettingKey<Float> FLOAT_MIN
      Specifies minimum value for floats; default is 1; property name float.min.
    • FLOAT_NULLABLE

      public static final SettingKey<Boolean> FLOAT_NULLABLE
      Specifies whether a null can be generated for Float type; default is false; property name float.nullable.
    • INTEGER_MAX

      public static final SettingKey<Integer> INTEGER_MAX
      Specifies maximum value for integers; default is 10000; property name integer.max.
    • INTEGER_MIN

      public static final SettingKey<Integer> INTEGER_MIN
      Specifies minimum value for integers; default is 1; property name integer.min.
    • INTEGER_NULLABLE

      public static final SettingKey<Boolean> INTEGER_NULLABLE
      Specifies whether a null can be generated for Integer type; default is false; property name integer.nullable.
    • LONG_MAX

      public static final SettingKey<Long> LONG_MAX
      Specifies maximum value for longs; default is 10000; property name long.max.
    • LONG_MIN

      public static final SettingKey<Long> LONG_MIN
      Specifies minimum value for longs; default is 1; property name long.min.
    • LONG_NULLABLE

      public static final SettingKey<Boolean> LONG_NULLABLE
      Specifies whether a null can be generated for Long type; default is false; property name long.nullable.
    • MAP_KEYS_NULLABLE

      public static final SettingKey<Boolean> MAP_KEYS_NULLABLE
      Specifies whether a null can be generated for map keys; default is false; property name map.keys.nullable.
    • MAP_MAX_SIZE

      public static final SettingKey<Integer> MAP_MAX_SIZE
      Specifies maximum size for maps; default is 6; property name map.max.size.
    • MAP_MIN_SIZE

      public static final SettingKey<Integer> MAP_MIN_SIZE
      Specifies minimum size for maps; default is 2; property name map.min.size.
    • MAP_NULLABLE

      public static final SettingKey<Boolean> MAP_NULLABLE
      Specifies whether a null can be generated for maps; default is false; property name map.nullable.
    • MAP_VALUES_NULLABLE

      public static final SettingKey<Boolean> MAP_VALUES_NULLABLE
      Specifies whether a null can be generated for map values; default is false; property name map.values.nullable.
    • MODE

      public static final SettingKey<Mode> MODE
      Specifies the mode: strict (unused selectors will trigger an exception) or lenient; default is Mode.STRICT; property name mode.
      Since:
      1.3.3
      See Also:
    • AFTER_GENERATE_HINT

      public static final SettingKey<AfterGenerate> AFTER_GENERATE_HINT
      Specifies the default value of the AfterGenerate hint supplied from custom generators to the engine; default is AfterGenerate.POPULATE_NULLS_AND_DEFAULT_PRIMITIVES; property name hint.after.generate.
      Since:
      2.0.0
      See Also:
    • OVERWRITE_EXISTING_VALUES

      public static final SettingKey<Boolean> OVERWRITE_EXISTING_VALUES
      Specifies whether initialised fields are allowed to be overwritten; default is true; property name overwrite.existing.values.
      Since:
      2.0.0
    • ASSIGNMENT_TYPE

      @ExperimentalApi public static final SettingKey<AssignmentType> ASSIGNMENT_TYPE
      Specifies how to assign values via reflection, using fields or methods; default is AssignmentType.FIELD; property name assignment.type.
      Since:
      2.1.0
      See Also:
    • ON_SET_FIELD_ERROR

      @ExperimentalApi public static final SettingKey<OnSetFieldError> ON_SET_FIELD_ERROR
      Specifies what should happen if an error occurs setting a field's value; default is OnSetFieldError.IGNORE; property name on.set.field.error.

      Warning: an error caused by assigning an incompatible type is considered a user error and is never ignored, despite this setting.

      Since:
      2.1.0
      See Also:
    • ON_SET_METHOD_ERROR

      @ExperimentalApi public static final SettingKey<OnSetMethodError> ON_SET_METHOD_ERROR
      Specifies what should happen if an error occurs invoking a setter; default is OnSetMethodError.ASSIGN_FIELD; property name on.set.method.error.
      Since:
      2.1.0
      See Also:
    • ON_SET_METHOD_NOT_FOUND

      @ExperimentalApi public static final SettingKey<OnSetMethodNotFound> ON_SET_METHOD_NOT_FOUND
      Specifies what should happen if a setter method for a field cannot be resolved; default is OnSetMethodNotFound.ASSIGN_FIELD; property name on.set.method.not.found.
      Since:
      2.1.0
      See Also:
    • SETTER_STYLE

      @ExperimentalApi public static final SettingKey<SetterStyle> SETTER_STYLE
      Indicates the naming convention of setter methods to use; default is SetterStyle.SET; property name setter.style.
      Since:
      2.1.0
      See Also:
    • BEAN_VALIDATION_ENABLED

      @ExperimentalApi public static final SettingKey<Boolean> BEAN_VALIDATION_ENABLED
      Specifies whether values should be generated based on Jakarta Bean Validation 3.0 annotations, if present; default is false; property name bean.validation.api.enabled.
      Since:
      2.7.0
    • MAX_DEPTH

      public static final SettingKey<Integer> MAX_DEPTH
      Specifies the maximum depth of the generated object tree; default is 8; property name max.depth.
      Since:
      2.7.0
    • SEED

      public static final SettingKey<Long> SEED
      Specifies the seed value; default is null; property name seed.
      Since:
      1.5.1
    • SHORT_MAX

      public static final SettingKey<Short> SHORT_MAX
      Specifies maximum value for shorts; default is 10000; property name short.max.
    • SHORT_MIN

      public static final SettingKey<Short> SHORT_MIN
      Specifies minimum value for shorts; default is 1; property name short.min.
    • SHORT_NULLABLE

      public static final SettingKey<Boolean> SHORT_NULLABLE
      Specifies whether a null can be generated for Short type; default is false; property name short.nullable.
    • STRING_ALLOW_EMPTY

      public static final SettingKey<Boolean> STRING_ALLOW_EMPTY
      Specifies whether an empty string can be generated; default is false; property name string.allow.empty.
    • STRING_MAX_LENGTH

      public static final SettingKey<Integer> STRING_MAX_LENGTH
      Specifies maximum length of strings; default is 10; property name string.max.length.
    • STRING_MIN_LENGTH

      public static final SettingKey<Integer> STRING_MIN_LENGTH
      Specifies minimum length of strings; default is 3; property name string.min.length.
    • STRING_NULLABLE

      public static final SettingKey<Boolean> STRING_NULLABLE
      Specifies whether a null can be generated for String type; default is false; property name string.nullable.
    • STRING_FIELD_PREFIX_ENABLED

      public static final SettingKey<Boolean> STRING_FIELD_PREFIX_ENABLED
      Specifies whether generated Strings should be prefixed with field names; default is false; property name string.field.prefix.enabled.
      Since:
      2.4.0
  • Method Details

    • all

      public static List<SettingKey<Object>> all()
      Returns all keys supported by Instancio.
      Returns:
      all keys
    • get

      public static <T> SettingKey<T> get(@NotNull @NotNull String key)
      Returns a SettingKey instance with the given property key.
      Parameters:
      key - to lookup
      Returns:
      the setting key, or null if none found
    • ofType

      @ExperimentalApi public static <T> SettingKey.SettingKeyBuilder<T> ofType(Class<T> type)
      A builder for creating custom setting keys.

      When defining custom keys, specifying SettingKey.SettingKeyBuilder.withPropertyKey(String) is optional since not all settings will be defined in a properties file. If withPropertyKey() is not specified, then a random property key will be assigned.

      Type Parameters:
      T - the value type
      Parameters:
      type - of the value the key is associated with, not null
      Returns:
      key builder
      Since:
      2.12.0