-
-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create Java Collections module #391
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #391 +/- ##
==========================================
+ Coverage 84.27% 85.86% +1.58%
==========================================
Files 108 117 +9
Lines 4071 4463 +392
Branches 182 171 -11
==========================================
+ Hits 3431 3832 +401
+ Misses 640 631 -9
☔ View full report in Codecov by Sentry. |
c036c5c
to
10ddf13
Compare
I am not entirely happy with the amount of implicits I have to write and that I cannot create trait JavaIterator[CC] {
type A
def foreach(collection: CC)(f: A => Any): Unit
}
object JavaIterator {
type Aux[A0, CC] = JavaIterator[CC] { type A = A0 }
implicit def iterator[A]: Aux[A, java.util.Iterator[A]] = ???
implicit def bitSet: Aux[Int, java.util.BitSet] = ???
implicit def iterable[A, CC <: java.lang.Iterable[A]]: Aux[A, CC] = ???
locally {
import io.scalaland.chimney.PartialTransformer
implicit def partialForJavaToJava[JColl1, JColl2, A, B](implicit
iterator: JavaIterator.Aux[A, JColl1],
factory: JavaFactory[B, JColl2],
aToB: PartialTransformer[A, B]
): PartialTransformer[JColl1, JColl2] =
???
implicit def strToInt: PartialTransformer[String, Int] = ???
//implicitly[PartialTransformer[java.util.ArrayList[String], java.util.BitSet]].toString
val foo: PartialTransformer[java.util.ArrayList[String], java.util.BitSet] = partialForJavaToJava
}
} produces (Scala 2.12)
which is absolutely absurd, as If we managed to pull this off we could have only 2 implicit for all cases: Iterator, Enumeration, Iterable, Dictionary, Map, Properties, BitSet, etc. handling collections with and without type bounds, iterating over one or two values (maps and map-like). For now however I am skipping on this effort as a lost a few hours and get nowhere with it. |
Actually I managed to fix that! Refactored |
d842cea
to
ab0eb45
Compare
ab0eb45
to
bf54715
Compare
f8c7f7c
to
3f3b552
Compare
/** Since [[io.scalaland.chimney.Transformer]] is NOT automatically provided for identity/subtype transformation, | ||
* and we want to allow such things without enabling whole recursive auto-derivation we use this trick. | ||
*/ | ||
trait TransformOrUpcast[From, To] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: shouldn't such structure live in core? Would we reuse it somewhere else? If we want to enure binary compatibility we should decide where to put this utility before releasing it since shoving it around would break binary compatibility.
I think that support for |
While it wasn't intended for 0.8.0 (more like 0.8.1) I decided to merge it, as it will be useful in convincing people to update. |
java.util.Optional
java.util.Iterable
java.util.Enumeration
java.util.Collection
java.util.BitSet
java.util.Dictionary
java.util.Map
java.util.Properties
java.util.stream.Stream