roboguice.inject
Interface ExtraConverter<FROM,TO>

Type Parameters:
FROM -
TO -

public interface ExtraConverter<FROM,TO>

An object capable of providing objects of type TO, using extras of type FROM.

Converters enable you to convert Android Extras to complex objects. For instance, sending a long timestamp as an extra, and getting a Date injected.

Once you have created an ExtraConverter implementation, you should bind it in your module configuration. Usage example: bind(new TypeLiteral<ExtraConverter<Long, Date>>() ).to(DateExtraConverter.class);

Usage in your components is as simple as : \@InjectExtra("timestampExtra") protected Date date;

You will usually want your converters to be singletons, so you should annotate them with Singleton.

Please notice that the context in which the bean that gets the extra injected is scoped should implements InjectorProvider to get the convert mechanism to work. This is because the ExtrasMembersInjector need an Injector to get an ExtraConverter instance.

Author:
Pierre-Yves Ricau (py.ricau+roboguice@gmail.com)

Method Summary
 TO convert(FROM from)
          Converts an instance of FROM to an instances of TO.
 

Method Detail

convert

TO convert(FROM from)
Converts an instance of FROM to an instances of TO. May return null.

Parameters:
from - The extra value to be converted.
Returns:
The converted object that will be injected.


Copyright © 2012. All Rights Reserved.