- java.lang.Object
-
- io.helidon.config.hocon.HoconConfigParser
-
- All Implemented Interfaces:
ConfigParser
@Priority(200) public class HoconConfigParser extends Object implements ConfigParser
Typesafe (Lightbend) Config (HOCON)ConfigParser
implementation that supports following media types: "application/hocon" and "application/json".The parser implementation supports
ServiceLoader
, i.e.Config.Builder
can automatically load and registerHoconConfigParser
instance, if notdisabled
. And of course it can beregistered programmatically
.Priority of the
HoconConfigParser
to be used byConfig.Builder
, if loaded automatically as aservice
, is 200.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.helidon.config.spi.ConfigParser
ConfigParser.Content
-
-
Field Summary
Fields Modifier and Type Field Description static String
MEDIA_TYPE_APPLICATION_HOCON
A String constant representing "application/hocon" media type.static String
MEDIA_TYPE_APPLICATION_JSON
A String constant representing "application/json" media type.static int
PRIORITY
Priority of the parser used if registered byConfig.Builder
automatically.
-
Constructor Summary
Constructors Constructor Description HoconConfigParser()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static HoconConfigParserBuilder
builder()
Create a new fluent API builder for a HOCON config parser.static HoconConfigParser
create()
Create a new instance of HOCON config parser using default configuration.ConfigNode.ObjectNode
parse(ConfigParser.Content content)
Parses a specifiedConfigContent
into ahierarchical configuration representation
.ConfigNode.ObjectNode
parse(ConfigParser.Content content, Function<String,Optional<InputStream>> relativeResolver)
Parses a specifiedConfigContent
into ahierarchical configuration representation
.Set<String>
supportedMediaTypes()
Returns set of supported media types by the parser.List<String>
supportedSuffixes()
Config parser can define supported file suffixes.
-
-
-
Field Detail
-
MEDIA_TYPE_APPLICATION_HOCON
public static final String MEDIA_TYPE_APPLICATION_HOCON
A String constant representing "application/hocon" media type.- See Also:
- Constant Field Values
-
MEDIA_TYPE_APPLICATION_JSON
public static final String MEDIA_TYPE_APPLICATION_JSON
A String constant representing "application/json" media type.- See Also:
- Constant Field Values
-
PRIORITY
public static final int PRIORITY
Priority of the parser used if registered byConfig.Builder
automatically.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HoconConfigParser
@Deprecated public HoconConfigParser()
Deprecated.To be used by Java Service Loader only!!!
-
-
Method Detail
-
create
public static HoconConfigParser create()
Create a new instance of HOCON config parser using default configuration.- Returns:
- a new instance of parser
- See Also:
builder()
-
builder
public static HoconConfigParserBuilder builder()
Create a new fluent API builder for a HOCON config parser.- Returns:
- a new builder instance
-
supportedMediaTypes
public Set<String> supportedMediaTypes()
Description copied from interface:ConfigParser
Returns set of supported media types by the parser.Set of supported media types is used when config system looks for appropriate parser based on media type of content.
ParsableSource
implementations can useMediaTypes
to probe for media type of content to provide it to config system throughConfigParser.Content.Builder.mediaType(String)
.- Specified by:
supportedMediaTypes
in interfaceConfigParser
- Returns:
- supported media types by the parser
-
parse
public ConfigNode.ObjectNode parse(ConfigParser.Content content)
Description copied from interface:ConfigParser
Parses a specifiedConfigContent
into ahierarchical configuration representation
.Never returns
null
.- Specified by:
parse
in interfaceConfigParser
- Parameters:
content
- a content to be parsed- Returns:
- parsed hierarchical configuration representation
-
parse
public ConfigNode.ObjectNode parse(ConfigParser.Content content, Function<String,Optional<InputStream>> relativeResolver)
Description copied from interface:ConfigParser
Parses a specifiedConfigContent
into ahierarchical configuration representation
.Never returns
null
.- Specified by:
parse
in interfaceConfigParser
- Parameters:
content
- a content to be parsedrelativeResolver
- function to resolve relative resources to this resource (if supported by the source)- Returns:
- parsed hierarchical configuration representation
-
supportedSuffixes
public List<String> supportedSuffixes()
Description copied from interface:ConfigParser
Config parser can define supported file suffixes. If such are defined, Helidon will use these to discover default configuration sources. For example if there is aConfigParser
that returnsxml
, config would look formeta-config.xml
to discover meta configuration, and forapplication.xml
on file system and on classpath to discover configuration files.Note that the suffixes must resolve into a media type supported by a config parser (see
MediaTypes.detectExtensionType(String)
).- Specified by:
supportedSuffixes
in interfaceConfigParser
- Returns:
- a set of file suffixes supported by this config parser.
-
-