CachingActivityMapper class
Wraps another {@link ActivityMapper} and caches the last activity it returned, to be re-used if we see the same place twice.
class CachingActivityMapper implements ActivityMapper { final ActivityMapper wrapped; Place lastPlace; Activity lastActivity; /** * Constructs a CachingActivityMapper object. * * @param wrapped an ActivityMapper object */ CachingActivityMapper(this.wrapped); Activity getActivity(Place place) { if (place != lastPlace) { lastPlace = place; lastActivity = wrapped.getActivity(place); } return lastActivity; } }
Implements
Constructors
new CachingActivityMapper(ActivityMapper wrapped) #
Constructs a CachingActivityMapper object.
@param wrapped an ActivityMapper object
CachingActivityMapper(this.wrapped);
Properties
final ActivityMapper wrapped #
final ActivityMapper wrapped
Methods
Activity getActivity(Place place) #
Returns the activity to run for the given {@link Place}, or null.
@param place a Place object
docs inherited from ActivityMapper
Activity getActivity(Place place) { if (place != lastPlace) { lastPlace = place; lastActivity = wrapped.getActivity(place); } return lastActivity; }