Class FitnessTopListAdapter

java.lang.Object
yearreview.app.data.sources.fitness.databse.FitnessTopListAdapter
All Implemented Interfaces:
TopListAdapter

public class FitnessTopListAdapter extends Object implements TopListAdapter
A TopListAdapter for the FitnessDatabase that outputs the Activities with their Distances and Durations.
Author:
ColdStone37
  • Field Details

    • LENGTH_ZERO

      private static final io.jenetics.jpx.Length LENGTH_ZERO
      Constant that stores a Length of 0 meters since Length does not provide one.
    • database

      private final FitnessDatabase database
      Database to adapt for the TopListGenerator.
    • activityIterator

      private final Iterator<Activity> activityIterator
      Iterator for the Activities provided by the FitnessDatabase.
    • currentActivity

      private Activity currentActivity
      Activity that is currently processed by the Adapter.
    • currentActivityDistance

      private io.jenetics.jpx.Length currentActivityDistance
      Distance of the current Activity that was already added to the TopListElement.
    • currentActivityDuration

      private Duration currentActivityDuration
      Duration of the current Activity that was already added to the TopListElement.
    • typeMap

      private final Map<ActivityType,TopListElement> typeMap
      Maps all ActivityTypes to their TopListElements.
  • Constructor Details

    • FitnessTopListAdapter

      public FitnessTopListAdapter(FitnessDatabase database)
      Constructs a FitnessDistanceTopListAdapter from a Database.
      Parameters:
      database - database to adapt for the TopListGenerator
  • Method Details

    • getElements

      public Collection<TopListElement> getElements(Instant t)
      Gets the TopListElements at a certain time. Iterates over the activity until one starts after t.
      Specified by:
      getElements in interface TopListAdapter
      Parameters:
      t - time until which all values should be added up to
      Returns:
      List of TopListElements with the Values summed up
    • getNewTopListElement

      private static TopListElement getNewTopListElement(String name)
      Constructs a new TopListElement with a given name and Distance and Duration Values.
      Parameters:
      name - name to use for the TopListElement
      Returns:
      new TopListElement