add convenience methods for getting multi-valued properties
See original GitHub issueThe existing Config
API only permits retrieving multi-valued properties as arrays like this:
for (String value : config.getValue("my.key", String[].class)) {
// do something with value
}
I propose we add the following methods to permit retrieving more than one value in a more natural way:
<T> Iterable<T> getValues(String propertyName, Class<T> propertyType);
<T> Optional<Iterable<T>> getOptionalValues(String propertyName, Class<T> propertyType);
This would enable the use of lamba-friendly patterns like this:
config.getValues("my.key", String.class)
.forEach(value -> {
// do something with value
});
As a bonus, the developer doesn’t need to worry about asking for String.class
or String[].class
depending on the scenario.
Issue Analytics
- State:
- Created 4 years ago
- Comments:16 (16 by maintainers)
Top Results From Across the Web
Modifying multivalued properties: Exchange 2013 Help
This topic explains how to use the Exchange Management Shell to add values to and remove values from a multivalued property on an...
Read more >How to set multiple attributes with one value function?
The d3-selection-multi docs for .attrs describes it as "A convenience method on top of selection.attr for setting multiple attributes." Looking ...
Read more >W6PMultiValue Object (ClickSchedule Server-Side Business ...
You can add elements to multivalued properties by calling their Add... methods. You can retrieve elements by calling their Get... and Item methods, ......
Read more >Attaching fields to represent inetorgperson data
For more information on multivalued attributes, see Specifying multivalued attributes. Alternative method of adding a field to represent the uid ...
Read more >prop - Go Packages
Special SCIM property that contains other property. This interface shall be implemented by complex and multiValued properties. A container property usually does ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That works for me. Not sure which hacky way is best for obtaining the array class in the default implementation, but the
Array#newInstance
approach seems like the cleanest since there are no magic string formulas or checked exceptions to deal with.The PR #501 has been merged a while ago.