Top Description Constructors Methods
com.typesafe.config

public Class ConfigBeanFactory

extends Object
Class Inheritance
Imports
com.typesafe.config.impl.ConfigBeanImpl

Factory for automatically creating a Java class from a Config. See create(Config, Class).
Since
1.3.0

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static <
the type of the class to be instantiated
T
>
T

Returns:

an instance of the class populated with data from the config
create
(Config
source of config information
config
,
Class<T>
class to be instantiated
clazz
)

Creates an instance of a class, initializing its fields from a Config.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ConfigBeanFactoryback to summary
public ConfigBeanFactory()

Method Detail

createback to summary
public static <T> T create(Config config, Class<T> clazz)

Creates an instance of a class, initializing its fields from a Config. Example usage:

Config configSource = ConfigFactory.load().getConfig("foo");
FooConfig config = ConfigBeanFactory.create(configSource, FooConfig.class);
The Java class should follow JavaBean conventions. Field types can be any of the types you can normally get from a Config, including java.time.Duration or ConfigMemorySize. Fields may also be another JavaBean-style class. Fields are mapped to config by converting the config key to camel case. So the key foo-bar becomes JavaBean setter setFooBar.
Parameters
<T>
the type of the class to be instantiated
config:Config

source of config information

clazz:Class<T>

class to be instantiated

Returns:T

an instance of the class populated with data from the config

Exceptions
BadBean:
If something is wrong with the JavaBean
ValidationFailed:
If the config doesn't conform to the bean's implied schema
ConfigException:
Can throw the same exceptions as the getters on Config
Since
1.3.0