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

public interface CommonDMIMapper<S>
A common mapping interface for converting raw dmidecode output into strongly typed Java objects.

Provides default methods to parse structured DMI text data and map it into either:

  • a single Optional entity
  • a List of entities when multiple DMI blocks are present

The mapping process works by:

  1. Parsing key–value pairs from the raw DMI text
  2. Normalizing single-line and multi-line values
  3. Converting the extracted data into JSON internally
  4. Deserializing the JSON into the requested entity class using Jackson
Since:
0.1.0
  • Method Summary

    Modifier and Type
    Method
    Description
    default @NonNull tools.jackson.databind.ObjectMapper
    Configure the ObjectMapper to be used for JSON processing.
    default @NonNull Optional<S>
    mapToEntity(@Nullable String rawDMIData, @NonNull Class<S> mappableEntityClass)
    Maps raw dmidecode output into a single entity of type <S>.
    default @NonNull @Unmodifiable List<S>
    mapToList(@Nullable String rawDMIData, @NonNull Class<S> mappableEntityClass)
    Maps raw dmidecode output into a list of entities of type <S>.
  • Method Details

    • configureObjectMapper

      default @NonNull tools.jackson.databind.ObjectMapper configureObjectMapper()
      Configure the ObjectMapper to be used for JSON processing.

      The default implementation returns a new ObjectMapper instance with default configuration.

      Custom implementations may override this method to provide a custom-configured ObjectMapper.

      Returns:
      the ObjectMapper to 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 raw dmidecode output 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: or Characteristics:) 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 raw dmidecode output
      mappableEntityClass - the target entity class
      Returns:
      an Optional containing 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 raw dmidecode output 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 raw dmidecode output
      mappableEntityClass - the target entity class
      Returns:
      a non-null list of mapped entities
      Since:
      0.1.0