Record Class ProjectWorkTimeSnapshot

java.lang.Object
java.lang.Record
dev.turboism.sdk.cubism.worktime.ProjectWorkTimeSnapshot
Record Components:
editorForeground - whether the Cubism process was foreground at the observation
sessionForegroundTime - foreground time of the project that is open now; zero while no project is open, because idle editor time is not project work
activeProject - project whose tab was active, empty when none was open
projects - all projects with recorded work time, ordered for display
observedAt - the instant this snapshot was observed

@CubismEditor public record ProjectWorkTimeSnapshot(boolean editorForeground, Duration sessionForegroundTime, Optional<ProjectWorkTime> activeProject, List<ProjectWorkTime> projects, Instant observedAt) extends Record
Immutable view of the runtime work-time tracker at one observation.

projects is ordered by descending ProjectWorkTime.totalTime(), with the project name as a deterministic tie-breaker. The active project, when present, is also one of the listed projects.

  • Constructor Details

  • Method Details

    • empty

      public static ProjectWorkTimeSnapshot empty(Instant observedAt)
      Returns the canonical empty snapshot at observedAt.
    • project

      public Optional<ProjectWorkTime> project(String projectKey)
      Looks up one recorded project by its opaque key.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • editorForeground

      public boolean editorForeground()
      Returns the value of the editorForeground record component.
      Returns:
      the value of the editorForeground record component
    • sessionForegroundTime

      public Duration sessionForegroundTime()
      Returns the value of the sessionForegroundTime record component.
      Returns:
      the value of the sessionForegroundTime record component
    • activeProject

      public Optional<ProjectWorkTime> activeProject()
      Returns the value of the activeProject record component.
      Returns:
      the value of the activeProject record component
    • projects

      public List<ProjectWorkTime> projects()
      Returns the value of the projects record component.
      Returns:
      the value of the projects record component
    • observedAt

      public Instant observedAt()
      Returns the value of the observedAt record component.
      Returns:
      the value of the observedAt record component