Class ComputerSystemProductService
java.lang.Object
io.github.eggy03.ferrumx.windows.service.product.ComputerSystemProductService
- All Implemented Interfaces:
OptionalCommonServiceInterface<ComputerSystemProduct>
public class ComputerSystemProductService
extends Object
implements OptionalCommonServiceInterface<ComputerSystemProduct>
Service class for fetching the system product information.
This class executes the CimQuery.COMPUTER_SYSTEM_PRODUCT
PowerShell command
and maps the resulting JSON into an Optional
ComputerSystemProduct
object.
Thread safety
Methods of class are not thread safe.Usage examples
// Convenience API (creates its own short-lived session)
ComputerSystemProductService productService = new ComputerSystemProductService();
Optional<ComputerSystemProduct> product = productService.get();
// API with re-usable session (caller manages session lifecycle)
try (PowerShell session = PowerShell.openSession()) {
ComputerSystemProductService productService = new ComputerSystemProductService();
Optional<ComputerSystemProduct> product = productService.get(session);
}
- Since:
- 2.0.0
- Author:
- Egg-03
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
ComputerSystemProductService
public ComputerSystemProductService()
-
-
Method Details
-
get
Retrieves anOptional
containing the computer system product information.Each invocation creates and uses a short-lived PowerShell session internally.
- Specified by:
get
in interfaceOptionalCommonServiceInterface<ComputerSystemProduct>
- Returns:
- an
Optional
ofComputerSystemProduct
representing the computer system as a product. ReturnsOptional.empty()
if no product information is detected.
-
get
Retrieves anOptional
containing the computer system product information using the caller'sPowerShell
session.- Specified by:
get
in interfaceOptionalCommonServiceInterface<ComputerSystemProduct>
- Parameters:
powerShell
- an existing PowerShell session managed by the caller- Returns:
- an
Optional
ofComputerSystemProduct
representing the computer system as a product. ReturnsOptional.empty()
if no product information is detected.
-