Permalink
Browse files

Merge branch 'release/0.10'

  • Loading branch information...
2 parents f7e6018 + 3eafc81 commit 016fa42952af1bdd52d672edda1cf5b3a6b0f324 @mschneiderwng mschneiderwng committed Oct 2, 2013
Showing with 2,457 additions and 194 deletions.
  1. +1 −0 .travis.yml
  2. +2 −1 README.md
  3. +5 −4 project/Build.scala
  4. +3 −3 project/Dependencies.scala
  5. +2 −0 project/scalastyle.sbt
  6. +2 −1 rootdoc.txt
  7. +124 −0 scalastyle-config.xml
  8. +1 −1 src/main/scala/org/feijoas/mango/common/annotations/Beta.scala
  9. +99 −0 src/main/scala/org/feijoas/mango/common/base/Equivalence.scala
  10. +2 −2 src/main/scala/org/feijoas/mango/common/base/Functions.scala
  11. +2 −2 src/main/scala/org/feijoas/mango/common/base/Optional.scala
  12. +2 −2 src/main/scala/org/feijoas/mango/common/base/Preconditions.scala
  13. +1 −1 src/main/scala/org/feijoas/mango/common/base/Predicates.scala
  14. +1 −1 src/main/scala/org/feijoas/mango/common/base/Suppliers.scala
  15. +1 −1 src/main/scala/org/feijoas/mango/common/base/Ticker.scala
  16. +1 −1 src/main/scala/org/feijoas/mango/common/base/package.scala
  17. +1 −1 src/main/scala/org/feijoas/mango/common/cache/Cache.scala
  18. +1 −1 src/main/scala/org/feijoas/mango/common/cache/CacheBuilder.scala
  19. +1 −1 src/main/scala/org/feijoas/mango/common/cache/CacheLoader.scala
  20. +1 −1 src/main/scala/org/feijoas/mango/common/cache/CacheLoaderWrapper.scala
  21. +1 −1 src/main/scala/org/feijoas/mango/common/cache/CacheStats.scala
  22. +1 −1 src/main/scala/org/feijoas/mango/common/cache/CacheWrapper.scala
  23. +1 −1 src/main/scala/org/feijoas/mango/common/cache/LoadingCache.scala
  24. +1 −1 src/main/scala/org/feijoas/mango/common/cache/LoadingCacheWrapper.scala
  25. +1 −1 src/main/scala/org/feijoas/mango/common/cache/RemovalCause.scala
  26. +1 −1 src/main/scala/org/feijoas/mango/common/cache/RemovalListener.scala
  27. +1 −1 src/main/scala/org/feijoas/mango/common/cache/RemovalNotification.scala
  28. +1 −1 src/main/scala/org/feijoas/mango/common/cache/Weigher.scala
  29. +1 −1 src/main/scala/org/feijoas/mango/common/cache/package.scala
  30. +2 −2 src/main/scala/org/feijoas/mango/common/collect/AsOrdered.scala
  31. +1 −1 src/main/scala/org/feijoas/mango/common/collect/Bound.scala
  32. +1 −1 src/main/scala/org/feijoas/mango/common/collect/BoundType.scala
  33. +1 −1 src/main/scala/org/feijoas/mango/common/collect/DiscreteDomain.scala
  34. +1 −1 src/main/scala/org/feijoas/mango/common/collect/Range.scala
  35. +1 −1 src/main/scala/org/feijoas/mango/common/collect/RangeMap.scala
  36. +1 −1 src/main/scala/org/feijoas/mango/common/collect/RangeMapFactory.scala
  37. +1 −1 src/main/scala/org/feijoas/mango/common/collect/RangeMapLike.scala
  38. +1 −1 src/main/scala/org/feijoas/mango/common/collect/RangeMapWrapperLike.scala
  39. +1 −1 src/main/scala/org/feijoas/mango/common/collect/RangeSet.scala
  40. +1 −1 src/main/scala/org/feijoas/mango/common/collect/RangeSetFactory.scala
  41. +1 −1 src/main/scala/org/feijoas/mango/common/collect/RangeSetLike.scala
  42. +1 −1 src/main/scala/org/feijoas/mango/common/collect/RangeSetWrapperLike.scala
  43. +1 −1 src/main/scala/org/feijoas/mango/common/collect/immutable/ImmutableRangeMapWrapper.scala
  44. +1 −1 src/main/scala/org/feijoas/mango/common/collect/immutable/ImmutableRangeSetWrapper.scala
  45. +1 −1 src/main/scala/org/feijoas/mango/common/collect/immutable/RangeMap.scala
  46. +1 −1 src/main/scala/org/feijoas/mango/common/collect/immutable/RangeMapLike.scala
  47. +1 −1 src/main/scala/org/feijoas/mango/common/collect/immutable/RangeSet.scala
  48. +1 −1 src/main/scala/org/feijoas/mango/common/collect/immutable/RangeSetLike.scala
  49. +1 −1 src/main/scala/org/feijoas/mango/common/collect/mutable/RangeMap.scala
  50. +1 −1 src/main/scala/org/feijoas/mango/common/collect/mutable/RangeMapLike.scala
  51. +1 −1 src/main/scala/org/feijoas/mango/common/collect/mutable/RangeMapWrapperLike.scala
  52. +1 −1 src/main/scala/org/feijoas/mango/common/collect/mutable/RangeSet.scala
  53. +1 −1 src/main/scala/org/feijoas/mango/common/collect/mutable/RangeSetLike.scala
  54. +1 −1 src/main/scala/org/feijoas/mango/common/collect/mutable/RangeSetWrapperLike.scala
  55. +1 −1 src/main/scala/org/feijoas/mango/common/collect/mutable/TreeRangeMapWrapper.scala
  56. +1 −1 src/main/scala/org/feijoas/mango/common/collect/mutable/TreeRangeSetWrapper.scala
  57. +1 −1 src/main/scala/org/feijoas/mango/common/collect/package.scala
  58. +1 −1 src/main/scala/org/feijoas/mango/common/convert/Decorators.scala
  59. +1 −1 src/main/scala/org/feijoas/mango/common/convert/package.scala
  60. +1 −1 src/main/scala/org/feijoas/mango/common/hash/BloomFilter.scala
  61. +1 −1 src/main/scala/org/feijoas/mango/common/hash/Funnel.scala
  62. +277 −0 src/main/scala/org/feijoas/mango/common/primitives/UByte.scala
  63. +351 −0 src/main/scala/org/feijoas/mango/common/primitives/UInt.scala
  64. +373 −0 src/main/scala/org/feijoas/mango/common/primitives/ULong.scala
  65. +2 −2 src/main/scala/org/feijoas/mango/common/util/concurrent/Futures.scala
  66. +63 −0 src/test/scala/org/feijoas/mango/common/base/EquivalenceTest.scala
  67. +2 −2 src/test/scala/org/feijoas/mango/common/base/FunctionsTest.scala
  68. +2 −2 src/test/scala/org/feijoas/mango/common/base/OptionalTest.scala
  69. +2 −2 src/test/scala/org/feijoas/mango/common/base/PreconditionsTest.scala
  70. +2 −2 src/test/scala/org/feijoas/mango/common/base/PredicatesTest.scala
  71. +2 −2 src/test/scala/org/feijoas/mango/common/base/SuppliersTest.scala
  72. +21 −9 src/test/scala/org/feijoas/mango/common/cache/CacheBuilderTest.scala
  73. +2 −2 src/test/scala/org/feijoas/mango/common/cache/CacheLoaderWrapperTest.scala
  74. +1 −1 src/test/scala/org/feijoas/mango/common/cache/CacheStatsMatcher.scala
  75. +2 −2 src/test/scala/org/feijoas/mango/common/cache/CacheStatsTest.scala
  76. +2 −2 src/test/scala/org/feijoas/mango/common/cache/CacheTest.scala
  77. +1 −1 src/test/scala/org/feijoas/mango/common/cache/CacheWrapperBehaviour.scala
  78. +2 −2 src/test/scala/org/feijoas/mango/common/cache/CacheWrapperTest.scala
  79. +2 −2 src/test/scala/org/feijoas/mango/common/cache/LoadingCacheTest.scala
  80. +2 −2 src/test/scala/org/feijoas/mango/common/cache/LoadingCacheWrapperTest.scala
  81. +8 −6 src/test/scala/org/feijoas/mango/common/cache/RemovalCauseTest.scala
  82. +4 −3 src/test/scala/org/feijoas/mango/common/cache/RemovalListenerTest.scala
  83. +4 −3 src/test/scala/org/feijoas/mango/common/cache/RemovalNotificationTest.scala
  84. +4 −3 src/test/scala/org/feijoas/mango/common/cache/WeigherTest.scala
  85. +10 −6 src/test/scala/org/feijoas/mango/common/collect/BoundTypeTest.scala
  86. +2 −2 src/test/scala/org/feijoas/mango/common/collect/DiscreteDomainTest.scala
  87. +11 −6 src/test/scala/org/feijoas/mango/common/collect/RangeMapBehaviors.scala
  88. +8 −4 src/test/scala/org/feijoas/mango/common/collect/RangeMapWrapperBehaviours.scala
  89. +13 −8 src/test/scala/org/feijoas/mango/common/collect/RangeSetBehaviors.scala
  90. +10 −4 src/test/scala/org/feijoas/mango/common/collect/RangeSetFactoryTest.scala
  91. +9 −2 src/test/scala/org/feijoas/mango/common/collect/RangeSetTraitTest.scala
  92. +7 −9 src/test/scala/org/feijoas/mango/common/collect/RangeSetWrapperBehaviours.scala
  93. +13 −12 src/test/scala/org/feijoas/mango/common/collect/RangeTest.scala
  94. +9 −2 src/test/scala/org/feijoas/mango/common/collect/immutable/ImmutableRangeMapWrapperTest.scala
  95. +9 −2 src/test/scala/org/feijoas/mango/common/collect/immutable/ImmutableRangeSetWrapperTest.scala
  96. +9 −2 src/test/scala/org/feijoas/mango/common/collect/immutable/RangeSetFactoryTest.scala
  97. +11 −3 src/test/scala/org/feijoas/mango/common/collect/mutable/TreeRangeMapWrapperTest.scala
  98. +2 −2 src/test/scala/org/feijoas/mango/common/collect/mutable/TreeRangeSetWrapperTest.scala
  99. +17 −7 src/test/scala/org/feijoas/mango/common/hash/BloomFilterTest.scala
  100. +4 −3 src/test/scala/org/feijoas/mango/common/hash/FunnelTest.scala
  101. +214 −0 src/test/scala/org/feijoas/mango/common/primitives/UByteTest.scala
  102. +331 −0 src/test/scala/org/feijoas/mango/common/primitives/UIntTest.scala
  103. +338 −0 src/test/scala/org/feijoas/mango/common/primitives/ULongTest.scala
  104. +2 −2 src/test/scala/org/feijoas/mango/common/util/concurrent/FuturesTest.scala
  105. +2 −2 src/test/scala/org/feijoas/mango/test/collect/Ranges.scala
View
@@ -3,6 +3,7 @@ scala:
- "2.10.0"
- "2.10.1"
- "2.10.2"
+ - "2.10.3"
jdk:
- openjdk7
- oraclejdk7
View
@@ -27,7 +27,7 @@ resolvers ++= Seq(
"Sonatype Releases" at "http://oss.sonatype.org/content/repositories/releases"
)
-libraryDependencies += "org.feijoas" %% "mango" % "0.9"
+libraryDependencies += "org.feijoas" %% "mango" % "0.10"
```
## Examples
@@ -166,6 +166,7 @@ Besides the [Scaladoc](http://feijoas.github.io/mango/scaladoc) there is an exce
- [Preconditions](http://feijoas.github.io/mango/scaladoc/index.html#org.feijoas.mango.common.base.Preconditions$): Test preconditions for your methods more easily.
- [Caches](http://feijoas.github.io/mango/scaladoc/index.html#org.feijoas.mango.common.cache.CacheBuilder$): Local caching, done right, and supporting a wide variety of expiration behaviors.
- [Ranges](http://feijoas.github.io/mango/scaladoc/index.html#org.feijoas.mango.common.collect.Range$): RangeSets/RangeMaps query, merge and manipulate ranges
+ - [Primitives](http://feijoas.github.io/mango/scaladoc/index.html#org.feijoas.mango.common.primitives$): Unsigned Int, Long and Byte
## License
View
@@ -5,13 +5,14 @@ import Dependencies._
object BuildSettings {
val buildOrganization = "org.feijoas"
- val buildVersion = "0.9"
+ val buildVersion = "0.10"
val buildScalaVersion = "2.10.2"
val gitHeadCommitSha = Process("git rev-parse HEAD").lines.head
val release = sys.props("release")=="true"
- println(sys.props("release"))
- val buildSettings = Defaults.defaultSettings ++ Seq (
+ val buildSettings = Defaults.defaultSettings ++
+ org.scalastyle.sbt.ScalastylePlugin.Settings ++
+ Seq (
organization := buildOrganization,
scalaVersion := buildScalaVersion,
shellPrompt := ShellPrompt.buildShellPrompt,
@@ -20,7 +21,7 @@ object BuildSettings {
},
// Scala compiler options
- scalacOptions ++= Seq("-encoding", "UTF-8", "-deprecation", "-unchecked", "-feature","-language:implicitConversions,reflectiveCalls,postfixOps,higherKinds,existentials"),
+ scalacOptions ++= Seq("-encoding", "UTF-8", "-deprecation", "-unchecked", "-Xlint", "-feature","-language:implicitConversions,reflectiveCalls,postfixOps,higherKinds,existentials"),
// Scaladoc title
scalacOptions in (Compile, doc) ++= Opts.doc.title("Mango"),
// Scaladoc title page
@@ -17,10 +17,10 @@ object Dependencies {
val findbugs = "com.google.code.findbugs" % "jsr305" % "1.3.+"
// test dependencies
- val guavaTestlib = "com.google.guava" % "guava-testlib" % "14.0.1" % "test"
+ val guavaTestlib = "com.google.guava" % "guava-testlib" % guavaDefaulVersion % "test"
val junit = "junit" % "junit" % "4.11" % "test"
- val scalatest = "org.scalatest" % "scalatest_2.10" % "2.0.M6" % "test"
- val scalacheck = "org.scalacheck" %% "scalacheck" % "1.10.0" % "test"
+ val scalatest = "org.scalatest" % "scalatest_2.10" % "2.0.M8" % "test"
+ val scalacheck = "org.scalacheck" %% "scalacheck" % "1.10.1" % "test"
val scalamock = "org.scalamock" %% "scalamock-scalatest-support" % "3.0.1" % "test"
val mockito = "org.mockito" % "mockito-core" % "1.9.5" % "test"
View
@@ -0,0 +1,2 @@
+// see http://www.scalastyle.org/sbt.html
+addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "0.3.2")
View
@@ -25,7 +25,7 @@ resolvers ++= Seq(
"Sonatype Releases" at "http://oss.sonatype.org/content/repositories/releases"
)
-libraryDependencies += "org.feijoas" %% "mango" % "0.9"
+libraryDependencies += "org.feijoas" %% "mango" % "0.10"
}}}
== Examples ==
@@ -166,6 +166,7 @@ Besides this Scaladoc there is an excelent user guide [[https://code.google.com/
- [[#org.feijoas.mango.common.base.Preconditions Preconditions]]: Test preconditions for your methods more easily.
- [[#org.feijoas.mango.common.cache.CacheBuilder Caches]]: Local caching, done right, and supporting a wide variety of expiration behaviors.
- [[#org.feijoas.mango.common.collect.Range Ranges]]: RangeSets/RangeMaps query, merge and manipulate ranges
+ - [[#org.feijoas.mango.common.primitives Primitives]]: Unsigned Int, Long and Byte
== License ==
View
@@ -0,0 +1,124 @@
+<scalastyle>
+ <name>Scalastyle standard configuration</name>
+ <check level="warning" class="org.scalastyle.file.FileTabChecker" enabled="true"></check>
+ <check level="warning" class="org.scalastyle.file.FileLengthChecker" enabled="true">
+ <parameters>
+ <parameter name="maxFileLength"><![CDATA[800]]></parameter>
+ </parameters>
+ </check>
+ <check level="warning" class="org.scalastyle.file.HeaderMatchesChecker" enabled="true">
+ <parameters>
+ <parameter name="header"><![CDATA[/*
+ * Copyright (C) 2013 The Mango Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * The code of this project is a port of (or wrapper around) the Guava-libraries.
+ * See http://code.google.com/p/guava-libraries/
+ *
+ * @author Markus Schneider
+ */]]></parameter>
+ </parameters>
+ </check>
+ <check level="warning" class="org.scalastyle.scalariform.SpacesAfterPlusChecker" enabled="false"></check>
+ <check level="warning" class="org.scalastyle.file.WhitespaceEndOfLineChecker" enabled="true"></check>
+ <check level="warning" class="org.scalastyle.scalariform.SpacesBeforePlusChecker" enabled="false"></check>
+ <check level="warning" class="org.scalastyle.file.FileLineLengthChecker" enabled="true">
+ <parameters>
+ <parameter name="maxLineLength"><![CDATA[160]]></parameter>
+ <parameter name="tabSize"><![CDATA[4]]></parameter>
+ </parameters>
+ </check>
+ <check level="warning" class="org.scalastyle.scalariform.ClassNamesChecker" enabled="true">
+ <parameters>
+ <parameter name="regex"><![CDATA[[A-Z][A-Za-z]*]]></parameter>
+ </parameters>
+ </check>
+ <check level="warning" class="org.scalastyle.scalariform.ObjectNamesChecker" enabled="true">
+ <parameters>
+ <parameter name="regex"><![CDATA[[A-Z][A-Za-z]*]]></parameter>
+ </parameters>
+ </check>
+ <check level="warning" class="org.scalastyle.scalariform.PackageObjectNamesChecker" enabled="true">
+ <parameters>
+ <parameter name="regex"><![CDATA[^[a-z][A-Za-z]*$]]></parameter>
+ </parameters>
+ </check>
+ <check level="warning" class="org.scalastyle.scalariform.EqualsHashCodeChecker" enabled="true"></check>
+ <check level="warning" class="org.scalastyle.scalariform.IllegalImportsChecker" enabled="true">
+ <parameters>
+ <parameter name="illegalImports"><![CDATA[sun._,java.awt._]]></parameter>
+ </parameters>
+ </check>
+ <check level="warning" class="org.scalastyle.scalariform.ParameterNumberChecker" enabled="true">
+ <parameters>
+ <parameter name="maxParameters"><![CDATA[8]]></parameter>
+ </parameters>
+ </check>
+ <check level="warning" class="org.scalastyle.scalariform.MagicNumberChecker" enabled="true">
+ <parameters>
+ <parameter name="ignore"><![CDATA[-1,0,1,2,3,1L,-1L,0L]]></parameter>
+ </parameters>
+ </check>
+ <check level="warning" class="org.scalastyle.scalariform.NoWhitespaceBeforeLeftBracketChecker" enabled="true"></check>
+ <check level="warning" class="org.scalastyle.scalariform.NoWhitespaceAfterLeftBracketChecker" enabled="true"></check>
+ <check level="warning" class="org.scalastyle.scalariform.ReturnChecker" enabled="true"></check>
+ <check level="warning" class="org.scalastyle.scalariform.NullChecker" enabled="true"></check>
+ <check level="warning" class="org.scalastyle.scalariform.NoCloneChecker" enabled="true"></check>
+ <check level="warning" class="org.scalastyle.scalariform.NoFinalizeChecker" enabled="true"></check>
+ <check level="warning" class="org.scalastyle.scalariform.CovariantEqualsChecker" enabled="true"></check>
+ <check level="warning" class="org.scalastyle.scalariform.StructuralTypeChecker" enabled="true"></check>
+ <check level="warning" class="org.scalastyle.file.RegexChecker" enabled="true">
+ <parameters>
+ <parameter name="regex"><![CDATA[println]]></parameter>
+ </parameters>
+ </check>
+ <check level="warning" class="org.scalastyle.scalariform.NumberOfTypesChecker" enabled="true">
+ <parameters>
+ <parameter name="maxTypes"><![CDATA[30]]></parameter>
+ </parameters>
+ </check>
+ <check level="warning" class="org.scalastyle.scalariform.CyclomaticComplexityChecker" enabled="true">
+ <parameters>
+ <parameter name="maximum"><![CDATA[10]]></parameter>
+ </parameters>
+ </check>
+ <check level="warning" class="org.scalastyle.scalariform.UppercaseLChecker" enabled="true"></check>
+ <check level="warning" class="org.scalastyle.scalariform.SimplifyBooleanExpressionChecker" enabled="true"></check>
+ <check level="warning" class="org.scalastyle.scalariform.IfBraceChecker" enabled="false">
+ <parameters>
+ <parameter name="singleLineAllowed"><![CDATA[true]]></parameter>
+ <parameter name="doubleLineAllowed"><![CDATA[false]]></parameter>
+ </parameters>
+ </check>
+ <check level="warning" class="org.scalastyle.scalariform.MethodLengthChecker" enabled="true">
+ <parameters>
+ <parameter name="maxLength"><![CDATA[50]]></parameter>
+ </parameters>
+ </check>
+ <check level="warning" class="org.scalastyle.scalariform.MethodNamesChecker" enabled="true">
+ <parameters>
+ <parameter name="regex"><![CDATA[(^[a-z][A-Za-z0-9]*$)|(^[\*\/\-\+=]*$)]]></parameter>
+ </parameters>
+ </check>
+ <check level="warning" class="org.scalastyle.scalariform.NumberOfMethodsInTypeChecker" enabled="true">
+ <parameters>
+ <parameter name="maxMethods"><![CDATA[30]]></parameter>
+ </parameters>
+ </check>
+ <check level="warning" class="org.scalastyle.scalariform.PublicMethodsHaveTypeChecker" enabled="false"></check>
+ <check level="warning" class="org.scalastyle.file.NewLineAtEofChecker" enabled="false"></check>
+ <check level="warning" class="org.scalastyle.file.NoNewLineAtEofChecker" enabled="false"></check>
+</scalastyle>
@@ -17,7 +17,7 @@
/*
* The code of this project is a port of (or wrapper around) the Guava-libraries.
* See http://code.google.com/p/guava-libraries/
- *
+ *
* @author Markus Schneider
*/
package org.feijoas.mango.common.annotations
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2013 The Mango Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * The code of this project is a port of (or wrapper around) the Guava-libraries.
+ * See http://code.google.com/p/guava-libraries/
+ *
+ * @author Markus Schneider
+ */
+package org.feijoas.mango.common.base
+
+import org.feijoas.mango.common.base.Preconditions.checkNotNull
+import org.feijoas.mango.common.convert.AsJava
+import org.feijoas.mango.common.convert.AsScala
+
+import com.google.common.{ base => gcm }
+
+/** Utility functions to convert from Scala `Equiv[T]` to Guava `Equivalence[T]` and vice versa.
+ *
+ * Usage example for conversion between Guava and Mango:
+ * {{{
+ * import org.feijoas.mango.common.base.Equivalence._
+ *
+ * // convert a Guava Equivalence[T] to a Scala Equiv[T]
+ * val guava: gcm.Equivalence[T] = ...
+ * val mango: Equiv[T] = guava.asScala
+ *
+ * // convert a Scala Equiv[T] to a Guava Equivalence[T]
+ * val mango: Equiv[T] = ...
+ * val guava: gcm.Equivalence[T] = mango.asJava
+ * }}}
+ *
+ * @author Markus Schneider
+ * @since 0.10
+ */
+final object Equivalence {
+
+ /** Adds an `asScala` method that wraps a Guava `Equivalence[T]` in
+ * a Scala `Equiv[T]`.
+ *
+ * The returned Scala `Equiv[T]` forwards all calls
+ * to the given Guava `Equivalence[T]`.
+ *
+ * @param equiv the Guava `Equivalence[T]` to wrap in a Scala `Equiv[T]`
+ * @return An object with an `asScala` method that returns a Scala `Equiv[T]`
+ * view of the argument
+ */
+ implicit def asMangoEquiv[T](equiv: gcm.Equivalence[T]): AsScala[Equiv[T]] = new AsScala(
+ equiv match {
+ case AsGuavaEquiv(delegate) => delegate
+ case _ => AsMangoEquiv(equiv)
+ })
+
+ /** Adds an `asJava` method that wraps a Scala `Equiv[T]` in
+ * a Guava `Equivalence[T]`.
+ *
+ * The returned Guava `Equivalence[T]` forwards all calls
+ * to the given Scala `Equiv[T]`.
+ *
+ * @param equiv the Scala `Equiv[T]` to wrap in a Guava `Equivalence[T]`
+ * @return An object with an `asJava` method that returns a Guava `Equivalence[T]`
+ * view of the argument
+ */
+ implicit def asGuavaEquiv[T](equiv: Equiv[T]): AsJava[gcm.Equivalence[T]] = new AsJava(
+ equiv match {
+ case AsMangoEquiv(delegate) => delegate
+ case _ => AsGuavaEquiv(equiv)
+ })
+}
+
+/** Wraps a Guava `Equivalence` in a Scala `Equiv`
+ */
+@SerialVersionUID(1L)
+private[mango] case class AsMangoEquiv[T](equiv: gcm.Equivalence[T]) extends Equiv[T] with Serializable {
+ checkNotNull(equiv)
+ override def equiv(x: T, y: T): Boolean = equiv.equivalent(x, y)
+}
+
+/** Wraps a Scala `Equiv` in a Guava `Equivalence`
+ */
+@SerialVersionUID(1L)
+private[mango] case class AsGuavaEquiv[T](equiv: Equiv[T]) extends gcm.Equivalence[T] with Serializable {
+ checkNotNull(equiv)
+ override def doEquivalent(x: T, y: T): Boolean = equiv.equiv(x, y)
+ override def doHash(t: T): Int = t.hashCode
+}
@@ -15,9 +15,9 @@
*/
/*
- * The code of this project is a port of (or wrapper around) the guava-libraries.
+ * The code of this project is a port of (or wrapper around) the Guava-libraries.
* See http://code.google.com/p/guava-libraries/
- *
+ *
* @author Markus Schneider
*/
package org.feijoas.mango.common.base
@@ -15,9 +15,9 @@
*/
/*
- * The code of this project is a port of (or wrapper around) the guava-libraries.
+ * The code of this project is a port of (or wrapper around) the Guava-libraries.
* See http://code.google.com/p/guava-libraries/
- *
+ *
* @author Markus Schneider
*/
package org.feijoas.mango.common.base
@@ -15,9 +15,9 @@
*/
/*
- * The code of this project is a port of (or wrapper around) the guava-libraries.
+ * The code of this project is a port of (or wrapper around) the Guava-libraries.
* See http://code.google.com/p/guava-libraries/
- *
+ *
* @author Markus Schneider
*/
package org.feijoas.mango.common.base
@@ -17,7 +17,7 @@
/*
* The code of this project is a port of (or wrapper around) the Guava-libraries.
* See http://code.google.com/p/guava-libraries/
- *
+ *
* @author Markus Schneider
*/
package org.feijoas.mango.common.base
@@ -17,7 +17,7 @@
/*
* The code of this project is a port of (or wrapper around) the Guava-libraries.
* See http://code.google.com/p/guava-libraries/
- *
+ *
* @author Markus Schneider
*/
package org.feijoas.mango.common.base
@@ -17,7 +17,7 @@
/*
* The code of this project is a port of (or wrapper around) the Guava-libraries.
* See http://code.google.com/p/guava-libraries/
- *
+ *
* @author Markus Schneider
*/
package org.feijoas.mango.common.base
@@ -17,7 +17,7 @@
/*
* The code of this project is a port of (or wrapper around) the Guava-libraries.
* See http://code.google.com/p/guava-libraries/
- *
+ *
* @author Markus Schneider
*/
package org.feijoas.mango.common
Oops, something went wrong.

0 comments on commit 016fa42

Please sign in to comment.