- 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)ConfigParserimplementation that supports following media types: "application/hocon" and "application/json".The parser implementation supports
ServiceLoader, i.e.Config.Buildercan automatically load and registerHoconConfigParserinstance, if notdisabled. And of course it can beregistered programmatically.Priority of the
HoconConfigParserto 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 StringMEDIA_TYPE_APPLICATION_HOCONA String constant representing "application/hocon" media type.static StringMEDIA_TYPE_APPLICATION_JSONA String constant representing "application/json" media type.static intPRIORITYPriority of the parser used if registered byConfig.Builderautomatically.
-
Constructor Summary
Constructors Constructor Description HoconConfigParser()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static HoconConfigParserBuilderbuilder()Create a new fluent API builder for a HOCON config parser.static HoconConfigParsercreate()Create a new instance of HOCON config parser using default configuration.ConfigNode.ObjectNodeparse(ConfigParser.Content content)Parses a specifiedConfigContentinto ahierarchical configuration representation.ConfigNode.ObjectNodeparse(ConfigParser.Content content, Function<String,Optional<InputStream>> relativeResolver)Parses a specifiedConfigContentinto 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.Builderautomatically.- 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:ConfigParserReturns 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.
ParsableSourceimplementations can useMediaTypesto probe for media type of content to provide it to config system throughConfigParser.Content.Builder.mediaType(String).- Specified by:
supportedMediaTypesin interfaceConfigParser- Returns:
- supported media types by the parser
-
parse
public ConfigNode.ObjectNode parse(ConfigParser.Content content)
Description copied from interface:ConfigParserParses a specifiedConfigContentinto ahierarchical configuration representation.Never returns
null.- Specified by:
parsein 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:ConfigParserParses a specifiedConfigContentinto ahierarchical configuration representation.Never returns
null.- Specified by:
parsein 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:ConfigParserConfig parser can define supported file suffixes. If such are defined, Helidon will use these to discover default configuration sources. For example if there is aConfigParserthat returnsxml, config would look formeta-config.xmlto discover meta configuration, and forapplication.xmlon 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:
supportedSuffixesin interfaceConfigParser- Returns:
- a set of file suffixes supported by this config parser.
-
-