-
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create extension methods for onSubtype/on.../eachItem/each... in DSL
- Loading branch information
1 parent
8a94eaa
commit af1638b
Showing
12 changed files
with
135 additions
and
6 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
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
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
17 changes: 17 additions & 0 deletions
17
chimney/src/main/scala/io/scalaland/chimney/internal/runtime/IsCollection.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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.scalaland.chimney.internal.runtime | ||
|
||
import scala.annotation.unused | ||
|
||
sealed trait IsCollection[C] { | ||
type Item | ||
} | ||
object IsCollection { | ||
type Of[C, A] = IsCollection[C] { type Item = A } | ||
|
||
private object Impl extends IsCollection[Nothing] | ||
|
||
// build-in Chimney support for collections assumes that they are BOTH Iterable and have a Factory | ||
implicit def scalaCollectionIsCollection[A, C <: Iterable[A]](implicit | ||
@unused ev: scala.collection.compat.Factory[A, C] | ||
): IsCollection.Of[C, A] = Impl.asInstanceOf[IsCollection.Of[C, A]] | ||
} |
14 changes: 14 additions & 0 deletions
14
chimney/src/main/scala/io/scalaland/chimney/internal/runtime/IsEither.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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package io.scalaland.chimney.internal.runtime | ||
|
||
sealed trait IsEither[E] { | ||
type Left | ||
type Right | ||
} | ||
object IsEither { | ||
|
||
type Of[E, L, R] = IsEither[E] { type Left = L; type Right = R } | ||
|
||
private object Impl extends IsEither[Nothing] | ||
|
||
implicit def eitherOsEither[L, R, E <: Left[L, R]]: IsEither.Of[E, L, R] = Impl.asInstanceOf[IsEither.Of[E, L, R]] | ||
} |
17 changes: 17 additions & 0 deletions
17
chimney/src/main/scala/io/scalaland/chimney/internal/runtime/IsMap.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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.scalaland.chimney.internal.runtime | ||
import scala.annotation.unused | ||
|
||
sealed trait IsMap[M] { | ||
type Key | ||
type Value | ||
} | ||
object IsMap { | ||
type Of[M, K, V] = IsMap[M] { type Key = K; type Value = V } | ||
|
||
private object Impl extends IsMap[Nothing] | ||
|
||
// build-in Chimney support for maps assumes that they are BOTH Map and have a Factory | ||
implicit def scalaMapIsMap[K, V, M <: Map[K, V]](implicit | ||
@unused ev: scala.collection.compat.Factory[(K, V), M] | ||
): IsMap.Of[K, V, M] = Impl.asInstanceOf[IsMap.Of[K, V, M]] | ||
} |
13 changes: 13 additions & 0 deletions
13
chimney/src/main/scala/io/scalaland/chimney/internal/runtime/IsOption.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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.scalaland.chimney.internal.runtime | ||
|
||
sealed trait IsOption[O] { | ||
type Value | ||
} | ||
object IsOption { | ||
|
||
type Of[O, A] = IsOption[O] { type Value = A } | ||
|
||
private object Impl extends IsOption[Nothing] | ||
|
||
implicit def optionIsOption[A, O <: Option[A]]: IsOption.Of[O, A] = Impl.asInstanceOf[IsOption.Of[O, A]] | ||
} |
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 |
---|---|---|
|
@@ -756,3 +756,4 @@ class IssuesSpec extends ChimneySpec { | |
.transform ==> To(uuid1, uuid2, "test") | ||
} | ||
} | ||
∑ |
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