Package org.instancio.settings
Class Settings
- java.lang.Object
-
- org.instancio.settings.Settings
-
public class Settings extends Object
Instancio settings API.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Settings
create()
Create a new instance of empty settings.static Settings
defaults()
Create default settings.static Settings
from(Map<?,?> map)
Create settings from the given map.static Settings
from(Settings other)
Create settings from the given settings.<T> T
get(SettingKey key)
Get setting value for given key.Map<Class<?>,Class<?>>
getSubtypeMap()
Returns a read-only view of the subtype map.Settings
lock()
Locks these settings for further modifications, making this instance immutable.Settings
mapType(Class<?> from, Class<?> to)
Map 'from' supertype to 'to' subtype.Settings
merge(Settings other)
Creates a new instance of settings by merging given settings with these settings.Settings
set(SettingKey key, Object value)
Set setting with given key to the specified value.
-
-
-
Method Detail
-
create
public static Settings create()
Create a new instance of empty settings.- Returns:
- empty settings
-
defaults
public static Settings defaults()
Create default settings.- Returns:
- settings containing defaults
-
from
public static Settings from(Map<?,?> map)
Create settings from the given map.- Parameters:
map
- to create settings from- Returns:
- settings
-
from
public static Settings from(Settings other)
Create settings from the given settings.- Parameters:
other
- settings to create settings from- Returns:
- a new instance of settings
-
merge
public Settings merge(@Nullable Settings other)
Creates a new instance of settings by merging given settings with these settings.- Parameters:
other
- settings to merge- Returns:
- new instance of merged settings
-
get
public <T> T get(SettingKey key)
Get setting value for given key.- Type Parameters:
T
- setting value type- Parameters:
key
- setting key- Returns:
- value for given key, or
null
if none.
-
set
public Settings set(SettingKey key, Object value)
Set setting with given key to the specified value.- Parameters:
key
- to setvalue
- to set- Returns:
- updated settings
-
mapType
public Settings mapType(Class<?> from, Class<?> to)
Map 'from' supertype to 'to' subtype.- Parameters:
from
- supertype classto
- subtype class- Returns:
- updated settings
-
getSubtypeMap
public Map<Class<?>,Class<?>> getSubtypeMap()
Returns a read-only view of the subtype map.- Returns:
- subtype map
-
lock
public Settings lock()
Locks these settings for further modifications, making this instance immutable.- Returns:
- read-only settings
-
-