summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/JavaConverters.scala
blob: 58fbc5afa5fa1bcbf67b5b01a52242c60c12446c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*                     __                                               *\
**     ________ ___   / /  ___     Scala API                            **
**    / __/ __// _ | / /  / _ |    (c) 2006-2013, LAMP/EPFL             **
**  __\ \/ /__/ __ |/ /__/ __ |    http://www.scala-lang.org/           **
** /____/\___/_/ |_/____/_/ | |                                         **
**                          |/                                          **
\*                                                                      */

package scala
package collection

import convert._

// TODO: I cleaned all this documentation up in JavaConversions, but the
// documentation in here is basically the pre-cleaned-up version with minor
// additions.  Would be nice to have in one place.

/** A collection of decorators that allow converting between
 *  Scala and Java collections using `asScala` and `asJava` methods.
 *
 *  The following conversions are supported via `asJava`, `asScala`
 *{{{
 *    scala.collection.Iterable               <=> java.lang.Iterable
 *    scala.collection.Iterator               <=> java.util.Iterator
 *    scala.collection.mutable.Buffer         <=> java.util.List
 *    scala.collection.mutable.Set            <=> java.util.Set
 *    scala.collection.mutable.Map            <=> java.util.Map
 *    scala.collection.mutable.concurrent.Map <=> java.util.concurrent.ConcurrentMap
 *}}}
 *  In all cases, converting from a source type to a target type and back
 *  again will return the original source object, e.g.
 *  {{{
 *    import scala.collection.JavaConverters._
 *
 *    val sl = new scala.collection.mutable.ListBuffer[Int]
 *    val jl : java.util.List[Int] = sl.asJava
 *    val sl2 : scala.collection.mutable.Buffer[Int] = jl.asScala
 *    assert(sl eq sl2)
 *  }}}
 *  The following conversions are also supported, but the
 *  direction from Scala to Java is done by the more specifically named methods:
 *  `asJavaCollection`, `asJavaEnumeration`, `asJavaDictionary`.
 *{{{
 *    scala.collection.Iterable    <=> java.util.Collection
 *    scala.collection.Iterator    <=> java.util.Enumeration
 *    scala.collection.mutable.Map <=> java.util.Dictionary
 *}}}
 *  In addition, the following one way conversions are provided via `asJava`:
 *{{{
 *    scala.collection.Seq         => java.util.List
 *    scala.collection.mutable.Seq => java.util.List
 *    scala.collection.Set         => java.util.Set
 *    scala.collection.Map         => java.util.Map
 *}}}
 *  The following one way conversion is provided via `asScala`:
 *{{{
 *    java.util.Properties => scala.collection.mutable.Map
 *}}}
 *  @since  2.8.1
 */
object JavaConverters extends DecorateAsJava with DecorateAsScala