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