net.codingwell.scalaguice

Members list

Concise view

Type members

Classlikes

Extensions for Guice's binding DSL. These allow using a type parameter instead of classOf[Foo] or new TypeLiteral[Bar[Foo]] {}. The extra methods are named as those in the normal binding DSL suffixed with Type.

Extensions for Guice's binding DSL. These allow using a type parameter instead of classOf[Foo] or new TypeLiteral[Bar[Foo]] {}. The extra methods are named as those in the normal binding DSL suffixed with Type.

For example, instead of

binder.bind(new TypeLiteral[Bar[Foo]]{}).to(classOf[FooBarImpl])

use

import BindingExtensions._
binder.bindType[Bar[Foo]].toType[FooImpl]

'''Note''' This syntax allows binding to and from generic types. It doesn't currently allow bindings between wildcard types because the manifests for wildcard types don't provide access to type bounds.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
trait InternalModule[B <: Binder]

Allows binding via type parameters. Mix into AbstractModule (or subclass) to allow using a type parameter instead of classOf[Foo] or new TypeLiteral[Bar[Foo\]\] {}.

Allows binding via type parameters. Mix into AbstractModule (or subclass) to allow using a type parameter instead of classOf[Foo] or new TypeLiteral[Bar[Foo\]\] {}.

For example, instead of

class MyModule extends AbstractModule {
 def configure {
   bind(classOf[Service]).to(classOf[ServiceImpl]).in(classOf[Singleton])
   bind(classOf[CreditCardPaymentService])
   bind(new TypeLiteral[Bar[Foo]]{}).to(classOf[FooBarImpl])
   bind(classOf[PaymentService]).to(classOf[CreditCardPaymentService])

   bindInterceptor(Matchers.any(), Matchers.annotatedWith(classOf[AOP]), new AOPI())
 }
}

use

class MyModule extends AbstractModule with ScalaModule {
 def configure {
   bind[Service].to[ServiceImpl].in[Singleton]
   bind[CreditCardPaymentService]
   bind[Bar[Foo]].to[FooBarImpl]
   bind[PaymentService].to[CreditCardPaymentService]

   bindInterceptor[AOPI](methodMatcher = annotatedWith[AOP])
 }
}

'''Note''' This syntax allows binding to and from generic types. It doesn't currently allow bindings between wildcard types because the manifests for wildcard types don't provide access to type bounds.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
class MapOfKToSetOfVProvider[K, V](source: Key[Map[K, Set[V]]]) extends ProviderWithDependencies[Map[K, Set[V]]]

Provider for a Scala Immutable Map from a Java Map.

Provider for a Scala Immutable Map from a Java Map.

Example:

.toProvider(new MapOfKToSetOfVProvider[K, V](Key.get(typeLiteral[JMap[K, JSet[V]]])))

Attributes

Graph
Supertypes
trait ProviderWithDependencies[Map[K, Set[V]]]
trait HasDependencies
trait Provider[Map[K, Set[V]]]
trait Provider[Map[K, Set[V]]]
trait Provider[Map[K, Set[V]]]
class Object
trait Matchable
class Any
class MapProvider[K, V](source: Key[Map[K, V]]) extends ProviderWithDependencies[Map[K, V]]

Provider for a Scala Immutable Map from a Java Map.

Provider for a Scala Immutable Map from a Java Map.

Example:

.toProvider(new MapProvider[K, V](Key.get(typeLiteral[JMap[K, V]])))

Attributes

Graph
Supertypes
trait ProviderWithDependencies[Map[K, V]]
trait HasDependencies
trait Provider[Map[K, V]]
trait Provider[Map[K, V]]
trait Provider[Map[K, V]]
class Object
trait Matchable
class Any
class OptionProvider[T](source: Key[Optional[T]]) extends ProviderWithDependencies[Option[T]]

Provider for Scala's Option from Guava's Optional.

Provider for Scala's Option from Guava's Optional.

Example:

.toProvider(new OptionProvider[T](Key.get(typeLiteral[Optional[T]])))

Attributes

Graph
Supertypes
trait ProviderWithDependencies[Option[T]]
trait HasDependencies
trait Provider[Option[T]]
trait Provider[Option[T]]
trait Provider[Option[T]]
class Object
trait Matchable
class Any
trait ScalaMapBinder[K, V]

Analog to Guice's MapBinder

Analog to Guice's MapBinder

Use ScalaMapBinder.newMapBinder to create a map binder that is scala friendly.

Attributes

K

The key type for the bound map

V

The value type for the bound map

Companion:
object
Graph
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion:
trait
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
trait ScalaModule extends InternalModule[Binder]

Attributes

Companion:
object
Graph
Supertypes
trait InternalModule[Binder]
class Object
trait Matchable
class Any
Self type
AbstractModule

Attributes

Companion:
trait
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
sealed trait ScalaMultibinder[T]

Analog to Guice's Multibinder

Analog to Guice's Multibinder

Use ScalaMultibinder.newSetBinder to create a multibinder that is scala friendly.

Attributes

Companion:
object
Graph
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion:
trait
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Analog to Guice's OptionalBinder

Analog to Guice's OptionalBinder

Use ScalaOptionBinder.newOptionBinder to create an option binder that is scala friendly.

Attributes

Companion:
object
Graph
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion:
trait
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
trait ScalaPrivateModule extends InternalModule[PrivateBinder]

Attributes

Graph
Supertypes
trait InternalModule[PrivateBinder]
class Object
trait Matchable
class Any
Self type
PrivateModule
class SetProvider[T](val source: Key[Set[T]]) extends ProviderWithDependencies[Set[T]]

Provider for a Scala Immutable Set from a Java Set.

Provider for a Scala Immutable Set from a Java Set.

Example:

.toProvider( new SetProvider[T]( Key.get( typeLiteral[JSet[T]] ) ) )

Attributes

Graph
Supertypes
trait ProviderWithDependencies[Set[T]]
trait HasDependencies
trait Provider[Set[T]]
trait Provider[Set[T]]
trait Provider[Set[T]]
class Object
trait Matchable
class Any

Value members

Concrete methods

def cls[T : ClassTag]: Class[T]
inline def typeLiteral[T]: TypeLiteral[T]

Create a com.google.inject.TypeLiteral from a type parameter. Subtypes of scala.AnyVal will be converted to their corresponding Java wrapper classes.

Create a com.google.inject.TypeLiteral from a type parameter. Subtypes of scala.AnyVal will be converted to their corresponding Java wrapper classes.

Note that any methods that call this and accept T as a parameter must also be defined as inline to preserve T's complete structure (e.g., if T could represent a parameterized type)

Attributes