Class InternalSettings

java.lang.Object
org.instancio.internal.settings.InternalSettings
All Implemented Interfaces:
Settings

public final class InternalSettings extends Object implements Settings
  • Method Details

    • create

      public static InternalSettings create()
      Description copied from interface: Settings
      Creates a new instance of empty settings.
      Returns:
      a new instance of empty settings
    • defaults

      public static InternalSettings defaults()
      Description copied from interface: Settings
      Creates a new instance containing default settings.
      Returns:
      a new instance of settings containing the defaults
    • from

      public static InternalSettings from(Map<Object,Object> map)
      Description copied from interface: Settings
      Create settings from the given map.
      Parameters:
      map - to create settings from
      Returns:
      a new instance of settings created from the given map
    • from

      public static InternalSettings from(Settings other)
      Description copied from interface: Settings
      Create settings from the given settings.
      Parameters:
      other - settings to create settings from
      Returns:
      a new instance of settings
    • merge

      public InternalSettings merge(@Nullable @Nullable Settings other)
      Description copied from interface: Settings
      Creates a new instance of settings by merging given settings with these settings.
      Specified by:
      merge in interface Settings
      Parameters:
      other - settings to merge
      Returns:
      new instance of merged settings
    • get

      public <T> T get(@NotNull @NotNull SettingKey<T> key)
      Description copied from interface: Settings
      Get setting value for given key.
      Specified by:
      get in interface Settings
      Type Parameters:
      T - setting value type
      Parameters:
      key - setting key
      Returns:
      value for given key, or null if none.
    • set

      public <T> InternalSettings set(SettingKey<T> key, T value)
      Description copied from interface: Settings
      Set the setting with the given key to the specified value.

      Note: when updating range settings (such as Keys.COLLECTION_MIN_SIZE and Keys.COLLECTION_MAX_SIZE), range bounds are auto-adjusted by Constants.RANGE_ADJUSTMENT_PERCENTAGE if the new minimum is higher than the current maximum, and vice versa.

      Specified by:
      set in interface Settings
      Parameters:
      key - the key to set, not null
      value - to set, can be null
      Returns:
      this instance of settings
    • mapType

      public InternalSettings mapType(@NotNull @NotNull Class<?> type, @NotNull @NotNull Class<?> subtype)
      Description copied from interface: Settings
      Maps the supertype from supertype to 'to' subtype.

      Example:

      
         Settings settings = Settings.create()
             .mapType(Animal.class, Dog.class);
      
         Animal animal = Instancio.of(Animal.class)
             .withSettings(settings)
             .create();
      
         assertThat(animal).isExactlyInstanceOf(Dog.class);
       
      Specified by:
      mapType in interface Settings
      Parameters:
      type - the type to map to a subtype
      subtype - the subtype class
      Returns:
      this instance of settings
    • getSubtypeMap

      public Map<Class<?>,Class<?>> getSubtypeMap()
      Description copied from interface: Settings
      Returns a read-only view of the subtype map.
      Specified by:
      getSubtypeMap in interface Settings
      Returns:
      subtype map
    • lock

      public InternalSettings lock()
      Description copied from interface: Settings
      Locks these settings for further modifications, making this instance immutable.
      Specified by:
      lock in interface Settings
      Returns:
      this instance of settings that can no longer be modified
    • toString

      public String toString()
      Overrides:
      toString in class Object