org.feijoas.mango.common

base

package base

Basic utility libraries and interfaces.

Since

0.7

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. base
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. trait Ticker extends AnyRef

    A time source; returns a time value representing the number of nanoseconds elapsed since some fixed but arbitrary point in time.

    A time source; returns a time value representing the number of nanoseconds elapsed since some fixed but arbitrary point in time. Note that most users should use Stopwatch instead of interacting with this class directly.

    Warning: this interface can only be used to measure elapsed time, not wall time.

    Annotations
    @Beta()
    Since

    0.7 (copied from guava-libraries)

Value Members

  1. object Equivalence

    Utility functions to convert from Scala Equiv[T] to Guava Equivalence[T] and vice versa.

    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
    Since

    0.10

  2. object Functions

    Utility functions for the work with Guava Function[T, R]

    Utility functions for the work with Guava Function[T, R]

    Usage example for conversion between Guava and Mango:

    // convert a Guava function to a Scala function
    val fnc: Function[T, R] = { (arg: T) => ... }.asJava
    
    // convert a Scala function to a Guava function
    val fnc: (T => R) = SomeGuavaFunction.asScala
    
    // convert a Scala function to a Callable
    val callable: Callable[R] = { () => n }.asJava
    
    // convert a Scala functio to a Runnable
    val runnable: Runnable = { () => ... }.asJava
    Since

    0.7

  3. object Optional

    Utility functions for the work with Option[T] and Optional[T]

    Utility functions for the work with Option[T] and Optional[T]

    Usage example for conversion between Guava and Mango:

    // convert a Guava Optional[T] to a Scala Option[T]
    Optional.of("some").asScala
    Optional.absent().asScala
    
    // convert a Scala Option[T] to a Guava Optional[T]
    Some("some").asJava
    None.asJava
    Since

    0.7

  4. object Preconditions

    Simple static methods to be called at the start of your own methods to verify correct arguments and state.

    Simple static methods to be called at the start of your own methods to verify correct arguments and state. This allows constructs such as

    if (count <= 0) {
        throw new IllegalArgumentException("must be positive: " + count)
    }

    to be replaced with the more compact

    checkArgument(count > 0, "must be positive: %s", count)

    Note that the sense of the expression is inverted with Preconditions you declare what you expect to be true, just as you do with an assert or a JUnit assertTrue call.

    Warning: only the "%s" specifier is recognized as a placeholder in these messages.

    Take care not to confuse precondition checking with other similar types of checks! Precondition exceptions -- including those provided here, but also IndexOutOfBoundsException, NoSuchElementException, UnsupportedOperationException and others -- are used to signal that the calling method has made an error. This tells the caller that it should not have invoked the method when it did, with the arguments it did, or perhaps ever. Postcondition or other invariant failures should not throw these types of exceptions.

    See also the Guava User Guide on using Preconditions

    Since

    0.7 (copied from guava-libraries)

  5. object Predicates

    Utility functions for the work with Guava Predicate[T]

    Utility functions for the work with Guava Predicate[T]

    Usage example for conversion between Guava and Mango:

    // convert a Guava Predicate[T] to a Scala function T => Boolean
    import com.google.common.base.{ Predicate => GuavaPredicate }
    val pred: GuavaPredicate[Any] = { (arg: Any) => true }.asJava
    
    // convert a Scala function T => Boolean to a Guava Predicate[T]
    import com.google.common.base.{ Predicates => GuavaPredicates }
    val pred: Any => Boolean = GuavaPredicates.alwaysTrue().asScala
    Since

    0.7

  6. object Suppliers

    Utility functions for the work with suppliers which are functions of the type () => T

    Utility functions for the work with suppliers which are functions of the type () => T

    Usage example for conversion between Guava and Mango:

    // convert a Guava Supplier[T] to a Scala function () => T
    import com.google.common.base.{ Supplier => GuavaSupplier }
    val fnc: () => T = ...
    val supplier: GuavaSupplier[T] = fnc.asJava
    
    // convert a Scala function () => T to a Guava Supplier[T]
    val guavaSupplier: GuavaSupplier[T] = ...
    val supplier: () => T = guavaSupplier.asScala
    Since

    0.7

  7. object Ticker

    Factory for Ticker instances.

Inherited from AnyRef

Inherited from Any

Ungrouped