Class TargetsHelper

java.lang.Object
ai.wanaku.cli.main.support.TargetsHelper

public class TargetsHelper extends Object
  • Method Details

    • getPrintableTargets

      public static List<Map<String,String>> getPrintableTargets(Map<String,List<ActivityRecord>> states)
      Converts a map of service states to a list of printable target representations. Each target is represented as a map containing display-friendly key-value pairs suitable for reporting or user interface purposes.
      Parameters:
      states - a map where keys are service names and values are lists of ActivityRecord objects representing the activities for each service. Must not be null.
      Returns:
      a list of maps, where each map represents a single target with the following keys:
      • "id" - the activity record ID
      • "service" - the service name
      • "active" - string representation of the activity status ("true"/"false")
      • "last_seen" - formatted timestamp of when the activity was last seen
      Returns an empty list if the input map is empty or contains no activities.
      Throws:
      NullPointerException - if states is null or contains null values
      RuntimeException - if formatLastSeenTimestamp fails for any activity record
      Since:
      1.0
      See Also:
    • createTargetMap

      public static Map<String,String> createTargetMap(String serviceName, ActivityRecord activityRecord)
      Creates a printable target map from a service name and activity record. This is a helper method to improve readability and maintainability.
      Parameters:
      serviceName - the name of the service
      activityRecord - the activity record to convert
      Returns:
      a map containing the printable representation of the target