Class TimeKeeper

java.lang.Object
com.djrapitops.plan.gathering.domain.TimeKeeper
Direct Known Subclasses:
GMTimes

public class TimeKeeper extends Object
Keeps track of time spent in each state.
  • Field Details

    • times

      protected Map<String,​Long> times
    • state

      protected String state
    • lastStateChange

      protected long lastStateChange
  • Constructor Details

    • TimeKeeper

      public TimeKeeper(Map<String,​Long> times, String lastState, long lastStateChange)
    • TimeKeeper

      public TimeKeeper(String lastState, long lastStateChange)
    • TimeKeeper

      public TimeKeeper(String lastState)
    • TimeKeeper

      public TimeKeeper(Map<String,​Long> times)
    • TimeKeeper

      public TimeKeeper()
  • Method Details

    • setTime

      public void setTime(String state, long time)
      Sets a specific time for a state.
      Parameters:
      state - State to set
      time - Time in ms the state has been active for
      Throws:
      IllegalArgumentException - If given state is null
    • renameState

      public void renameState(String state, String renameTo)
    • changeState

      public void changeState(String newState, long ms)
      Adds time to the last state while updating the status of other parameters.
      Parameters:
      newState - New State seen in.
      ms - Epoch ms the change occurred.
      Throws:
      IllegalArgumentException - If newState is null.
    • resetState

      protected void resetState(String state)
    • resetState

      protected void resetState(String state, long time)
    • getTime

      public long getTime(String state)
    • addTime

      public void addTime(String state, long time)
    • getTotal

      public long getTotal()
    • getTimes

      public Map<String,​Long> getTimes()
    • setTimes

      public void setTimes(Map<String,​Long> times)
    • getState

      public String getState()
    • setState

      public void setState(String state)
    • getLastStateChange

      public long getLastStateChange()
    • setLastStateChange

      public void setLastStateChange(long lastStateChange)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object