Porting java interface to scala with generics

I am new to Scala and I need to port a part of my Java application to scala.

I have the following java interface definition that looks like this:

public interface AccountDAO<A extends Account> extends CrudRepository<A, Integer> {
...
}

I am not sure how to implement the parameterized Scala type according to the above java generics.

Here is my Scala trait:

trait AccountDAO extends CrudRepository[A, Int] {
...
}

I have a problem with A.

Can anyone advise?

+5
source share
1 answer

The type parameter Aand its subtype ratio Accountcan be expressed as follows:

trait AccountDAO[A <: Account] extends CrudRepository[A, Int]
+8
source

All Articles