Class TimeKeeper

  • Direct Known Subclasses:
    GMTimes

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

      Fields 
      Modifier and Type Field Description
      protected long lastStateChange  
      protected java.lang.String state  
      protected java.util.Map<java.lang.String,​java.lang.Long> times  
    • Constructor Summary

      Constructors 
      Constructor Description
      TimeKeeper()  
      TimeKeeper​(java.lang.String lastState)  
      TimeKeeper​(java.lang.String lastState, long lastStateChange)  
      TimeKeeper​(java.util.Map<java.lang.String,​java.lang.Long> times)  
      TimeKeeper​(java.util.Map<java.lang.String,​java.lang.Long> times, java.lang.String lastState, long lastStateChange)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addTime​(java.lang.String state, long time)  
      void changeState​(java.lang.String newState, long ms)
      Adds time to the last state while updating the status of other parameters.
      boolean equals​(java.lang.Object o)  
      long getLastStateChange()  
      java.lang.String getState()  
      long getTime​(java.lang.String state)  
      java.util.Map<java.lang.String,​java.lang.Long> getTimes()  
      long getTotal()  
      int hashCode()  
      void renameState​(java.lang.String state, java.lang.String renameTo)  
      protected void resetState​(java.lang.String state)  
      protected void resetState​(java.lang.String state, long time)  
      void setLastStateChange​(long lastStateChange)  
      void setState​(java.lang.String state)  
      void setTime​(java.lang.String state, long time)
      Sets a specific time for a state.
      void setTimes​(java.util.Map<java.lang.String,​java.lang.Long> times)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • times

        protected java.util.Map<java.lang.String,​java.lang.Long> times
      • state

        protected java.lang.String state
      • lastStateChange

        protected long lastStateChange
    • Constructor Detail

      • TimeKeeper

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

        public TimeKeeper​(java.lang.String lastState,
                          long lastStateChange)
      • TimeKeeper

        public TimeKeeper​(java.lang.String lastState)
      • TimeKeeper

        public TimeKeeper​(java.util.Map<java.lang.String,​java.lang.Long> times)
      • TimeKeeper

        public TimeKeeper()
    • Method Detail

      • setTime

        public void setTime​(java.lang.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:
        java.lang.IllegalArgumentException - If given state is null
      • renameState

        public void renameState​(java.lang.String state,
                                java.lang.String renameTo)
      • changeState

        public void changeState​(java.lang.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:
        java.lang.IllegalArgumentException - If newState is null.
      • resetState

        protected void resetState​(java.lang.String state)
      • resetState

        protected void resetState​(java.lang.String state,
                                  long time)
      • getTime

        public long getTime​(java.lang.String state)
      • addTime

        public void addTime​(java.lang.String state,
                            long time)
      • getTotal

        public long getTotal()
      • getTimes

        public java.util.Map<java.lang.String,​java.lang.Long> getTimes()
      • setTimes

        public void setTimes​(java.util.Map<java.lang.String,​java.lang.Long> times)
      • getState

        public java.lang.String getState()
      • setState

        public void setState​(java.lang.String state)
      • getLastStateChange

        public long getLastStateChange()
      • setLastStateChange

        public void setLastStateChange​(long lastStateChange)
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

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

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object