Add DeriveConfig support for Map with non-String keys via ConfigKeyDecoder#1658
Open
loathwine wants to merge 4 commits intozio:series/4.xfrom
Open
Add DeriveConfig support for Map with non-String keys via ConfigKeyDecoder#1658loathwine wants to merge 4 commits intozio:series/4.xfrom
loathwine wants to merge 4 commits intozio:series/4.xfrom
Conversation
* Introduced ConfigKeyDecoder trait to enable decoding map keys from strings * Added built-in decoders for String, UUID, Int, and Long * Updated DeriveConfig.implicitMapDesc to support Map[K, V] with custom key types * Implemented for both Scala 2.12-2.13 and Scala 3 (dotty) * Added comprehensive test suite covering String, UUID, Int keys and nested case classes
f767770 to
af24c50
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
ConfigKeyDecoder[K]typeclass to supportMap[K, V]whereKis notString, fixing #1381.Previously,
DeriveConfigonly supportedMap[String, V]viaConfig.table. This adds aConfigKeyDecodertrait that decodes map keys from their string representation, with built-in instances forString,UUID,Int, andLong.This is particularly useful for libraries like neotype where wrapper types are commonly used as map keys — see kitlangton/neotype#413 for a concrete use case.
Usage
Changes
ConfigKeyDecodertrait with built-in instances forString,UUID,Int,LongMap[String, V]-onlymapDescwith generalizedMap[K, V]version usingConfigKeyDecoder[K]Map[String, V]continues to work as beforeTest plan
Map[String, Int]— backwards compatibilityMap[UUID, String]— UUID keys parsed from configMap[Int, String]— Int keys parsed from configMap[UUID, CaseClass]— automatic derivation