Package org.eclipse.gef.common.adapt.inject

# Class AdaptableTypeListener

java.lang.Object
org.eclipse.gef.common.adapt.inject.AdaptableTypeListener

All Implemented Interfaces:
  `TypeListener`

public class AdaptableTypeListener extends Object implements TypeListener
A specific `TypeListener` to support adapter injection. It will register an `AdapterInjector`, which will perform the adapter injection, for each `IAdaptable` that is eligible (see `InjectAdapters`.

In order to function properly, an `AdaptableTypeListener` has to be bound in a Guice `Module` as follows:

     AdaptableTypeListener adaptableTypeListener = new AdaptableTypeListener();
     requestInjection(adaptableTypeListener);
     bindListener(Matchers.any(), adaptableTypeListener);

The call to `requestInjection()` is important to ensure that `setInjector(Injector)` will get injected. Without it, the `AdaptableTypeListener` will not function properly.

Clients should not register an `AdaptableTypeListener` themselves but rather install `AdapterInjectionSupport` in one of the `Module`s that are used by the `Injector`.

See Also:
  - `AdapterInjectionSupport`

## Constructor Summary

Constructors
Constructor
Description
`AdaptableTypeListener(AdapterInjectionSupport.LoggingMode loggingMode)`
Constructs a new `AdaptableTypeListener` and specifies the `AdapterInjectionSupport.LoggingMode` to use.

## Method Summary

Modifier and Type
Method
Description
`protected boolean`
`eligibleForAdapterInjection(Method method)`
Checks that the given method complies to the signature of `IAdaptable.setAdapter(TypeToken, Object, String)`.
`<I> void`
`hear(TypeLiteral<I> type, TypeEncounter<I> encounter)`
`void`
`setInjector(Injector injector)`
In order to work, the `AdaptableTypeListener` needs to obtain a reference to an `Injector`, which is forwarded to the `AdapterInjector`, which it registers for any `IAdaptable` encounters, to obtain the `AdapterMap` bindings to be injected.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### AdaptableTypeListener

public AdaptableTypeListener(AdapterInjectionSupport.LoggingMode loggingMode)
Constructs a new `AdaptableTypeListener` and specifies the `AdapterInjectionSupport.LoggingMode` to use. If in `AdapterInjectionSupport.LoggingMode.DEVELOPMENT` mode, binding-related information, warning, and error messages will be printed. If in `AdapterInjectionSupport.LoggingMode.PRODUCTION` mode, only error messages will be printed, and information and warning messages will be suppressed.

Parameters:
  `loggingMode` - The `AdapterInjectionSupport.LoggingMode` to use.

## Method Details

### eligibleForAdapterInjection

protected boolean eligibleForAdapterInjection(Method method)
Checks that the given method complies to the signature of `IAdaptable.setAdapter(TypeToken, Object, String)`.

Parameters:
  `method` - The `Method` to test.
Returns:
  `true` if the method has a compatible signature, `false` otherwise.

### hear

public <I> void hear(TypeLiteral<I> type, TypeEncounter<I> encounter)

Specified by:
  `hear` in interface `TypeListener`

### setInjector

@Inject public void setInjector(Injector injector)
In order to work, the `AdaptableTypeListener` needs to obtain a reference to an `Injector`, which is forwarded to the `AdapterInjector`, which it registers for any `IAdaptable` encounters, to obtain the `AdapterMap` bindings to be injected.

Parameters:
  `injector` - The injector that is forwarded (used to inject) the `AdapterInjector`.