Class DiskDriveService

java.lang.Object
io.github.eggy03.ferrumx.windows.service.storage.DiskDriveService
All Implemented Interfaces:
CommonServiceInterface<DiskDrive>

public class DiskDriveService extends Object implements CommonServiceInterface<DiskDrive>
Service class for fetching information about disk drives.

This class executes the CimQuery.DISK_QUERY PowerShell command and maps the resulting JSON into a list of DiskDrive objects.

Thread safety

Methods of class are not thread safe.

Usage examples


 // Convenience API (creates its own short-lived session)
 DiskDriveService diskService = new DiskDriveService();
 List<DiskDrive> drives = diskService.get();

 // API with re-usable session (caller manages session lifecycle)
 try (PowerShell session = PowerShell.openSession()) {
     DiskDriveService diskService = new DiskDriveService();
     List<DiskDrive> drives = diskService.get(session);
 }
 
Since:
2.0.0
Author:
Egg-03
  • Constructor Details

    • DiskDriveService

      public DiskDriveService()
  • Method Details

    • get

      @NotNull public @NotNull List<DiskDrive> get()
      Retrieves a non-null list of disk drives present in the system.

      Each invocation creates and uses a short-lived PowerShell session internally.

      Specified by:
      get in interface CommonServiceInterface<DiskDrive>
      Returns:
      a list of DiskDrive objects representing the disk drives. Returns an empty list if no disk drives are detected.
    • get

      @NotNull public @NotNull List<DiskDrive> get(com.profesorfalken.jpowershell.PowerShell powerShell)
      Retrieves a non-null list of disk drives using the caller's PowerShell session.
      Specified by:
      get in interface CommonServiceInterface<DiskDrive>
      Parameters:
      powerShell - an existing PowerShell session managed by the caller
      Returns:
      a list of DiskDrive objects representing the disk drives. Returns an empty list if no disk drives are detected.