What is the Java-compatibile equivalent in Scala for <? extends Foo>

Ed Staub

I have a java class "JavaClass" with a method:

boolean addAll(java.util.Collection<? extends java.lang.Integer> collection) { ... }

I need to create a Scala trait MyTrait that includes this method without an implementation, something like

def addAll[A<:java.lang.Integer](coll: java.util.Collection[A]) : Boolean

so that an implementation

class MyClass extends JavaClass with MyTrait

would not be abstract. But I can't figure out any way to match the Java signature in Trait.

FWIW... I'm trying to write some high-performance Scala-collection-compatible wrappers for Trove, which avoids generics to provide high performance with primitives, but used highly consistent interfaces for each primitive type. I've found that in general, traits work well to model the type-independent demi-interfaces, but I can't figure out how to express this particular signature - even ignoring, for the moment, the type-abstraction I'm using the trait for.

maks

Collection<? extends java.lang.Integer> in java is equivalent to

Collection[T] forSome {type T <: java.lang.Integer}

or using placeholder syntax Collection[_ <: java.lang.Integer] in scala

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

What is the Java equivalent of this Scala code?

From Dev

What is Scala's equivalent of java char[]?

From Dev

What is Scala's equivalent of java char[]?

From Dev

What is the equivalent C# of a parameterized type like Class<? extends Throwable> in Java?

From Dev

What is the equivalent C# of a parameterized type like Class<? extends Throwable> in Java?

From Dev

Scala object that extends Java class

From Dev

Scala object that extends Java class

From Dev

C# equivalent of Java Class<? extends Base>?

From Dev

What is the annotation equivalent of map: const {'foo':'&foo'} in AngularDart?

From Dev

What is the annotation equivalent of map: const {'foo':'&foo'} in AngularDart?

From Dev

What does `object Foo extends (Bar => Baz)` mean?

From Dev

What does `object Foo extends (Bar => Baz)` mean?

From Dev

Equivalent of Java '?' in Scala

From Dev

Equivalent to Java summaryStatistics in Scala

From Dev

Why Java / Scala use extends / implements keywords?

From Dev

Why Java / Scala use extends / implements keywords?

From Java

What is the Java equivalent for LINQ?

From Dev

What is the 'defer' equivalent for Java

From Dev

What is the equivalent of :: operator in java?

From Dev

Is there an equivalent of Java's this in Scala constructors?

From Dev

Scala equivalent of Java's Number

From Dev

The java "Object" Class equivalent in Scala

From Dev

Equivalent Scala code for Java code

From Java

What is the equivalent of ARRAY_AGG(foo where bar) in BigQuery?

From Dev

In Scala, what does "extends (A => B)" on a case class mean?

From Dev

What does "case class extends trait" mean in Scala?

From Dev

What is the Scala equivalent of Clojure's Atom?

From Dev

What is the Scala case class equivalent in PySpark?

From Dev

What is the Scala equivalent to Clojure's threading macros?

Related Related

  1. 1

    What is the Java equivalent of this Scala code?

  2. 2

    What is Scala's equivalent of java char[]?

  3. 3

    What is Scala's equivalent of java char[]?

  4. 4

    What is the equivalent C# of a parameterized type like Class<? extends Throwable> in Java?

  5. 5

    What is the equivalent C# of a parameterized type like Class<? extends Throwable> in Java?

  6. 6

    Scala object that extends Java class

  7. 7

    Scala object that extends Java class

  8. 8

    C# equivalent of Java Class<? extends Base>?

  9. 9

    What is the annotation equivalent of map: const {'foo':'&foo'} in AngularDart?

  10. 10

    What is the annotation equivalent of map: const {'foo':'&foo'} in AngularDart?

  11. 11

    What does `object Foo extends (Bar => Baz)` mean?

  12. 12

    What does `object Foo extends (Bar => Baz)` mean?

  13. 13

    Equivalent of Java '?' in Scala

  14. 14

    Equivalent to Java summaryStatistics in Scala

  15. 15

    Why Java / Scala use extends / implements keywords?

  16. 16

    Why Java / Scala use extends / implements keywords?

  17. 17

    What is the Java equivalent for LINQ?

  18. 18

    What is the 'defer' equivalent for Java

  19. 19

    What is the equivalent of :: operator in java?

  20. 20

    Is there an equivalent of Java's this in Scala constructors?

  21. 21

    Scala equivalent of Java's Number

  22. 22

    The java "Object" Class equivalent in Scala

  23. 23

    Equivalent Scala code for Java code

  24. 24

    What is the equivalent of ARRAY_AGG(foo where bar) in BigQuery?

  25. 25

    In Scala, what does "extends (A => B)" on a case class mean?

  26. 26

    What does "case class extends trait" mean in Scala?

  27. 27

    What is the Scala equivalent of Clojure's Atom?

  28. 28

    What is the Scala case class equivalent in PySpark?

  29. 29

    What is the Scala equivalent to Clojure's threading macros?

HotTag

Archive