-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from TinkoffCreditSystems/sealed-traits
Sealed traits encoding and decoding support
- Loading branch information
Showing
15 changed files
with
1,067 additions
and
126 deletions.
There are no files selected for viewing
This file contains 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
29 changes: 23 additions & 6 deletions
29
modules/core/src/main/scala/ru/tinkoff/phobos/configured/ElementCodecConfig.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,29 @@ | ||
package ru.tinkoff.phobos.configured | ||
|
||
final case class ElementCodecConfig(transformAttributeNames: String => String, | ||
transformElementNames: String => String) { | ||
def withElementsRenamed(transform: String => String): ElementCodecConfig = copy(transformElementNames = transform) | ||
def withAttributesRenamed(transform: String => String): ElementCodecConfig = copy(transformAttributeNames = transform) | ||
def withStyle(transform: String => String): ElementCodecConfig = copy(transformElementNames = transform, transformAttributeNames = transform) | ||
final case class ElementCodecConfig( | ||
transformAttributeNames: String => String, | ||
transformElementNames: String => String, | ||
transformConstructorNames: String => String, | ||
discriminatorLocalName: String, | ||
discriminatorNamespace: Option[String] | ||
) { | ||
def withElementsRenamed(transform: String => String): ElementCodecConfig = | ||
copy(transformElementNames = transform) | ||
|
||
def withAttributesRenamed(transform: String => String): ElementCodecConfig = | ||
copy(transformAttributeNames = transform) | ||
|
||
def withConstructorsRenamed(transform: String => String): ElementCodecConfig = | ||
copy(transformConstructorNames = transform) | ||
|
||
def withStyle(transform: String => String): ElementCodecConfig = | ||
copy(transformElementNames = transform, transformAttributeNames = transform) | ||
|
||
def withDiscriminator(localName: String, namespace: Option[String]): ElementCodecConfig = | ||
copy(discriminatorLocalName = localName, discriminatorNamespace = namespace) | ||
} | ||
|
||
object ElementCodecConfig { | ||
val default: ElementCodecConfig = ElementCodecConfig(identity, identity) | ||
val default: ElementCodecConfig = | ||
ElementCodecConfig(identity, identity, identity, "type", Some("http://www.w3.org/2001/XMLSchema-instance")) | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.