Class DiskPartitionService
java.lang.Object
io.github.eggy03.ferrumx.windows.service.storage.DiskPartitionService
- All Implemented Interfaces:
CommonServiceInterface<DiskPartition>
Service class for fetching information about disk partitions.
This class executes the CimQuery.DISK_PARTITION_QUERY PowerShell command
and maps the resulting JSON into a list of DiskPartition objects.
Thread safety
Methods of class are not thread safe.Usage examples
// Convenience API (creates its own short-lived session)
DiskPartitionService partitionService = new DiskPartitionService();
List<DiskPartition> partitions = partitionService.get();
// API with re-usable session (caller manages session lifecycle)
try (PowerShell session = PowerShell.openSession()) {
DiskPartitionService partitionService = new DiskPartitionService();
List<DiskPartition> partitions = partitionService.get(session);
}
- Since:
- 2.0.0
- Author:
- Egg-03
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NotNull List<DiskPartition> get()Retrieves a non-null list of disk partitions present in the system.@NotNull List<DiskPartition> get(com.profesorfalken.jpowershell.PowerShell powerShell) Retrieves a non-null list of disk partitions using the caller'sPowerShellsession.
-
Constructor Details
-
DiskPartitionService
public DiskPartitionService()
-
-
Method Details
-
get
Retrieves a non-null list of disk partitions present in the system.Each invocation creates and uses a short-lived PowerShell session internally.
- Specified by:
getin interfaceCommonServiceInterface<DiskPartition>- Returns:
- a list of
DiskPartitionobjects representing the disk partitions. Returns an empty list if no partitions are detected.
-
get
@NotNull public @NotNull List<DiskPartition> get(com.profesorfalken.jpowershell.PowerShell powerShell) Retrieves a non-null list of disk partitions using the caller'sPowerShellsession.- Specified by:
getin interfaceCommonServiceInterface<DiskPartition>- Parameters:
powerShell- an existing PowerShell session managed by the caller- Returns:
- a list of
DiskPartitionobjects representing the disk partitions. Returns an empty list if no partitions are detected.
-