How to access the CALL_INDEX
object from java class:
MyStrategy.scala
trait CallStrategy
object CallStrategy {
case object CALL_INDEX extends CallStrategy
}
trait MyStrategy { def random(as: CallStrategy) }
object MyStrategy extends MyStrategy
{
def random(as: CallStrategy) = { //Some code }
}
In another scala file I can access the CALL_INDEX
using:
CallStrategy.CALL_INDEX
But in java, I am not able to access it as follows:
StrategyUser.java
CallStrategy$ callStrategy = CallStrategy$.MODULE$;
MyStrategy$ myStrategy = MyStrategy$.MODULE$;
myStrategy.random(callStrategy); // compile time error
The above java code is giving compile time error:
The method random(CallStrategy) in the type MyStrategy$ is not applicable for the arguments (CallStrategy$)
I used the above java code by taking help from:
How do I "get" a Scala case object from Java?
UPDATE:
Please see the image below for clarification:
Even I added two more statements in the code and still the same compile time error: