Last active
December 25, 2015 04:49
-
-
Save arturaz/6919690 to your computer and use it in GitHub Desktop.
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
object ChiShapeGenerator extends ChiShapeGenerator { | |
trait JavaConvertible[From, To] { def asJava(obj: From): To } | |
object JavaConvertible { | |
def apply[A, B](obj: A) = implicitly[JavaConvertible[A, B]].asJava(obj) | |
implicit object HoleParamsJC extends JavaConvertible[HoleParams, HP] { | |
def asJava(obj: HoleParams) = new HP(obj.holeEdgeLengthThreshold) | |
} | |
implicit object SmoothHoleParamsJC | |
extends JavaConvertible[SmoothHoleParams, SHP] { | |
def asJava(obj: SmoothHoleParams) = new SHP( | |
JavaConvertible(obj.nonSmoothParams), | |
obj.holeLineStiffness, obj.holeLineElasticity | |
) | |
} | |
implicit object ClusteringParamsJC | |
extends JavaConvertible[ClusteringParams, CP] { | |
def asJava(obj: ClusteringParams) = new CP(obj.clusterNodesDistance) | |
} | |
} | |
} |
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
ChiShapeGenerator.scala:16: could not find implicit value for parameter e: ChiShapeGenerator.JavaConvertible[A,B] | |
[error] def apply[A, B](obj: A) = implicitly[JavaConvertible[A, B]].asJava(obj) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
trait JavaConvertible[From,To] { def asJava(a:From): To }
object JavaConvertible {
// convenience function
def apply[A,B] = implicitly[JavaConvertible[A,B]]
implicit object HoleParamsJC extends JavaConvertible[HoleParams, <Return type?>] {
def asJava(a:From) = a.holeEdgeLengthThreshold
}
}
// How you'd use it
def fooA,B(implicit jc:JavaConvertible[A,B]):B = jc.asJava(someItem)