hocon 0.0.7 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +4 -2
  3. data/lib/hocon.rb +2 -0
  4. data/lib/hocon/config.rb +1010 -0
  5. data/lib/hocon/config_error.rb +32 -2
  6. data/lib/hocon/config_factory.rb +46 -0
  7. data/lib/hocon/config_include_context.rb +49 -0
  8. data/lib/hocon/config_includer_file.rb +27 -0
  9. data/lib/hocon/config_list.rb +49 -0
  10. data/lib/hocon/config_mergeable.rb +74 -0
  11. data/lib/hocon/config_object.rb +144 -1
  12. data/lib/hocon/config_parse_options.rb +33 -9
  13. data/lib/hocon/config_parseable.rb +51 -0
  14. data/lib/hocon/config_render_options.rb +4 -2
  15. data/lib/hocon/config_resolve_options.rb +31 -0
  16. data/lib/hocon/config_syntax.rb +5 -2
  17. data/lib/hocon/config_util.rb +73 -0
  18. data/lib/hocon/config_value.rb +122 -0
  19. data/lib/hocon/config_value_factory.rb +66 -2
  20. data/lib/hocon/config_value_type.rb +5 -2
  21. data/lib/hocon/impl.rb +2 -0
  22. data/lib/hocon/impl/abstract_config_node.rb +29 -0
  23. data/lib/hocon/impl/abstract_config_node_value.rb +11 -0
  24. data/lib/hocon/impl/abstract_config_object.rb +148 -42
  25. data/lib/hocon/impl/abstract_config_value.rb +251 -11
  26. data/lib/hocon/impl/array_iterator.rb +19 -0
  27. data/lib/hocon/impl/config_boolean.rb +7 -1
  28. data/lib/hocon/impl/config_concatenation.rb +177 -28
  29. data/lib/hocon/impl/config_delayed_merge.rb +329 -0
  30. data/lib/hocon/impl/config_delayed_merge_object.rb +274 -0
  31. data/lib/hocon/impl/config_document_parser.rb +647 -0
  32. data/lib/hocon/impl/config_double.rb +44 -0
  33. data/lib/hocon/impl/config_impl.rb +143 -19
  34. data/lib/hocon/impl/config_impl_util.rb +18 -0
  35. data/lib/hocon/impl/config_include_kind.rb +10 -0
  36. data/lib/hocon/impl/config_int.rb +13 -1
  37. data/lib/hocon/impl/config_node_array.rb +11 -0
  38. data/lib/hocon/impl/config_node_comment.rb +19 -0
  39. data/lib/hocon/impl/config_node_complex_value.rb +54 -0
  40. data/lib/hocon/impl/config_node_concatenation.rb +11 -0
  41. data/lib/hocon/impl/config_node_field.rb +81 -0
  42. data/lib/hocon/impl/config_node_include.rb +33 -0
  43. data/lib/hocon/impl/config_node_object.rb +276 -0
  44. data/lib/hocon/impl/config_node_path.rb +48 -0
  45. data/lib/hocon/impl/config_node_root.rb +60 -0
  46. data/lib/hocon/impl/config_node_simple_value.rb +42 -0
  47. data/lib/hocon/impl/config_node_single_token.rb +17 -0
  48. data/lib/hocon/impl/config_null.rb +15 -7
  49. data/lib/hocon/impl/config_number.rb +43 -4
  50. data/lib/hocon/impl/config_parser.rb +403 -0
  51. data/lib/hocon/impl/config_reference.rb +142 -0
  52. data/lib/hocon/impl/config_string.rb +55 -7
  53. data/lib/hocon/impl/container.rb +29 -0
  54. data/lib/hocon/impl/default_transformer.rb +24 -15
  55. data/lib/hocon/impl/from_map_mode.rb +3 -1
  56. data/lib/hocon/impl/full_includer.rb +2 -0
  57. data/lib/hocon/impl/memo_key.rb +42 -0
  58. data/lib/hocon/impl/mergeable_value.rb +8 -0
  59. data/lib/hocon/impl/origin_type.rb +8 -2
  60. data/lib/hocon/impl/parseable.rb +455 -91
  61. data/lib/hocon/impl/path.rb +181 -59
  62. data/lib/hocon/impl/path_builder.rb +24 -3
  63. data/lib/hocon/impl/path_parser.rb +280 -0
  64. data/lib/hocon/impl/replaceable_merge_stack.rb +22 -0
  65. data/lib/hocon/impl/resolve_context.rb +254 -0
  66. data/lib/hocon/impl/resolve_memos.rb +21 -0
  67. data/lib/hocon/impl/resolve_result.rb +39 -0
  68. data/lib/hocon/impl/resolve_source.rb +354 -0
  69. data/lib/hocon/impl/resolve_status.rb +3 -1
  70. data/lib/hocon/impl/simple_config.rb +264 -10
  71. data/lib/hocon/impl/simple_config_document.rb +48 -0
  72. data/lib/hocon/impl/simple_config_list.rb +282 -8
  73. data/lib/hocon/impl/simple_config_object.rb +424 -88
  74. data/lib/hocon/impl/simple_config_origin.rb +263 -71
  75. data/lib/hocon/impl/simple_include_context.rb +31 -1
  76. data/lib/hocon/impl/simple_includer.rb +196 -1
  77. data/lib/hocon/impl/substitution_expression.rb +38 -0
  78. data/lib/hocon/impl/token.rb +17 -4
  79. data/lib/hocon/impl/token_type.rb +6 -2
  80. data/lib/hocon/impl/tokenizer.rb +339 -109
  81. data/lib/hocon/impl/tokens.rb +330 -79
  82. data/lib/hocon/impl/unmergeable.rb +14 -1
  83. data/lib/hocon/impl/unsupported_operation_error.rb +6 -0
  84. data/lib/hocon/impl/url.rb +37 -0
  85. data/lib/hocon/parser.rb +7 -0
  86. data/lib/hocon/parser/config_document.rb +92 -0
  87. data/lib/hocon/parser/config_document_factory.rb +36 -0
  88. data/lib/hocon/parser/config_node.rb +30 -0
  89. metadata +67 -43
  90. data/lib/hocon/impl/config_float.rb +0 -13
  91. data/lib/hocon/impl/parser.rb +0 -977
  92. data/lib/hocon/impl/properties_parser.rb +0 -83
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8d1d8c906c6a713c9f0e3c005449b4f27f43de4d
4
+ data.tar.gz: 81828db454ff9ec38b722b3245309c42dfd521be
5
+ SHA512:
6
+ metadata.gz: bceacdf280b8674be1d2c0019d365920cf7edffd303e76a19ba51eb2b77bbe4ac759f9b9675f650bb321be65b1be853d98da8bfd92880c90ec32c538a27443e7
7
+ data.tar.gz: bd795df60b8d4297d96b79e4ba80db4cb1248828fb00db15fb3886a6f8e6a316fe6c49280cbf57436d29d9ce5a639435f3d18186571389343d73c19282f3f533
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Build Status](https://travis-ci.org/puppetlabs/ruby-hocon.png?branch=master)](https://travis-ci.org/puppetlabs/ruby-hocon)
2
+
1
3
  ruby-hocon
2
4
  ==========
3
5
 
@@ -5,7 +7,7 @@ This is a port of the [Typesafe Config](https://github.com/typesafehub/config) l
5
7
 
6
8
  The library provides Ruby support for the [HOCON](https://github.com/typesafehub/config/blob/master/HOCON.md) configuration file format.
7
9
 
8
- At present, the only features it supports are explicit parsing of config files (.conf/HOCON, .json, .properties) via `ConfigFactory.parse_file`, and rendering a parsed config object back to a String. Testing is minimal and not all data types are supported yet. It also does not yet support `include` or interpolated settings.
10
+ At present, the only features it supports are explicit parsing of config files (.conf/HOCON, .json) via `ConfigFactory.parse_file`, and rendering a parsed config object back to a String. Testing is minimal and not all data types are supported yet. It also does not yet support `include` or interpolated settings.
9
11
  PLEASE NOTE that as a result this project is in a very experimental state, and in some cases may not work properly, so
10
12
  please be wary when using it. If you find a problem, feel free to open a github issue.
11
13
 
@@ -31,5 +33,5 @@ Testing
31
33
 
32
34
  ```sh
33
35
  bundle install
34
- bundle exec rake spec
36
+ bundle exec rspec spec
35
37
  ```
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Hocon
2
4
  require 'hocon/config_factory'
3
5
 
@@ -0,0 +1,1010 @@
1
+ # encoding: utf-8
2
+
3
+ require 'hocon'
4
+ require 'hocon/config_mergeable'
5
+ require 'hocon/config_error'
6
+
7
+ #
8
+ # An immutable map from config paths to config values. Paths are dot-separated
9
+ # expressions such as <code>foo.bar.baz</code>. Values are as in JSON
10
+ # (booleans, strings, numbers, lists, or objects), represented by
11
+ # {@link ConfigValue} instances. Values accessed through the
12
+ # <code>Config</code> interface are never null.
13
+ #
14
+ # <p>
15
+ # {@code Config} is an immutable object and thus safe to use from multiple
16
+ # threads. There's never a need for "defensive copies."
17
+ #
18
+ # <p>
19
+ # Fundamental operations on a {@code Config} include getting configuration
20
+ # values, <em>resolving</em> substitutions with {@link Config#resolve()}, and
21
+ # merging configs using {@link Config#withFallback(ConfigMergeable)}.
22
+ #
23
+ # <p>
24
+ # All operations return a new immutable {@code Config} rather than modifying
25
+ # the original instance.
26
+ #
27
+ # <p>
28
+ # <strong>Examples</strong>
29
+ #
30
+ # <p>
31
+ # You can find an example app and library <a
32
+ # href="https://github.com/typesafehub/config/tree/master/examples">on
33
+ # GitHub</a>. Also be sure to read the <a
34
+ # href="package-summary.html#package_description">package overview</a> which
35
+ # describes the big picture as shown in those examples.
36
+ #
37
+ # <p>
38
+ # <strong>Paths, keys, and Config vs. ConfigObject</strong>
39
+ #
40
+ # <p>
41
+ # <code>Config</code> is a view onto a tree of {@link ConfigObject}; the
42
+ # corresponding object tree can be found through {@link Config#root()}.
43
+ # <code>ConfigObject</code> is a map from config <em>keys</em>, rather than
44
+ # paths, to config values. Think of <code>ConfigObject</code> as a JSON object
45
+ # and <code>Config</code> as a configuration API.
46
+ #
47
+ # <p>
48
+ # The API tries to consistently use the terms "key" and "path." A key is a key
49
+ # in a JSON object; it's just a string that's the key in a map. A "path" is a
50
+ # parseable expression with a syntax and it refers to a series of keys. Path
51
+ # expressions are described in the <a
52
+ # href="https://github.com/typesafehub/config/blob/master/HOCON.md">spec for
53
+ # Human-Optimized Config Object Notation</a>. In brief, a path is
54
+ # period-separated so "a.b.c" looks for key c in object b in object a in the
55
+ # root object. Sometimes double quotes are needed around special characters in
56
+ # path expressions.
57
+ #
58
+ # <p>
59
+ # The API for a {@code Config} is in terms of path expressions, while the API
60
+ # for a {@code ConfigObject} is in terms of keys. Conceptually, {@code Config}
61
+ # is a one-level map from <em>paths</em> to values, while a
62
+ # {@code ConfigObject} is a tree of nested maps from <em>keys</em> to values.
63
+ #
64
+ # <p>
65
+ # Use {@link ConfigUtil#joinPath} and {@link ConfigUtil#splitPath} to convert
66
+ # between path expressions and individual path elements (keys).
67
+ #
68
+ # <p>
69
+ # Another difference between {@code Config} and {@code ConfigObject} is that
70
+ # conceptually, {@code ConfigValue}s with a {@link ConfigValue#valueType()
71
+ # valueType()} of {@link ConfigValueType#NULL NULL} exist in a
72
+ # {@code ConfigObject}, while a {@code Config} treats null values as if they
73
+ # were missing.
74
+ #
75
+ # <p>
76
+ # <strong>Getting configuration values</strong>
77
+ #
78
+ # <p>
79
+ # The "getters" on a {@code Config} all work in the same way. They never return
80
+ # null, nor do they return a {@code ConfigValue} with
81
+ # {@link ConfigValue#valueType() valueType()} of {@link ConfigValueType#NULL
82
+ # NULL}. Instead, they throw {@link ConfigException.Missing} if the value is
83
+ # completely absent or set to null. If the value is set to null, a subtype of
84
+ # {@code ConfigException.Missing} called {@link ConfigException.Null} will be
85
+ # thrown. {@link ConfigException.WrongType} will be thrown anytime you ask for
86
+ # a type and the value has an incompatible type. Reasonable type conversions
87
+ # are performed for you though.
88
+ #
89
+ # <p>
90
+ # <strong>Iteration</strong>
91
+ #
92
+ # <p>
93
+ # If you want to iterate over the contents of a {@code Config}, you can get its
94
+ # {@code ConfigObject} with {@link #root()}, and then iterate over the
95
+ # {@code ConfigObject} (which implements <code>java.util.Map</code>). Or, you
96
+ # can use {@link #entrySet()} which recurses the object tree for you and builds
97
+ # up a <code>Set</code> of all path-value pairs where the value is not null.
98
+ #
99
+ # <p>
100
+ # <strong>Resolving substitutions</strong>
101
+ #
102
+ # <p>
103
+ # <em>Substitutions</em> are the <code>${foo.bar}</code> syntax in config
104
+ # files, described in the <a href=
105
+ # "https://github.com/typesafehub/config/blob/master/HOCON.md#substitutions"
106
+ # >specification</a>. Resolving substitutions replaces these references with real
107
+ # values.
108
+ #
109
+ # <p>
110
+ # Before using a {@code Config} it's necessary to call {@link Config#resolve()}
111
+ # to handle substitutions (though {@link ConfigFactory#load()} and similar
112
+ # methods will do the resolve for you already).
113
+ #
114
+ # <p>
115
+ # <strong>Merging</strong>
116
+ #
117
+ # <p>
118
+ # The full <code>Config</code> for your application can be constructed using
119
+ # the associative operation {@link Config#withFallback(ConfigMergeable)}. If
120
+ # you use {@link ConfigFactory#load()} (recommended), it merges system
121
+ # properties over the top of <code>application.conf</code> over the top of
122
+ # <code>reference.conf</code>, using <code>withFallback</code>. You can add in
123
+ # additional sources of configuration in the same way (usually, custom layers
124
+ # should go either just above or just below <code>application.conf</code>,
125
+ # keeping <code>reference.conf</code> at the bottom and system properties at
126
+ # the top).
127
+ #
128
+ # <p>
129
+ # <strong>Serialization</strong>
130
+ #
131
+ # <p>
132
+ # Convert a <code>Config</code> to a JSON or HOCON string by calling
133
+ # {@link ConfigObject#render()} on the root object,
134
+ # <code>myConfig.root().render()</code>. There's also a variant
135
+ # {@link ConfigObject#render(ConfigRenderOptions)} which allows you to control
136
+ # the format of the rendered string. (See {@link ConfigRenderOptions}.) Note
137
+ # that <code>Config</code> does not remember the formatting of the original
138
+ # file, so if you load, modify, and re-save a config file, it will be
139
+ # substantially reformatted.
140
+ #
141
+ # <p>
142
+ # As an alternative to {@link ConfigObject#render()}, the
143
+ # <code>toString()</code> method produces a debug-output-oriented
144
+ # representation (which is not valid JSON).
145
+ #
146
+ # <p>
147
+ # Java serialization is supported as well for <code>Config</code> and all
148
+ # subtypes of <code>ConfigValue</code>.
149
+ #
150
+ # <p>
151
+ # <strong>This is an interface but don't implement it yourself</strong>
152
+ #
153
+ # <p>
154
+ # <em>Do not implement {@code Config}</em>; it should only be implemented by
155
+ # the config library. Arbitrary implementations will not work because the
156
+ # library internals assume a specific concrete implementation. Also, this
157
+ # interface is likely to grow new methods over time, so third-party
158
+ # implementations will break.
159
+ #
160
+ class Config < Hocon::ConfigMergeable
161
+ #
162
+ # Gets the {@code Config} as a tree of {@link ConfigObject}. This is a
163
+ # constant-time operation (it is not proportional to the number of values
164
+ # in the {@code Config}).
165
+ #
166
+ # @return the root object in the configuration
167
+ #
168
+ def root
169
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `root` (#{self.class})"
170
+ end
171
+
172
+ #
173
+ # Gets the origin of the {@code Config}, which may be a file, or a file
174
+ # with a line number, or just a descriptive phrase.
175
+ #
176
+ # @return the origin of the {@code Config} for use in error messages
177
+ #
178
+ def origin
179
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `origin` (#{self.class})"
180
+ end
181
+
182
+ def with_fallback(other)
183
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `with_fallback` (#{self.class})"
184
+ end
185
+
186
+ #
187
+ # Returns a replacement config with all substitutions (the
188
+ # <code>${foo.bar}</code> syntax, see <a
189
+ # href="https://github.com/typesafehub/config/blob/master/HOCON.md">the
190
+ # spec</a>) resolved. Substitutions are looked up using this
191
+ # <code>Config</code> as the root object, that is, a substitution
192
+ # <code>${foo.bar}</code> will be replaced with the result of
193
+ # <code>getValue("foo.bar")</code>.
194
+ #
195
+ # <p>
196
+ # This method uses {@link ConfigResolveOptions#defaults()}, there is
197
+ # another variant {@link Config#resolve(ConfigResolveOptions)} which lets
198
+ # you specify non-default options.
199
+ #
200
+ # <p>
201
+ # A given {@link Config} must be resolved before using it to retrieve
202
+ # config values, but ideally should be resolved one time for your entire
203
+ # stack of fallbacks (see {@link Config#withFallback}). Otherwise, some
204
+ # substitutions that could have resolved with all fallbacks available may
205
+ # not resolve, which will be potentially confusing for your application's
206
+ # users.
207
+ #
208
+ # <p>
209
+ # <code>resolve()</code> should be invoked on root config objects, rather
210
+ # than on a subtree (a subtree is the result of something like
211
+ # <code>config.getConfig("foo")</code>). The problem with
212
+ # <code>resolve()</code> on a subtree is that substitutions are relative to
213
+ # the root of the config and the subtree will have no way to get values
214
+ # from the root. For example, if you did
215
+ # <code>config.getConfig("foo").resolve()</code> on the below config file,
216
+ # it would not work:
217
+ #
218
+ # <pre>
219
+ # common-value = 10
220
+ # foo {
221
+ # whatever = ${common-value}
222
+ # }
223
+ # </pre>
224
+ #
225
+ # <p>
226
+ # Many methods on {@link ConfigFactory} such as
227
+ # {@link ConfigFactory#load()} automatically resolve the loaded
228
+ # <code>Config</code> on the loaded stack of config files.
229
+ #
230
+ # <p>
231
+ # Resolving an already-resolved config is a harmless no-op, but again, it
232
+ # is best to resolve an entire stack of fallbacks (such as all your config
233
+ # files combined) rather than resolving each one individually.
234
+ #
235
+ # @return an immutable object with substitutions resolved
236
+ # @throws ConfigException.UnresolvedSubstitution
237
+ # if any substitutions refer to nonexistent paths
238
+ # @throws ConfigException
239
+ # some other config exception if there are other problems
240
+ #
241
+ def resolve(options)
242
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `resolve` (#{self.class})"
243
+ end
244
+
245
+ #
246
+ # Checks whether the config is completely resolved. After a successful call
247
+ # to {@link Config#resolve()} it will be completely resolved, but after
248
+ # calling {@link Config#resolve(ConfigResolveOptions)} with
249
+ # <code>allowUnresolved</code> set in the options, it may or may not be
250
+ # completely resolved. A newly-loaded config may or may not be completely
251
+ # resolved depending on whether there were substitutions present in the
252
+ # file.
253
+ #
254
+ # @return true if there are no unresolved substitutions remaining in this
255
+ # configuration.
256
+ # @since 1.2.0
257
+ #
258
+ def resolved?
259
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `resolved?` (#{self.class})"
260
+ end
261
+
262
+ #
263
+ # Like {@link Config#resolveWith(Config)} but allows you to specify
264
+ # non-default options.
265
+ #
266
+ # @param source
267
+ # source configuration to pull values from
268
+ # @param options
269
+ # resolve options
270
+ # @return the resolved <code>Config</code> (may be only partially resolved
271
+ # if options are set to allow unresolved)
272
+ # @since 1.2.0
273
+ #
274
+ def resolve_with(source, options)
275
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `resolve_with` (#{self.class})"
276
+ end
277
+
278
+ #
279
+ # Validates this config against a reference config, throwing an exception
280
+ # if it is invalid. The purpose of this method is to "fail early" with a
281
+ # comprehensive list of problems; in general, anything this method can find
282
+ # would be detected later when trying to use the config, but it's often
283
+ # more user-friendly to fail right away when loading the config.
284
+ #
285
+ # <p>
286
+ # Using this method is always optional, since you can "fail late" instead.
287
+ #
288
+ # <p>
289
+ # You must restrict validation to paths you "own" (those whose meaning are
290
+ # defined by your code module). If you validate globally, you may trigger
291
+ # errors about paths that happen to be in the config but have nothing to do
292
+ # with your module. It's best to allow the modules owning those paths to
293
+ # validate them. Also, if every module validates only its own stuff, there
294
+ # isn't as much redundant work being done.
295
+ #
296
+ # <p>
297
+ # If no paths are specified in <code>checkValid()</code>'s parameter list,
298
+ # validation is for the entire config.
299
+ #
300
+ # <p>
301
+ # If you specify paths that are not in the reference config, those paths
302
+ # are ignored. (There's nothing to validate.)
303
+ #
304
+ # <p>
305
+ # Here's what validation involves:
306
+ #
307
+ # <ul>
308
+ # <li>All paths found in the reference config must be present in this
309
+ # config or an exception will be thrown.
310
+ # <li>
311
+ # Some changes in type from the reference config to this config will cause
312
+ # an exception to be thrown. Not all potential type problems are detected,
313
+ # in particular it's assumed that strings are compatible with everything
314
+ # except objects and lists. This is because string types are often "really"
315
+ # some other type (system properties always start out as strings, or a
316
+ # string like "5ms" could be used with {@link #getMilliseconds}). Also,
317
+ # it's allowed to set any type to null or override null with any type.
318
+ # <li>
319
+ # Any unresolved substitutions in this config will cause a validation
320
+ # failure; both the reference config and this config should be resolved
321
+ # before validation. If the reference config is unresolved, it's a bug in
322
+ # the caller of this method.
323
+ # </ul>
324
+ #
325
+ # <p>
326
+ # If you want to allow a certain setting to have a flexible type (or
327
+ # otherwise want validation to be looser for some settings), you could
328
+ # either remove the problematic setting from the reference config provided
329
+ # to this method, or you could intercept the validation exception and
330
+ # screen out certain problems. Of course, this will only work if all other
331
+ # callers of this method are careful to restrict validation to their own
332
+ # paths, as they should be.
333
+ #
334
+ # <p>
335
+ # If validation fails, the thrown exception contains a list of all problems
336
+ # found. See {@link ConfigException.ValidationFailed#problems}. The
337
+ # exception's <code>getMessage()</code> will have all the problems
338
+ # concatenated into one huge string, as well.
339
+ #
340
+ # <p>
341
+ # Again, <code>checkValid()</code> can't guess every domain-specific way a
342
+ # setting can be invalid, so some problems may arise later when attempting
343
+ # to use the config. <code>checkValid()</code> is limited to reporting
344
+ # generic, but common, problems such as missing settings and blatant type
345
+ # incompatibilities.
346
+ #
347
+ # @param reference
348
+ # a reference configuration
349
+ # @param restrictToPaths
350
+ # only validate values underneath these paths that your code
351
+ # module owns and understands
352
+ # @throws ConfigException.ValidationFailed
353
+ # if there are any validation issues
354
+ # @throws ConfigException.NotResolved
355
+ # if this config is not resolved
356
+ # @throws ConfigException.BugOrBroken
357
+ # if the reference config is unresolved or caller otherwise
358
+ # misuses the API
359
+ #
360
+ def check_valid(reference, restrict_to_paths)
361
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `check_valid` (#{self.class})"
362
+ end
363
+
364
+ #
365
+ # Checks whether a value is present and non-null at the given path. This
366
+ # differs in two ways from {@code Map.containsKey()} as implemented by
367
+ # {@link ConfigObject}: it looks for a path expression, not a key; and it
368
+ # returns false for null values, while {@code containsKey()} returns true
369
+ # indicating that the object contains a null value for the key.
370
+ #
371
+ # <p>
372
+ # If a path exists according to {@link #hasPath(String)}, then
373
+ # {@link #getValue(String)} will never throw an exception. However, the
374
+ # typed getters, such as {@link #getInt(String)}, will still throw if the
375
+ # value is not convertible to the requested type.
376
+ #
377
+ # <p>
378
+ # Note that path expressions have a syntax and sometimes require quoting
379
+ # (see {@link ConfigUtil#joinPath} and {@link ConfigUtil#splitPath}).
380
+ #
381
+ # @param path
382
+ # the path expression
383
+ # @return true if a non-null value is present at the path
384
+ # @throws ConfigException.BadPath
385
+ # if the path expression is invalid
386
+ #
387
+ def has_path(path)
388
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `has_path` (#{self.class})"
389
+ end
390
+
391
+ #
392
+ # Returns true if the {@code Config}'s root object contains no key-value
393
+ # pairs.
394
+ #
395
+ # @return true if the configuration is empty
396
+ #
397
+ def empty?
398
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `empty` (#{self.class})"
399
+ end
400
+
401
+ #
402
+ # Returns the set of path-value pairs, excluding any null values, found by
403
+ # recursing {@link #root() the root object}. Note that this is very
404
+ # different from <code>root().entrySet()</code> which returns the set of
405
+ # immediate-child keys in the root object and includes null values.
406
+ # <p>
407
+ # Entries contain <em>path expressions</em> meaning there may be quoting
408
+ # and escaping involved. Parse path expressions with
409
+ # {@link ConfigUtil#splitPath}.
410
+ # <p>
411
+ # Because a <code>Config</code> is conceptually a single-level map from
412
+ # paths to values, there will not be any {@link ConfigObject} values in the
413
+ # entries (that is, all entries represent leaf nodes). Use
414
+ # {@link ConfigObject} rather than <code>Config</code> if you want a tree.
415
+ # (OK, this is a slight lie: <code>Config</code> entries may contain
416
+ # {@link ConfigList} and the lists may contain objects. But no objects are
417
+ # directly included as entry values.)
418
+ #
419
+ # @return set of paths with non-null values, built up by recursing the
420
+ # entire tree of {@link ConfigObject} and creating an entry for
421
+ # each leaf value.
422
+ #
423
+ def entry_set
424
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `entry_set` (#{self.class})"
425
+ end
426
+
427
+ #
428
+ #
429
+ # @param path
430
+ # path expression
431
+ # @return the boolean value at the requested path
432
+ # @throws ConfigException.Missing
433
+ # if value is absent or null
434
+ # @throws ConfigException.WrongType
435
+ # if value is not convertible to boolean
436
+ #
437
+ def get_boolean(path)
438
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `get_boolean` (#{self.class})"
439
+ end
440
+
441
+ #
442
+ # @param path
443
+ # path expression
444
+ # @return the numeric value at the requested path
445
+ # @throws ConfigException.Missing
446
+ # if value is absent or null
447
+ # @throws ConfigException.WrongType
448
+ # if value is not convertible to a number
449
+ #
450
+ def get_number(path)
451
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `get_number` (#{self.class})"
452
+ end
453
+
454
+ #
455
+ # Gets the integer at the given path. If the value at the
456
+ # path has a fractional (floating point) component, it
457
+ # will be discarded and only the integer part will be
458
+ # returned (it works like a "narrowing primitive conversion"
459
+ # in the Java language specification).
460
+ #
461
+ # @param path
462
+ # path expression
463
+ # @return the 32-bit integer value at the requested path
464
+ # @throws ConfigException.Missing
465
+ # if value is absent or null
466
+ # @throws ConfigException.WrongType
467
+ # if value is not convertible to an int (for example it is out
468
+ # of range, or it's a boolean value)
469
+ #
470
+ def get_int(path)
471
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `get_int` (#{self.class})"
472
+ end
473
+
474
+
475
+ #
476
+ # Gets the long integer at the given path. If the value at
477
+ # the path has a fractional (floating point) component, it
478
+ # will be discarded and only the integer part will be
479
+ # returned (it works like a "narrowing primitive conversion"
480
+ # in the Java language specification).
481
+ #
482
+ # @param path
483
+ # path expression
484
+ # @return the 64-bit long value at the requested path
485
+ # @throws ConfigException.Missing
486
+ # if value is absent or null
487
+ # @throws ConfigException.WrongType
488
+ # if value is not convertible to a long
489
+ #
490
+ def get_long(path)
491
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `get_long` (#{self.class})"
492
+ end
493
+
494
+ #
495
+ # @param path
496
+ # path expression
497
+ # @return the floating-point value at the requested path
498
+ # @throws ConfigException.Missing
499
+ # if value is absent or null
500
+ # @throws ConfigException.WrongType
501
+ # if value is not convertible to a double
502
+ #
503
+ def get_double(path)
504
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `get_double` (#{self.class})"
505
+ end
506
+
507
+ #
508
+ # @param path
509
+ # path expression
510
+ # @return the string value at the requested path
511
+ # @throws ConfigException.Missing
512
+ # if value is absent or null
513
+ # @throws ConfigException.WrongType
514
+ # if value is not convertible to a string
515
+ #
516
+ def get_string(path)
517
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `get_string` (#{self.class})"
518
+ end
519
+
520
+ #
521
+ # @param path
522
+ # path expression
523
+ # @return the {@link ConfigObject} value at the requested path
524
+ # @throws ConfigException.Missing
525
+ # if value is absent or null
526
+ # @throws ConfigException.WrongType
527
+ # if value is not convertible to an object
528
+ #
529
+ def get_object(path)
530
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `get_object` (#{self.class})"
531
+ end
532
+
533
+ #
534
+ # @param path
535
+ # path expression
536
+ # @return the nested {@code Config} value at the requested path
537
+ # @throws ConfigException.Missing
538
+ # if value is absent or null
539
+ # @throws ConfigException.WrongType
540
+ # if value is not convertible to a Config
541
+ #
542
+ def get_config(path)
543
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `get_config` (#{self.class})"
544
+ end
545
+
546
+ #
547
+ # Gets the value at the path as an unwrapped Java boxed value (
548
+ # {@link java.lang.Boolean Boolean}, {@link java.lang.Integer Integer}, and
549
+ # so on - see {@link ConfigValue#unwrapped()}).
550
+ #
551
+ # @param path
552
+ # path expression
553
+ # @return the unwrapped value at the requested path
554
+ # @throws ConfigException.Missing
555
+ # if value is absent or null
556
+ #
557
+ def get_any_ref(path)
558
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `get_any_ref` (#{self.class})"
559
+ end
560
+
561
+ #
562
+ # Gets the value at the given path, unless the value is a
563
+ # null value or missing, in which case it throws just like
564
+ # the other getters. Use {@code get()} on the {@link
565
+ # Config#root()} object (or other object in the tree) if you
566
+ # want an unprocessed value.
567
+ #
568
+ # @param path
569
+ # path expression
570
+ # @return the value at the requested path
571
+ # @throws ConfigException.Missing
572
+ # if value is absent or null
573
+ #
574
+ def get_value(path)
575
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `get_value`path(#{self.class})"
576
+ end
577
+
578
+ #
579
+ # Gets a value as a size in bytes (parses special strings like "128M"). If
580
+ # the value is already a number, then it's left alone; if it's a string,
581
+ # it's parsed understanding unit suffixes such as "128K", as documented in
582
+ # the <a
583
+ # href="https://github.com/typesafehub/config/blob/master/HOCON.md">the
584
+ # spec</a>.
585
+ #
586
+ # @param path
587
+ # path expression
588
+ # @return the value at the requested path, in bytes
589
+ # @throws ConfigException.Missing
590
+ # if value is absent or null
591
+ # @throws ConfigException.WrongType
592
+ # if value is not convertible to Long or String
593
+ # @throws ConfigException.BadValue
594
+ # if value cannot be parsed as a size in bytes
595
+ #
596
+ def get_bytes(path)
597
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `get_bytes` (#{self.class})"
598
+ end
599
+
600
+ #
601
+ # Gets a value as an amount of memory (parses special strings like "128M"). If
602
+ # the value is already a number, then it's left alone; if it's a string,
603
+ # it's parsed understanding unit suffixes such as "128K", as documented in
604
+ # the <a
605
+ # href="https://github.com/typesafehub/config/blob/master/HOCON.md">the
606
+ # spec</a>.
607
+ #
608
+ # @since 1.3.0
609
+ #
610
+ # @param path
611
+ # path expression
612
+ # @return the value at the requested path, in bytes
613
+ # @throws ConfigException.Missing
614
+ # if value is absent or null
615
+ # @throws ConfigException.WrongType
616
+ # if value is not convertible to Long or String
617
+ # @throws ConfigException.BadValue
618
+ # if value cannot be parsed as a size in bytes
619
+ #
620
+ def get_memory_size(path)
621
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `get_memory_size`path(#{self.class})"
622
+ end
623
+
624
+ #
625
+ # Get value as a duration in milliseconds. If the value is already a
626
+ # number, then it's left alone; if it's a string, it's parsed understanding
627
+ # units suffixes like "10m" or "5ns" as documented in the <a
628
+ # href="https://github.com/typesafehub/config/blob/master/HOCON.md">the
629
+ # spec</a>.
630
+ #
631
+ # @deprecated As of release 1.1, replaced by {@link #getDuration(String, TimeUnit)}
632
+ #
633
+ # @param path
634
+ # path expression
635
+ # @return the duration value at the requested path, in milliseconds
636
+ # @throws ConfigException.Missing
637
+ # if value is absent or null
638
+ # @throws ConfigException.WrongType
639
+ # if value is not convertible to Long or String
640
+ # @throws ConfigException.BadValue
641
+ # if value cannot be parsed as a number of milliseconds
642
+ #
643
+ def get_milliseconds(path)
644
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `get_milliseconds` (#{self.class})"
645
+ end
646
+
647
+ #
648
+ # Get value as a duration in nanoseconds. If the value is already a number
649
+ # it's taken as milliseconds and converted to nanoseconds. If it's a
650
+ # string, it's parsed understanding unit suffixes, as for
651
+ # {@link #getDuration(String, TimeUnit)}.
652
+ #
653
+ # @deprecated As of release 1.1, replaced by {@link #getDuration(String, TimeUnit)}
654
+ #
655
+ # @param path
656
+ # path expression
657
+ # @return the duration value at the requested path, in nanoseconds
658
+ # @throws ConfigException.Missing
659
+ # if value is absent or null
660
+ # @throws ConfigException.WrongType
661
+ # if value is not convertible to Long or String
662
+ # @throws ConfigException.BadValue
663
+ # if value cannot be parsed as a number of nanoseconds
664
+ #
665
+ def get_nanoseconds(path)
666
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `get_nanoseconds` (#{self.class})"
667
+ end
668
+
669
+ #
670
+ # Gets a value as a duration in a specified
671
+ # {@link java.util.concurrent.TimeUnit TimeUnit}. If the value is already a
672
+ # number, then it's taken as milliseconds and then converted to the
673
+ # requested TimeUnit; if it's a string, it's parsed understanding units
674
+ # suffixes like "10m" or "5ns" as documented in the <a
675
+ # href="https://github.com/typesafehub/config/blob/master/HOCON.md">the
676
+ # spec</a>.
677
+ #
678
+ # @since 1.2.0
679
+ #
680
+ # @param path
681
+ # path expression
682
+ # @param unit
683
+ # convert the return value to this time unit
684
+ # @return the duration value at the requested path, in the given TimeUnit
685
+ # @throws ConfigException.Missing
686
+ # if value is absent or null
687
+ # @throws ConfigException.WrongType
688
+ # if value is not convertible to Long or String
689
+ # @throws ConfigException.BadValue
690
+ # if value cannot be parsed as a number of the given TimeUnit
691
+ #
692
+ def get_duration(path, unit)
693
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `get_duration` (#{self.class})"
694
+ end
695
+
696
+ #
697
+ # Gets a list value (with any element type) as a {@link ConfigList}, which
698
+ # implements {@code java.util.List<ConfigValue>}. Throws if the path is
699
+ # unset or null.
700
+ #
701
+ # @param path
702
+ # the path to the list value.
703
+ # @return the {@link ConfigList} at the path
704
+ # @throws ConfigException.Missing
705
+ # if value is absent or null
706
+ # @throws ConfigException.WrongType
707
+ # if value is not convertible to a ConfigList
708
+ #
709
+ def get_list(path)
710
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `get_list` (#{self.class})"
711
+ end
712
+
713
+ #
714
+ # Gets a list value with boolean elements. Throws if the
715
+ # path is unset or null or not a list or contains values not
716
+ # convertible to boolean.
717
+ #
718
+ # @param path
719
+ # the path to the list value.
720
+ # @return the list at the path
721
+ # @throws ConfigException.Missing
722
+ # if value is absent or null
723
+ # @throws ConfigException.WrongType
724
+ # if value is not convertible to a list of booleans
725
+ #
726
+ def get_boolean_list(path)
727
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `get_boolean_list` (#{self.class})"
728
+ end
729
+
730
+ #
731
+ # Gets a list value with number elements. Throws if the
732
+ # path is unset or null or not a list or contains values not
733
+ # convertible to number.
734
+ #
735
+ # @param path
736
+ # the path to the list value.
737
+ # @return the list at the path
738
+ # @throws ConfigException.Missing
739
+ # if value is absent or null
740
+ # @throws ConfigException.WrongType
741
+ # if value is not convertible to a list of numbers
742
+ #
743
+ def get_number_list(path)
744
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `get_number_list` (#{self.class})"
745
+ end
746
+
747
+ #
748
+ # Gets a list value with int elements. Throws if the
749
+ # path is unset or null or not a list or contains values not
750
+ # convertible to int.
751
+ #
752
+ # @param path
753
+ # the path to the list value.
754
+ # @return the list at the path
755
+ # @throws ConfigException.Missing
756
+ # if value is absent or null
757
+ # @throws ConfigException.WrongType
758
+ # if value is not convertible to a list of ints
759
+ #
760
+ def get_int_list(path)
761
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `get_int_list` (#{self.class})"
762
+ end
763
+
764
+ #
765
+ # Gets a list value with long elements. Throws if the
766
+ # path is unset or null or not a list or contains values not
767
+ # convertible to long.
768
+ #
769
+ # @param path
770
+ # the path to the list value.
771
+ # @return the list at the path
772
+ # @throws ConfigException.Missing
773
+ # if value is absent or null
774
+ # @throws ConfigException.WrongType
775
+ # if value is not convertible to a list of longs
776
+ #
777
+ def get_long_list(path)
778
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `get_long_list` (#{self.class})"
779
+ end
780
+
781
+ #
782
+ # Gets a list value with double elements. Throws if the
783
+ # path is unset or null or not a list or contains values not
784
+ # convertible to double.
785
+ #
786
+ # @param path
787
+ # the path to the list value.
788
+ # @return the list at the path
789
+ # @throws ConfigException.Missing
790
+ # if value is absent or null
791
+ # @throws ConfigException.WrongType
792
+ # if value is not convertible to a list of doubles
793
+ #
794
+ def get_double_list(path)
795
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `get_double_list` (#{self.class})"
796
+ end
797
+
798
+ #
799
+ # Gets a list value with string elements. Throws if the
800
+ # path is unset or null or not a list or contains values not
801
+ # convertible to string.
802
+ #
803
+ # @param path
804
+ # the path to the list value.
805
+ # @return the list at the path
806
+ # @throws ConfigException.Missing
807
+ # if value is absent or null
808
+ # @throws ConfigException.WrongType
809
+ # if value is not convertible to a list of strings
810
+ #
811
+ def get_string_list(path)
812
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `get_string_list` (#{self.class})"
813
+ end
814
+
815
+ #
816
+ # Gets a list value with object elements. Throws if the
817
+ # path is unset or null or not a list or contains values not
818
+ # convertible to <code>ConfigObject</code>.
819
+ #
820
+ # @param path
821
+ # the path to the list value.
822
+ # @return the list at the path
823
+ # @throws ConfigException.Missing
824
+ # if value is absent or null
825
+ # @throws ConfigException.WrongType
826
+ # if value is not convertible to a list of objects
827
+ #
828
+ def get_object_list(path)
829
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `get_object_list` (#{self.class})"
830
+ end
831
+
832
+ #
833
+ # Gets a list value with <code>Config</code> elements.
834
+ # Throws if the path is unset or null or not a list or
835
+ # contains values not convertible to <code>Config</code>.
836
+ #
837
+ # @param path
838
+ # the path to the list value.
839
+ # @return the list at the path
840
+ # @throws ConfigException.Missing
841
+ # if value is absent or null
842
+ # @throws ConfigException.WrongType
843
+ # if value is not convertible to a list of configs
844
+ #
845
+ def get_config_list(path)
846
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `get_config_list` (#{self.class})"
847
+ end
848
+
849
+ #
850
+ # Gets a list value with any kind of elements. Throws if the
851
+ # path is unset or null or not a list. Each element is
852
+ # "unwrapped" (see {@link ConfigValue#unwrapped()}).
853
+ #
854
+ # @param path
855
+ # the path to the list value.
856
+ # @return the list at the path
857
+ # @throws ConfigException.Missing
858
+ # if value is absent or null
859
+ # @throws ConfigException.WrongType
860
+ # if value is not convertible to a list
861
+ #
862
+ def get_any_ref_list(path)
863
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `get_any_ref_list`path(#{self.class})"
864
+ end
865
+
866
+ #
867
+ # Gets a list value with elements representing a size in
868
+ # bytes. Throws if the path is unset or null or not a list
869
+ # or contains values not convertible to memory sizes.
870
+ #
871
+ # @param path
872
+ # the path to the list value.
873
+ # @return the list at the path
874
+ # @throws ConfigException.Missing
875
+ # if value is absent or null
876
+ # @throws ConfigException.WrongType
877
+ # if value is not convertible to a list of memory sizes
878
+ #
879
+ def get_bytes_list(path)
880
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `get_bytes_list` (#{self.class})"
881
+ end
882
+
883
+ #
884
+ # Gets a list, converting each value in the list to a memory size, using the
885
+ # same rules as {@link #getMemorySize(String)}.
886
+ #
887
+ # @since 1.3.0
888
+ # @param path
889
+ # a path expression
890
+ # @return list of memory sizes
891
+ # @throws ConfigException.Missing
892
+ # if value is absent or null
893
+ # @throws ConfigException.WrongType
894
+ # if value is not convertible to a list of memory sizes
895
+ #
896
+ def get_memory_size_list(path)
897
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `get_memory_size_list` (#{self.class})"
898
+ end
899
+
900
+ #
901
+ # @deprecated As of release 1.1, replaced by {@link #getDurationList(String, TimeUnit)}
902
+ # @param path the path
903
+ # @return list of millisecond values
904
+ #
905
+ def get_milliseconds_list(path)
906
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `get_milliseconds_list` (#{self.class})"
907
+ end
908
+
909
+ #
910
+ # @deprecated As of release 1.1, replaced by {@link #getDurationList(String, TimeUnit)}
911
+ # @param path the path
912
+ # @return list of nanosecond values
913
+ #
914
+ def get_nanoseconds_list(path)
915
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `get_nanoseconds_list` (#{self.class})"
916
+ end
917
+
918
+ #
919
+ # Gets a list, converting each value in the list to a duration, using the
920
+ # same rules as {@link #getDuration(String, TimeUnit)}.
921
+ #
922
+ # @since 1.2.0
923
+ # @param path
924
+ # a path expression
925
+ # @param unit
926
+ # time units of the returned values
927
+ # @return list of durations, in the requested units
928
+ #
929
+ def get_duration_list(path, unit)
930
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `get_duration_list` (#{self.class})"
931
+ end
932
+
933
+ #
934
+ # Clone the config with only the given path (and its children) retained;
935
+ # all sibling paths are removed.
936
+ # <p>
937
+ # Note that path expressions have a syntax and sometimes require quoting
938
+ # (see {@link ConfigUtil#joinPath} and {@link ConfigUtil#splitPath}).
939
+ #
940
+ # @param path
941
+ # path to keep
942
+ # @return a copy of the config minus all paths except the one specified
943
+ #
944
+ def with_only_path(path)
945
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `with_only_path` (#{self.class})"
946
+ end
947
+
948
+ #
949
+ # Clone the config with the given path removed.
950
+ # <p>
951
+ # Note that path expressions have a syntax and sometimes require quoting
952
+ # (see {@link ConfigUtil#joinPath} and {@link ConfigUtil#splitPath}).
953
+ #
954
+ # @param path
955
+ # path expression to remove
956
+ # @return a copy of the config minus the specified path
957
+ #
958
+ def without_path(path)
959
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `without_path` (#{self.class})"
960
+ end
961
+
962
+ #
963
+ # Places the config inside another {@code Config} at the given path.
964
+ # <p>
965
+ # Note that path expressions have a syntax and sometimes require quoting
966
+ # (see {@link ConfigUtil#joinPath} and {@link ConfigUtil#splitPath}).
967
+ #
968
+ # @param path
969
+ # path expression to store this config at.
970
+ # @return a {@code Config} instance containing this config at the given
971
+ # path.
972
+ #
973
+ def at_path(path)
974
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `at_path` (#{self.class})"
975
+ end
976
+
977
+ #
978
+ # Places the config inside a {@code Config} at the given key. See also
979
+ # atPath(). Note that a key is NOT a path expression (see
980
+ # {@link ConfigUtil#joinPath} and {@link ConfigUtil#splitPath}).
981
+ #
982
+ # @param key
983
+ # key to store this config at.
984
+ # @return a {@code Config} instance containing this config at the given
985
+ # key.
986
+ #
987
+ def at_key(key)
988
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `at_key` (#{self.class})"
989
+ end
990
+
991
+ #
992
+ # Returns a {@code Config} based on this one, but with the given path set
993
+ # to the given value. Does not modify this instance (since it's immutable).
994
+ # If the path already has a value, that value is replaced. To remove a
995
+ # value, use withoutPath().
996
+ # <p>
997
+ # Note that path expressions have a syntax and sometimes require quoting
998
+ # (see {@link ConfigUtil#joinPath} and {@link ConfigUtil#splitPath}).
999
+ #
1000
+ # @param path
1001
+ # path expression for the value's new location
1002
+ # @param value
1003
+ # value at the new path
1004
+ # @return the new instance with the new map entry
1005
+ #
1006
+ def with_value(path, value)
1007
+ raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `with_value` (#{self.class})"
1008
+ end
1009
+ end
1010
+