Porting a java interface to a scala trait with generics
Asked Answered
I

1

5

I am a Scala newbie and I need to port part of a java application to scala.

I have the following java interface definition which is as follows:

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

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

Here is my scala trait:

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

The problem I have is with the A.

Can anyone please advise?

Immediate answered 24/2, 2012 at 10:3 Comment(0)
U
8

The type parameter A and its subtype relationship to Account can be expressed as follows:

trait AccountDAO[A <: Account] extends CrudRepository[A, Int]
Unbeaten answered 24/2, 2012 at 10:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.