aboutsummaryrefslogtreecommitdiff
path: root/examples/shared/src/main/scala/patch.scala
diff options
context:
space:
mode:
Diffstat (limited to 'examples/shared/src/main/scala/patch.scala')
-rw-r--r--examples/shared/src/main/scala/patch.scala11
1 files changed, 7 insertions, 4 deletions
diff --git a/examples/shared/src/main/scala/patch.scala b/examples/shared/src/main/scala/patch.scala
index 668a2e2..769b214 100644
--- a/examples/shared/src/main/scala/patch.scala
+++ b/examples/shared/src/main/scala/patch.scala
@@ -30,7 +30,8 @@ object Patcher extends LowerPriorityPatcher {
def patch(value: T, fieldValues: Seq[Any]): T = {
if (fieldValues.lengthCompare(ctx.parameters.size) != 0) {
throw new IllegalArgumentException(
- s"Cannot patch value `$value`, expected ${ctx.parameters.size} fields but got ${fieldValues.size}")
+ s"Cannot patch value `$value`, expected ${ctx.parameters.size} fields but got ${fieldValues.size}"
+ )
}
val effectiveFields = ctx.parameters.zip(fieldValues).map {
case (param, x) => if (x.asInstanceOf[AnyRef] ne null) x else param dereference value
@@ -55,15 +56,17 @@ sealed abstract class LowerPriorityPatcher {
def patch(value: Any, fieldValues: Seq[Any]): Any = {
if (fieldValues.lengthCompare(1) != 0)
throw new IllegalArgumentException(
- s"Cannot patch single value `$value` with patch sequence of size ${fieldValues.size}")
+ s"Cannot patch single value `$value` with patch sequence of size ${fieldValues.size}"
+ )
val head = fieldValues.head
if (head.getClass != value.getClass)
throw new IllegalArgumentException(
- s"Illegal patch value type. Expected `${value.getClass}` but got `${head.getClass}`")
+ s"Illegal patch value type. Expected `${value.getClass}` but got `${head.getClass}`"
+ )
head
}
}
// once https://github.com/propensive/magnolia/issues/58 is fixed this can be marked `implicit`
def forSingleValue[T]: Patcher[T] = _forSingleValue.asInstanceOf[Patcher[T]]
-} \ No newline at end of file
+}