Interface CommonDMIMapper<S>
- Type Parameters:
S- the entity type returned by the service implementation
- All Known Implementing Classes:
DMIBaseboardMapper,DMIBIOSLanguageMapper,DMIBIOSMapper,DMICacheMapper,DMIChassisMapper,DMIMemoryDeviceMapper,DMIPhysicalMemoryArrayMapper,DMIPortableBatteryMapper,DMIPortConnectorInformationMapper,DMIProcessorMapper,DMISystemMapper,DMISystemSlotsMapper
dmidecode output
into strongly typed Java objects.
Provides default methods to parse structured DMI text data and map it into either:
The mapping process works by:
- Parsing key–value pairs from the raw DMI text
- Normalizing single-line and multi-line values
- Converting the extracted data into JSON internally
- Deserializing the JSON into the requested entity class using Jackson
- Since:
- 0.1.0
-
Method Summary
Modifier and TypeMethodDescriptiondefault @NonNull tools.jackson.databind.ObjectMapperConfigure theObjectMapperto be used for JSON processing.mapToEntity(@Nullable String rawDMIData, @NonNull Class<S> mappableEntityClass) Maps rawdmidecodeoutput into a single entity of type<S>.default @NonNull @Unmodifiable List<S> Maps rawdmidecodeoutput into a list of entities of type<S>.
-
Method Details
-
configureObjectMapper
default @NonNull tools.jackson.databind.ObjectMapper configureObjectMapper()Configure theObjectMapperto be used for JSON processing.The default implementation returns a new
ObjectMapperinstance with default configuration.Custom implementations may override this method to provide a custom-configured
ObjectMapper.- Returns:
- the
ObjectMapperto use - Since:
- 0.3.0
-
mapToEntity
@FragileMethod(type=INTERFACE_DEFAULT_METHOD, reason="Parsing formatted human readable dmidecode output is always error-prone and subject to change without notice", requiresReplacement=true) default @NonNull Optional<S> mapToEntity(@Nullable String rawDMIData, @NonNull Class<S> mappableEntityClass) Maps rawdmidecodeoutput into a single entity of type<S>.If multiple DMI blocks are present in the input, the last parsed entity is returned.
Multi-line values (for example, lists under keys like
Flags:orCharacteristics:) are automatically aggregated into lists.Example schema:
# dmidecode 3.6 Getting SMBIOS data from sysfs. SMBIOS 3.3.0 present. Handle 0x0011, DMI type 4, 48 bytes Processor Information Socket Designation: FP6 Type: Central Processor Family: Zen Flags: FPU (Floating-point unit on-chip) VME (Virtual mode extension) Version: AMD Ryzen 3 5300U with Radeon Graphics Characteristics: 64-bit capable Multi-Core- Parameters:
rawDMIData- the rawdmidecodeoutputmappableEntityClass- the target entity class- Returns:
- an
Optionalcontaining the mapped entity, or empty if no mappable data is found - Since:
- 0.1.0
-
mapToList
@FragileMethod(type=INTERFACE_DEFAULT_METHOD, reason="Parsing formatted human readable dmidecode output is always error-prone and subject to change without notice", requiresReplacement=true) default @NonNull @Unmodifiable List<S> mapToList(@Nullable String rawDMIData, @NonNull Class<S> mappableEntityClass) Maps rawdmidecodeoutput into a list of entities of type<S>.Each DMI block separated by a blank line is treated as an independent entity. Empty or non-mappable blocks are ignored.
This method is useful for DMI structures that naturally occur multiple times, such as cache information, memory devices, or processor entries.
Example schema:
# dmidecode 3.6 Getting SMBIOS data from sysfs. SMBIOS 3.3.0 present. Handle 0x000E, DMI type 7, 27 bytes Cache Information Socket Designation: L1 - Cache Configuration: Enabled, Not Socketed, Level 1 Supported SRAM Types: Pipeline Burst Associativity: 8-way Set-associative Handle 0x000F, DMI type 7, 27 bytes Cache Information Socket Designation: L2 - Cache Configuration: Enabled, Not Socketed, Level 2 Supported SRAM Types: Pipeline Burst Associativity: 8-way Set-associative Handle 0x0010, DMI type 7, 27 bytes Cache Information Socket Designation: L3 - Cache Configuration: Enabled, Not Socketed, Level 3 Supported SRAM Types: Pipeline Burst Associativity: 16-way Set-associative- Parameters:
rawDMIData- the rawdmidecodeoutputmappableEntityClass- the target entity class- Returns:
- a non-null list of mapped entities
- Since:
- 0.1.0
-