Packages

  • package root

    This library provides the mechanisms to convert between types provided by javascalautils to their Scala equivalence and vice-versa.

    Overview

    This library provides the mechanisms to convert between types provided by javascalautils to their Scala equivalence and vice-versa.
    One can either perform explicit conversions by using a specific converter method or do implicit conversions using the decorator pattern provided by Scalas implicit method declaration.

    Explicit Conversion

    This is the mechanism for performing the conversion by invoking a specific method taking the type you want to and converting it to its Scala or Java equivalence.
    There's converters for Java -> Scala, javascalautils.converters.j2s.Converters as well as from Scala -> Java, javascalautils.converters.s2j.Converters. There's also an aggregate converter containing both of these javascalautils.converters.JavaScalaUtilConverters. Either import the converters you need:

    import javascalautils.converters.j2s.Converters._
    import javascalautils.converters.s2j.Converters._

    or use the aggregate object composed of both above converters

    import javascalautils.converters.JavaScalaUtilConverters._

    After that it's a matter of using the right converter method to do the job.
    E.g.

    import javascalautils.{Some => JSome}
    
    val optionSome = asScalaOption(new JSome("Some is never None"))
    val joptionSome = asJavaOption(Some("Some is never None"))

    Refer to the aggregate object javascalautils.converters.JavaScalaUtilConverters for a list of all converter methods and examples on usage.

    Implicit Conversion

    This utilizes the implicit mechanism in Scala to decorate any given class with new methods.
    More precisely this library provides asScala methods on all supported Java types and asJava methods on all supported Scala types.
    This magic is enabled by having the right imports in scope.
    Just as with the explicit converters the implicit ones are divided into Java -> Scala, javascalautils.converters.j2s.Implicits as well as from Scala -> Java, javascalautils.converters.s2j.Implicits.
    Or one can choose to use the aggregate implicit javascalautils.converters.JavaScalaUtilImplicits.
    It's again a matter of having the right imports in scope.

    import javascalautils.converters.j2s.Implicits._
    import javascalautils.converters.s2j.Implicits._

    or use the aggregate object composed of both above implicits.

    import javascalautils.converters.JavaScalaUtilImplicits._

    Now your instances should be decorated with either a asScala or asJava method.

    import javascalautils.{Some => JSome}
    
    val some = new JSome("Some is never None").asScala
    val jsome = Some("Some is never None").asJava

    Full Documentation

    Wiki

    License

    Copyright 2015 Peter Nerg

    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.

    Definition Classes
    root
  • package javascalautils
    Definition Classes
    root
  • package converters

    Contains the main/aggregate objects for the converters and implicits.

    Contains the main/aggregate objects for the converters and implicits.

    Definition Classes
    javascalautils
  • package s2j

    Contains the converters from Scala -> Java, both implicit as well as explicit.

    Contains the converters from Scala -> Java, both implicit as well as explicit.

    Definition Classes
    converters
  • Converters
  • EitherConverters
  • EitherDecorator
  • EitherImplicits
  • FailureDecorator
  • FutureConverters
  • FutureDecorator
  • FutureImplicits
  • Implicits
  • LeftDecorator
  • NoneDecorator
  • OptionConverters
  • OptionDecorator
  • OptionImplicits
  • RightDecorator
  • SomeDecorator
  • SuccessDecorator
  • TryConverters
  • TryDecorator
  • TryImplicits

trait Converters extends OptionConverters with TryConverters with EitherConverters with FutureConverters

Aggregates the various traits for converting from Scala -> javascalautils.
Example on usage:

import javascalautils.converters.s2j.Converters._
val joptionSome = asJavaOption(Some("Some is never None"))

Refer to the various methods on this object for further code examples.

Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Converters
  2. FutureConverters
  3. EitherConverters
  4. TryConverters
  5. OptionConverters
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def asJavaEither[L, R](underlying: scala.util.Either[L, R]): Either[_ <: L, _ <: R] with Serializable

    Converts a scala.util.Either to a javascalautils.Either.

    Converts a scala.util.Either to a javascalautils.Either.

    val jEitherLeft = asJavaEither(Left("Left is not to the Right"))
    val jEitherRight = asJavaEither(Right("Left is not to the Right"))
    underlying

    The type to be converted

    returns

    The converted type

    Definition Classes
    EitherConverters
    Since

    1.0

  6. def asJavaFailure[T](underlying: scala.util.Failure[T]): Failure[Nothing]

    Converts a scala.util.Failure to a javascalautils.Failure.

    Converts a scala.util.Failure to a javascalautils.Failure.

    val jfailure = asJavaFailure(Failure(new Exception("Error, terror!!!")))
    underlying

    The type to be converted

    returns

    The converted type

    Definition Classes
    TryConverters
    Since

    1.0

  7. def asJavaFuture[T](underlying: Future[T])(implicit ec: ExecutionContext): Future[T]

    Converts a scala.concurrent.Future -> javascalautils.concurrent.Future.

    Converts a scala.concurrent.Future -> javascalautils.concurrent.Future.

    val future = Future {
      Thread.sleep(50)
      "The Future is right here!"
    }
    val jfuture = asJavaFuture(future)
    underlying

    The type to be converted

    returns

    The converted type

    Definition Classes
    FutureConverters
    Since

    1.0

  8. def asJavaLeft[L, R](underlying: scala.util.Left[L, R]): Left[L, Nothing]

    Converts a scala.util.Left to a javascalautils.Left.

    Converts a scala.util.Left to a javascalautils.Left.

    val jLeft = asJavaLeft(Left("Left is not to the Right"))
    underlying

    The type to be converted

    returns

    The converted type

    Definition Classes
    EitherConverters
    Since

    1.0

  9. def asJavaNone[T](underlying: scala.None.type): None[Nothing]

    Converts a scala.None to a javascalautils.None.

    Converts a scala.None to a javascalautils.None.

    val jnone = asJavaNone(None)
    underlying

    The type to be converted

    returns

    The converted type

    Definition Classes
    OptionConverters
    Since

    1.0

  10. def asJavaOption[T](underlying: scala.Option[T]): Option[_ <: T] with Serializable

    Converts a scala.Option to a javascalautils.Option.

    Converts a scala.Option to a javascalautils.Option.

    val joptionSome = asJavaOption(Some("Some is never None"))
    val joptionNone = asJavaOption(None)
    underlying

    The type to be converted

    returns

    The converted type

    Definition Classes
    OptionConverters
    Since

    1.0

  11. def asJavaRight[L, R](underlying: scala.util.Right[L, R]): Right[Nothing, R]

    Converts a scala.util.Right to a javascalautils.Right.

    Converts a scala.util.Right to a javascalautils.Right.

    val jright = asJavaRight(Right("Left is not to the Right"))
    underlying

    The type to be converted

    returns

    The converted type

    Definition Classes
    EitherConverters
    Since

    1.0

  12. def asJavaSome[T](underlying: scala.Some[T]): Some[T]

    Converts a scala.Some to a javascalautils.Some.

    Converts a scala.Some to a javascalautils.Some.

    val jsome = asJavaSome(Some("Some is never None"))
    underlying

    The type to be converted

    returns

    The converted type

    Definition Classes
    OptionConverters
    Since

    1.0

  13. def asJavaSuccess[T](underlying: scala.util.Success[T]): Success[T]

    Converts a scala.util.Success to a javascalautils.Success.

    Converts a scala.util.Success to a javascalautils.Success.

    val jSuccess = asJavaSuccess(Success("Success is not Failure"))
    underlying

    The type to be converted

    returns

    The converted type

    Definition Classes
    TryConverters
    Since

    1.0

  14. def asJavaTry[T](underlying: scala.util.Try[T]): Try[T]

    Converts a scala.util.Try to a javascalautils.Try.

    Converts a scala.util.Try to a javascalautils.Try.

    val jTryFailure = asJavaTry(Failure(new Exception("Error, terror!!!")))
    val jTrySuccess = asJavaTry(Success("Success is not Failure"))
    underlying

    The type to be converted

    returns

    The converted type

    Definition Classes
    TryConverters
    Since

    1.0

  15. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native() @HotSpotIntrinsicCandidate()
  16. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  17. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  18. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  19. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  20. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  21. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  22. final def notify(): scala.Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  23. final def notifyAll(): scala.Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  24. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  25. def toString(): String
    Definition Classes
    AnyRef → Any
  26. final def wait(arg0: Long, arg1: Int): scala.Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. final def wait(arg0: Long): scala.Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  28. final def wait(): scala.Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

  1. def finalize(): scala.Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] ) @Deprecated
    Deprecated

Inherited from FutureConverters

Inherited from EitherConverters

Inherited from TryConverters

Inherited from OptionConverters

Inherited from AnyRef

Inherited from Any

Ungrouped