Class MainboardService

java.lang.Object
io.github.eggy03.ferrumx.windows.service.mainboard.MainboardService
All Implemented Interfaces:
OptionalCommonServiceInterface<Mainboard>

public class MainboardService extends Object implements OptionalCommonServiceInterface<Mainboard>
Service class for fetching mainboard information from the system.

This class executes the CimQuery.MAINBOARD_QUERY PowerShell command and maps the resulting JSON into a Mainboard object.

Thread safety

Methods of class are not thread safe.

Usage examples


 // Convenience API (creates its own short-lived session)
 MainboardService mainboardService = new MainboardService();
 Optional<Mainboard> mainboard = mainboardService.get();

 // API with re-usable session (caller manages session lifecycle)
 try (PowerShell session = PowerShell.openSession()) {
     MainboardService mainboardService = new MainboardService();
     Optional<Mainboard> mainboard = mainboardService.get(session);
 }
 
Since:
2.0.0
Author:
Egg-03
  • Constructor Details

    • MainboardService

      public MainboardService()
  • Method Details

    • get

      @NotNull public @NotNull Optional<Mainboard> get()
      Retrieves an Optional containing the system's mainboard information.

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

      Specified by:
      get in interface OptionalCommonServiceInterface<Mainboard>
      Returns:
      an Optional of Mainboard representing the system's mainboard.
      Throws:
      com.google.gson.JsonSyntaxException - if there is an error executing the PowerShell command or parsing the output.
    • get

      @NotNull public @NotNull Optional<Mainboard> get(com.profesorfalken.jpowershell.PowerShell powerShell)
      Retrieves an Optional containing the system's mainboard information using the caller's PowerShell session.
      Specified by:
      get in interface OptionalCommonServiceInterface<Mainboard>
      Parameters:
      powerShell - an existing PowerShell session managed by the caller
      Returns:
      an Optional of Mainboard representing the system's mainboard.
      Throws:
      com.google.gson.JsonSyntaxException - if there is an error executing the PowerShell command or parsing the output.