From 3d387a38d6cdc64fcb3ce225db38632843ef4666 Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Mon, 30 Mar 2026 09:28:09 +0530 Subject: [PATCH 01/19] refactor(mapper): enforce unmodifiable lists and non-null returns - Add `@Unmodifiable` annotation to `mapToList` return type - Ensure `mapToList` returns an unmodifiable list using `Collections.unmodifiableList` - Add `@NotNull` annotation to `mapToEntity` and `mapToList` return types --- .../io/github/eggy03/dmidecode/mapper/CommonDMIMapper.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/github/eggy03/dmidecode/mapper/CommonDMIMapper.java b/src/main/java/io/github/eggy03/dmidecode/mapper/CommonDMIMapper.java index 2acae89..3056266 100644 --- a/src/main/java/io/github/eggy03/dmidecode/mapper/CommonDMIMapper.java +++ b/src/main/java/io/github/eggy03/dmidecode/mapper/CommonDMIMapper.java @@ -9,6 +9,7 @@ import com.google.gson.JsonElement; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Unmodifiable; import java.util.ArrayList; import java.util.Collections; @@ -84,7 +85,7 @@ public interface CommonDMIMapper { * no mappable data is found * @since 0.1.0 */ - default Optional mapToEntity(@Nullable String rawDMIData, @NotNull Class mappableEntityClass) { + default @NotNull Optional mapToEntity(@Nullable String rawDMIData, @NotNull Class mappableEntityClass) { if(rawDMIData==null) return Optional.empty(); @@ -184,7 +185,7 @@ default Optional mapToEntity(@Nullable String rawDMIData, @NotNull Class m * @return a non-null list of mapped entities * @since 0.1.0 */ - default List mapToList(@Nullable String rawDMIData, @NotNull Class mappableEntityClass) { + default @NotNull @Unmodifiable List mapToList(@Nullable String rawDMIData, @NotNull Class mappableEntityClass) { if(rawDMIData==null) return Collections.emptyList(); @@ -250,6 +251,6 @@ default List mapToList(@Nullable String rawDMIData, @NotNull Class mappabl key.setLength(0); value = null; } - return entityList; + return entityList.isEmpty() ? Collections.emptyList() : Collections.unmodifiableList(new ArrayList<>(entityList)); } } \ No newline at end of file From 2a7b7a77d97d815852eb12d0953fd879e536f7ba Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Mon, 30 Mar 2026 15:28:30 +0530 Subject: [PATCH 02/19] feat(build): introduce immutables and jackson - update project version to `0.2.0-SNAPSHOT` - add `immutables` and `jackson` BOMs and dependencies - refactor source generation plugins to support `immutables` and standard attachment - update `assertj-core` from `3.27.6` to `3.27.7` --- pom.xml | 113 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 59 insertions(+), 54 deletions(-) diff --git a/pom.xml b/pom.xml index 8714ffe..3466098 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.github.eggy03 dmidecode4j - 0.1.1 + 0.2.0-SNAPSHOT 8 @@ -29,12 +29,14 @@ egg-03 + 2.12.1 1.18.42 2.13.2 + 3.1.1 26.0.2 6.0.0 5.20.0 - 3.27.6 + 3.27.7 1.5.0 2.0.17 @@ -48,9 +50,44 @@ 1.1.0 0.9.0 0.8.14 + 3.4.0 + + + + org.immutables + bom + ${immutables.version} + pom + import + + + tools.jackson + jackson-bom + ${jackson.version} + pom + import + + + + + + org.immutables + value + provided + + + com.fasterxml.jackson.core + jackson-annotations + compile + + + tools.jackson.core + jackson-databind + compile + com.google.code.gson gson @@ -137,6 +174,11 @@ lombok ${lombok.version} + + org.immutables + value + ${immutables.version} + @@ -147,76 +189,39 @@ ${surefire.version} - + - org.projectlombok - lombok-maven-plugin - ${lombok.maven.plugin.version} + org.codehaus.mojo + build-helper-maven-plugin + ${build.helper.maven.plugin.version} + add-source generate-sources - delombok - - - - - false - ${project.build.directory}/delombok - src/main/java - - - - org.projectlombok - lombok - ${lombok.version} - - - - - - - org.apache.maven.plugins - maven-antrun-plugin - ${maven.antrun.plugin.version} - - - generate-delomboked-sources-jar - package - - run + add-source - - - + + ${project.build.directory}/generated-sources/annotations + - + - org.codehaus.mojo - build-helper-maven-plugin - ${build.helper.maven.plugin.version} + org.apache.maven.plugins + maven-source-plugin + ${maven.source.plugin.version} - attach-delomboked-sources-jar + attach-sources package - attach-artifact + jar - - - - ${project.build.directory}/${project.build.finalName}-sources.jar - jar - sources - - - From 45ce4ebcb386e597aa9506110ff82ba1f9675562 Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Mon, 30 Mar 2026 15:32:42 +0530 Subject: [PATCH 03/19] refactor(entity): migrate to Immutables - introduce `@ImmutableStyle` annotation for `Immutables` configuration, which groups together, a variety of annotations under one custom annotation. All entity classes apply this annotation. - replace all `Lombok` annotations for these entities with `Immutable `equivalents. Note that future commits will gradually remove all traces of `Lombok` from the codebase. - refactor concrete entities to abstract classes with their names prefixed with "Abstract" such that the generated concrete classes has their prefixes trimmed. - switch JSON serialization/deserialization annotations from Gson to Jackson. Note that future commits will remove all traces of `GSON` in favor of `Jackson` integration. - replace JetBrains `@Nullable` Annotations with Jspecify. Note that future commits replace all `JetBrains` annotations with equivalent `Jspecify` annotations. - remove custom `toString()` method and update `@since` version - update corresponding tests to use the `Immutables` builder pattern - update documentation to reflect the Immutable builder style examples - update `@since` remove `@author` --- pom.xml | 8 +- .../dmidecode/annotation/ImmutableStyle.java | 22 +++ .../entity/board/AbstractDMIBIOS.java | 81 ++++++++ .../entity/board/AbstractDMIBIOSLanguage.java | 52 +++++ .../entity/board/AbstractDMIBaseboard.java | 86 ++++++++ .../entity/board/AbstractDMIChassis.java | 104 ++++++++++ .../AbstractDMIPortConnectorInformation.java | 64 ++++++ .../entity/board/AbstractDMISystemSlots.java | 75 +++++++ .../dmidecode/entity/board/DMIBIOS.java | 91 --------- .../entity/board/DMIBIOSLanguage.java | 62 ------ .../dmidecode/entity/board/DMIBaseboard.java | 95 --------- .../dmidecode/entity/board/DMIChassis.java | 113 ----------- .../board/DMIPortConnectorInformation.java | 74 ------- .../entity/board/DMISystemSlots.java | 76 -------- .../memory/AbstractDMIMemoryDevice.java | 173 +++++++++++++++++ .../AbstractDMIPhysicalMemoryArray.java | 68 +++++++ .../entity/memory/DMIMemoryDevice.java | 183 ------------------ .../entity/memory/DMIPhysicalMemoryArray.java | 78 -------- .../AbstractDMIPortableBattery.java | 88 +++++++++ .../entity/peripheral/DMIPortableBattery.java | 86 -------- .../entity/processor/AbstractDMICache.java | 94 +++++++++ .../processor/AbstractDMIProcessor.java | 144 ++++++++++++++ .../dmidecode/entity/processor/DMICache.java | 104 ---------- .../entity/processor/DMIProcessor.java | 154 --------------- .../entity/system/AbstractDMISystem.java | 76 ++++++++ .../dmidecode/entity/system/DMISystem.java | 86 -------- .../board/DMIBIOSLanguageServiceTest.java | 4 +- .../service/board/DMIBIOSServiceTest.java | 2 +- .../board/DMIBaseboardServiceTest.java | 4 +- .../service/board/DMIChassisServiceTest.java | 4 +- ...MIPortConnectorInformationServiceTest.java | 2 +- .../board/DMISystemSlotsServiceTest.java | 2 +- .../memory/DMIMemoryDeviceServiceTest.java | 2 +- .../DMIPhysicalMemoryArrayServiceTest.java | 4 +- .../DMIPortableBatteryServiceTest.java | 2 +- .../processor/DMICacheServiceTest.java | 2 +- .../processor/DMIProcessorServiceTest.java | 2 +- .../service/system/DMISystemServiceTest.java | 4 +- 38 files changed, 1148 insertions(+), 1223 deletions(-) create mode 100644 src/main/java/io/github/eggy03/dmidecode/annotation/ImmutableStyle.java create mode 100644 src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBIOS.java create mode 100644 src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBIOSLanguage.java create mode 100644 src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBaseboard.java create mode 100644 src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIChassis.java create mode 100644 src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIPortConnectorInformation.java create mode 100644 src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMISystemSlots.java delete mode 100644 src/main/java/io/github/eggy03/dmidecode/entity/board/DMIBIOS.java delete mode 100644 src/main/java/io/github/eggy03/dmidecode/entity/board/DMIBIOSLanguage.java delete mode 100644 src/main/java/io/github/eggy03/dmidecode/entity/board/DMIBaseboard.java delete mode 100644 src/main/java/io/github/eggy03/dmidecode/entity/board/DMIChassis.java delete mode 100644 src/main/java/io/github/eggy03/dmidecode/entity/board/DMIPortConnectorInformation.java delete mode 100644 src/main/java/io/github/eggy03/dmidecode/entity/board/DMISystemSlots.java create mode 100644 src/main/java/io/github/eggy03/dmidecode/entity/memory/AbstractDMIMemoryDevice.java create mode 100644 src/main/java/io/github/eggy03/dmidecode/entity/memory/AbstractDMIPhysicalMemoryArray.java delete mode 100644 src/main/java/io/github/eggy03/dmidecode/entity/memory/DMIMemoryDevice.java delete mode 100644 src/main/java/io/github/eggy03/dmidecode/entity/memory/DMIPhysicalMemoryArray.java create mode 100644 src/main/java/io/github/eggy03/dmidecode/entity/peripheral/AbstractDMIPortableBattery.java delete mode 100644 src/main/java/io/github/eggy03/dmidecode/entity/peripheral/DMIPortableBattery.java create mode 100644 src/main/java/io/github/eggy03/dmidecode/entity/processor/AbstractDMICache.java create mode 100644 src/main/java/io/github/eggy03/dmidecode/entity/processor/AbstractDMIProcessor.java delete mode 100644 src/main/java/io/github/eggy03/dmidecode/entity/processor/DMICache.java delete mode 100644 src/main/java/io/github/eggy03/dmidecode/entity/processor/DMIProcessor.java create mode 100644 src/main/java/io/github/eggy03/dmidecode/entity/system/AbstractDMISystem.java delete mode 100644 src/main/java/io/github/eggy03/dmidecode/entity/system/DMISystem.java diff --git a/pom.xml b/pom.xml index 3466098..5786cb3 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ 1.18.42 2.13.2 3.1.1 - 26.0.2 + 1.0.0 6.0.0 5.20.0 3.27.7 @@ -100,9 +100,9 @@ provided - org.jetbrains - annotations - ${jetbrains.annotations.version} + org.jspecify + jspecify + ${jspecify.version} org.slf4j diff --git a/src/main/java/io/github/eggy03/dmidecode/annotation/ImmutableStyle.java b/src/main/java/io/github/eggy03/dmidecode/annotation/ImmutableStyle.java new file mode 100644 index 0000000..47e9441 --- /dev/null +++ b/src/main/java/io/github/eggy03/dmidecode/annotation/ImmutableStyle.java @@ -0,0 +1,22 @@ +package io.github.eggy03.dmidecode.annotation; + +import org.immutables.value.Value; +import tools.jackson.databind.annotation.JsonSerialize; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.PACKAGE, ElementType.TYPE}) +@Retention(RetentionPolicy.CLASS) // Make it class retention for incremental compilation +@JsonSerialize // Jackson automatic integration +@Value.Style( + typeAbstract = {"Abstract*"}, // 'Abstract' prefix will be detected and trimmed + typeImmutable = "*", // No prefix or suffix for generated immutable type + visibility = Value.Style.ImplementationVisibility.PUBLIC, // Generated class will be always public + builder = "new", // construct builder using 'new' instead of factory method (required for Jackson). + // Generated builders will have attributes annotated with @JsonProperty so deserialization will work properly. + defaults = @Value.Immutable(copy = true) // Enable copy methods +) +public @interface ImmutableStyle {} diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBIOS.java b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBIOS.java new file mode 100644 index 0000000..c1e294b --- /dev/null +++ b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBIOS.java @@ -0,0 +1,81 @@ +/* + * © 2026 The dmidecode4j contributors + * Licensed under the MIT License. + * See the LICENSE file in the project root for more information. + */ +package io.github.eggy03.dmidecode.entity.board; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.github.eggy03.dmidecode.annotation.ImmutableStyle; +import org.immutables.value.Value; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +import java.util.List; + +/** + * Immutable representation of BIOS information retrieved via DMI. + *

+ * Fields correspond to properties reported by {@code dmidecode} for the BIOS + * (Type 0) SMBIOS structure. + *

+ *

+ * Instances of this class are thread-safe. + *

+ * + *

Usage example

+ *
{@code
+ * DMIBIOS bios = new DMIBIOS.Builder()
+ *     .vendor("American Megatrends Inc.")
+ *     .version("F10")
+ *     .releaseDate("07/15/2023")
+ *     .build();
+ *
+ * // Create a modified copy
+ * DMIBIOS updated = bios
+ *     .withVersion("F11");
+ * }
+ * + * @since 0.2.0 + */ +@Value.Immutable +@ImmutableStyle +@NullMarked +public abstract class AbstractDMIBIOS { + + @JsonProperty("Vendor") + @Nullable + public abstract String vendor(); + + @JsonProperty("Version") + @Nullable + public abstract String version(); + + @JsonProperty("Release Date") + @Nullable + public abstract String releaseDate(); + + @JsonProperty("Address") + @Nullable + public abstract String address(); + + @JsonProperty("Runtime Size") + @Nullable + public abstract String runtimeSize(); + + @JsonProperty("ROM Size") + @Nullable + public abstract String romSize(); + + @JsonProperty("Characteristics") + @Nullable + public abstract List<@Nullable String> characteristics(); + + @JsonProperty("BIOS Revision") + @Nullable + public abstract String biosRevision(); + + @JsonProperty("Firmware Revision") + @Nullable + public abstract String firmwareRevision(); +} diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBIOSLanguage.java b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBIOSLanguage.java new file mode 100644 index 0000000..c8eac69 --- /dev/null +++ b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBIOSLanguage.java @@ -0,0 +1,52 @@ +/* + * © 2026 The dmidecode4j contributors + * Licensed under the MIT License. + * See the LICENSE file in the project root for more information. + */ +package io.github.eggy03.dmidecode.entity.board; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.github.eggy03.dmidecode.annotation.ImmutableStyle; +import org.immutables.value.Value; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +import java.util.List; + +/** + * Immutable representation of BIOS language information retrieved via DMI. + *

+ * Fields correspond to properties reported by {@code dmidecode} for the BIOS + * Language (Type 13) SMBIOS structure. + *

+ *

+ * Instances of this class are thread-safe. + *

+ * + *

Usage example

+ *
{@code
+ * DMIBIOSLanguage language = new DMIBIOSLanguage.Builder()
+ *     .installableLanguages(List.of("en|US", "fr|FR"))
+ *     .currentLanguage("en|US")
+ *     .build();
+ *
+ * // Create a modified copy
+ * DMIBIOSLanguage updated = language
+ *     .withCurrentLanguage("fr|FR");
+ * }
+ * + * @since 0.2.0 + */ +@Value.Immutable +@ImmutableStyle +@NullMarked +public abstract class AbstractDMIBIOSLanguage { + + @JsonProperty("Installable Languages") + @Nullable + public abstract List<@Nullable String> installableLanguages(); + + @JsonProperty("Currently Installed Language") + @Nullable + public abstract String currentLanguage(); +} diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBaseboard.java b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBaseboard.java new file mode 100644 index 0000000..beec919 --- /dev/null +++ b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBaseboard.java @@ -0,0 +1,86 @@ +/* + * © 2026 The dmidecode4j contributors + * Licensed under the MIT License. + * See the LICENSE file in the project root for more information. + */ +package io.github.eggy03.dmidecode.entity.board; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.github.eggy03.dmidecode.annotation.ImmutableStyle; +import org.immutables.value.Value; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +import java.util.List; + +/** + * Immutable representation of a baseboard (motherboard) device retrieved via DMI. + *

+ * Fields correspond to properties reported by {@code dmidecode} for the Base Board + * (Type 2) SMBIOS structure. + *

+ *

+ * Instances of this class are thread-safe. + *

+ * + *

Usage example

+ *
{@code
+ * DMIBaseboard board = new DMIBaseboard.Builder()
+ *     .manufacturer("ASUSTeK COMPUTER INC.")
+ *     .productName("PRIME B550M-A")
+ *     .serialNumber("ABC123456")
+ *     .build();
+ *
+ * // Create a modified copy
+ * DMIBaseboard updated = board
+ *     .withSerialNumber("XYZ987654")
+ *     .withProductName("PRIME A320");
+ * }
+ * + * @since 0.2.0 + */ +@Value.Immutable +@ImmutableStyle +@NullMarked +public abstract class AbstractDMIBaseboard { + + @JsonProperty("Manufacturer") + @Nullable + public abstract String manufacturer(); + + @JsonProperty("Product Name") + @Nullable + public abstract String productName(); + + @JsonProperty("Version") + @Nullable + public abstract String version(); + + @JsonProperty("Serial Number") + @Nullable + public abstract String serialNumber(); + + @JsonProperty("Asset Tag") + @Nullable + public abstract String assetTag(); + + @JsonProperty("Features") + @Nullable + public abstract List<@Nullable String> features(); + + @JsonProperty("Location In Chassis") + @Nullable + public abstract String locationInChassis(); + + @JsonProperty("Chassis Handle") + @Nullable + public abstract String chassisHandle(); + + @JsonProperty("Type") + @Nullable + public abstract String type(); + + @JsonProperty("Contained Object Handles") + @Nullable + public abstract Integer containedObjectHandles(); +} diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIChassis.java b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIChassis.java new file mode 100644 index 0000000..48cfc1e --- /dev/null +++ b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIChassis.java @@ -0,0 +1,104 @@ +/* + * © 2026 The dmidecode4j contributors + * Licensed under the MIT License. + * See the LICENSE file in the project root for more information. + */ +package io.github.eggy03.dmidecode.entity.board; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.github.eggy03.dmidecode.annotation.ImmutableStyle; +import org.immutables.value.Value; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +/** + * Immutable representation of system chassis information retrieved via DMI. + *

+ * Fields correspond to properties reported by {@code dmidecode} for the Chassis + * (Type 3) SMBIOS structure. + *

+ *

+ * Instances of this class are thread-safe. + *

+ * + *

Usage example

+ *
{@code
+ * DMIChassis chassis = new DMIChassis.Builder()
+ *     .manufacturer("Dell Inc.")
+ *     .type("Desktop")
+ *     .serialNumber("ABC123456")
+ *     .build();
+ *
+ * // Create a modified copy
+ * DMIChassis updated = chassis
+ *     .withAssetTag("OFFICE-PC-01");
+ * }
+ * + * @since 0.2.0 + */ +@Value.Immutable +@ImmutableStyle +@NullMarked +public abstract class AbstractDMIChassis { + + @JsonProperty("Manufacturer") + @Nullable + public abstract String manufacturer(); + + @JsonProperty("Type") + @Nullable + public abstract String type(); + + @JsonProperty("Lock") + @Nullable + public abstract String lock(); + + @JsonProperty("Version") + @Nullable + public abstract String version(); + + @JsonProperty("Serial Number") + @Nullable + public abstract String serialNumber(); + + @JsonProperty("Asset Tag") + @Nullable + public abstract String assetTag(); + + @JsonProperty("Boot-up State") + @Nullable + public abstract String bootUpState(); + + @JsonProperty("Power Supply State") + @Nullable + public abstract String powerSupplyState(); + + @JsonProperty("Thermal State") + @Nullable + public abstract String thermalState(); + + @JsonProperty("Security Status") + @Nullable + public abstract String securityStatus(); + + @JsonProperty("OEM Information") + @Nullable + public abstract String oemInformation(); + + @JsonProperty("Height") + @Nullable + public abstract String height(); + + @JsonProperty("Number Of Power Cords") + @Nullable + public abstract Integer numberOfPowerCords(); + + @JsonProperty("Contained Elements") + @Nullable + public abstract Integer containedElements(); + + @JsonProperty("SKU Number") + @Nullable + public abstract String skuNumber(); + +} diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIPortConnectorInformation.java b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIPortConnectorInformation.java new file mode 100644 index 0000000..27f1df2 --- /dev/null +++ b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIPortConnectorInformation.java @@ -0,0 +1,64 @@ +/* + * © 2026 The dmidecode4j contributors + * Licensed under the MIT License. + * See the LICENSE file in the project root for more information. + */ +package io.github.eggy03.dmidecode.entity.board; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.github.eggy03.dmidecode.annotation.ImmutableStyle; +import org.immutables.value.Value; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +/** + * Immutable representation of port connector information retrieved via DMI. + *

+ * Fields correspond to properties reported by {@code dmidecode} for the Port + * Connector Information (Type 8) SMBIOS structure. + *

+ *

+ * Instances of this class are thread-safe. + *

+ * + *

Usage example

+ *
{@code
+ * DMIPortConnectorInformation port = new DMIPortConnectorInformation.Builder()
+ *     .externalReferenceDesignator("USB1")
+ *     .externalConnectorType("USB")
+ *     .portType("USB")
+ *     .build();
+ *
+ * // Create a modified copy
+ * DMIPortConnectorInformation updated = port
+ *     .withPortType("USB Type-C");
+ * }
+ * + * @since 0.2.0 + */ +@Value.Immutable +@ImmutableStyle +@NullMarked +public abstract class AbstractDMIPortConnectorInformation { + + @JsonProperty("External Reference Designator") + @Nullable + public abstract String externalReferenceDesignator(); + + @JsonProperty("Internal Reference Designator") + @Nullable + public abstract String internalReferenceDesignator(); + + @JsonProperty("External Connector Type") + @Nullable + public abstract String externalConnectorType(); + + @JsonProperty("Internal Connector Type") + @Nullable + public abstract String internalConnectorType(); + + @JsonProperty("Port Type") + @Nullable + public abstract String portType(); + +} diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMISystemSlots.java b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMISystemSlots.java new file mode 100644 index 0000000..bd2c922 --- /dev/null +++ b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMISystemSlots.java @@ -0,0 +1,75 @@ +/* + * © 2026 The dmidecode4j contributors + * Licensed under the MIT License. + * See the LICENSE file in the project root for more information. + */ +package io.github.eggy03.dmidecode.entity.board; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.github.eggy03.dmidecode.annotation.ImmutableStyle; +import org.immutables.value.Value; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +import java.util.List; + +/** + * Immutable representation of system slot information retrieved via DMI. + *

+ * Fields correspond to properties reported by {@code dmidecode} for the System + * Slots (Type 9) SMBIOS structure. + *

+ *

+ * Instances of this class are thread-safe. + *

+ * + *

Usage example

+ *
{@code
+ * DMISystemSlots slot = new DMISystemSlots.Builder()
+ *     .designation("PCIEX16")
+ *     .type("PCI Express")
+ *     .currentUsage("In Use")
+ *     .busAddress("0000:01:00.0")
+ *     .build();
+ *
+ * // Create a modified copy
+ * DMISystemSlots updated = slot
+ *     .withCurrentUsage("Available");
+ * }
+ * + * @since 0.2.0 + */ +@Value.Immutable +@ImmutableStyle +@NullMarked +public abstract class AbstractDMISystemSlots { + + @JsonProperty("Designation") + @Nullable + public abstract String designation(); + + @JsonProperty("Type") + @Nullable + public abstract String type(); + + @JsonProperty("Current Usage") + @Nullable + public abstract String currentUsage(); + + @JsonProperty("Length") + @Nullable + public abstract String length(); + + @JsonProperty("ID") + @Nullable + public abstract Integer id(); + + @JsonProperty("Characteristics") + @Nullable + public abstract List<@Nullable String> characteristics(); + + @JsonProperty("Bus Address") + @Nullable + public abstract String busAddress(); + +} diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/board/DMIBIOS.java b/src/main/java/io/github/eggy03/dmidecode/entity/board/DMIBIOS.java deleted file mode 100644 index 5aa15ef..0000000 --- a/src/main/java/io/github/eggy03/dmidecode/entity/board/DMIBIOS.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * © 2026 The dmidecode4j contributors - * Licensed under the MIT License. - * See the LICENSE file in the project root for more information. - */ -package io.github.eggy03.dmidecode.entity.board; - -import com.google.gson.GsonBuilder; -import com.google.gson.annotations.SerializedName; -import lombok.Builder; -import lombok.Value; -import org.jetbrains.annotations.Nullable; - -import java.util.List; - -/** - * Immutable representation of BIOS information retrieved via DMI. - *

- * Fields correspond to properties reported by {@code dmidecode} for the BIOS - * (Type 0) SMBIOS structure. - *

- *

- * Instances of this class are thread-safe. - *

- * - *

Usage example

- *
{@code
- * DMIBIOS bios = DMIBIOS.builder()
- *     .vendor("American Megatrends Inc.")
- *     .version("F10")
- *     .releaseDate("07/15/2023")
- *     .build();
- *
- * // Create a modified copy
- * DMIBIOS updated = bios.toBuilder()
- *     .version("F11")
- *     .build();
- * }
- * - * @since 0.1.0 - * @author Sayan Bhattacharya - */ -@Value -@Builder(toBuilder = true) -public class DMIBIOS { - - @SerializedName("Vendor") - @Nullable - String vendor; - - @SerializedName("Version") - @Nullable - String version; - - @SerializedName("Release Date") - @Nullable - String releaseDate; - - @SerializedName("Address") - @Nullable - String address; - - @SerializedName("Runtime Size") - @Nullable - String runtimeSize; - - @SerializedName("ROM Size") - @Nullable - String romSize; - - @SerializedName("Characteristics") - @Nullable - List characteristics; - - @SerializedName("BIOS Revision") - @Nullable - String biosRevision; - - @SerializedName("Firmware Revision") - @Nullable - String firmwareRevision; - - @Override - public String toString() { - return new GsonBuilder() - .serializeNulls() - .setPrettyPrinting() - .create() - .toJson(this); - } -} diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/board/DMIBIOSLanguage.java b/src/main/java/io/github/eggy03/dmidecode/entity/board/DMIBIOSLanguage.java deleted file mode 100644 index 21f1618..0000000 --- a/src/main/java/io/github/eggy03/dmidecode/entity/board/DMIBIOSLanguage.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * © 2026 The dmidecode4j contributors - * Licensed under the MIT License. - * See the LICENSE file in the project root for more information. - */ -package io.github.eggy03.dmidecode.entity.board; - -import com.google.gson.GsonBuilder; -import com.google.gson.annotations.SerializedName; -import lombok.Builder; -import lombok.Value; -import org.jetbrains.annotations.Nullable; - -import java.util.List; - -/** - * Immutable representation of BIOS language information retrieved via DMI. - *

- * Fields correspond to properties reported by {@code dmidecode} for the BIOS - * Language (Type 13) SMBIOS structure. - *

- *

- * Instances of this class are thread-safe. - *

- * - *

Usage example

- *
{@code
- * DMIBIOSLanguage language = DMIBIOSLanguage.builder()
- *     .installableLanguages(List.of("en|US", "fr|FR"))
- *     .currentLanguage("en|US")
- *     .build();
- *
- * // Create a modified copy
- * DMIBIOSLanguage updated = language.toBuilder()
- *     .currentLanguage("fr|FR")
- *     .build();
- * }
- * - * @since 0.1.0 - * @author Sayan Bhattacharya - */ -@Value -@Builder(toBuilder = true) -public class DMIBIOSLanguage { - - @SerializedName("Installable Languages") - @Nullable - List installableLanguages; - - @SerializedName("Currently Installed Language") - @Nullable - String currentLanguage; - - @Override - public String toString() { - return new GsonBuilder() - .serializeNulls() - .setPrettyPrinting() - .create() - .toJson(this); - } -} diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/board/DMIBaseboard.java b/src/main/java/io/github/eggy03/dmidecode/entity/board/DMIBaseboard.java deleted file mode 100644 index 60c97f6..0000000 --- a/src/main/java/io/github/eggy03/dmidecode/entity/board/DMIBaseboard.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * © 2026 The dmidecode4j contributors - * Licensed under the MIT License. - * See the LICENSE file in the project root for more information. - */ -package io.github.eggy03.dmidecode.entity.board; - -import com.google.gson.GsonBuilder; -import com.google.gson.annotations.SerializedName; -import lombok.Builder; -import lombok.Value; -import org.jetbrains.annotations.Nullable; - -import java.util.List; - -/** - * Immutable representation of a baseboard (motherboard) device retrieved via DMI. - *

- * Fields correspond to properties reported by {@code dmidecode} for the Base Board - * (Type 2) SMBIOS structure. - *

- *

- * Instances of this class are thread-safe. - *

- * - *

Usage example

- *
{@code
- * DMIBaseboard board = DMIBaseboard.builder()
- *     .manufacturer("ASUSTeK COMPUTER INC.")
- *     .productName("PRIME B550M-A")
- *     .serialNumber("ABC123456")
- *     .build();
- *
- * // Create a modified copy
- * DMIBaseboard updated = board.toBuilder()
- *     .serialNumber("XYZ987654")
- *     .build();
- * }
- * - * @since 0.1.0 - * @author Sayan Bhattacharya - */ -@Value -@Builder(toBuilder = true) -public class DMIBaseboard { - - @SerializedName("Manufacturer") - @Nullable - String manufacturer; - - @SerializedName("Product Name") - @Nullable - String productName; - - @SerializedName("Version") - @Nullable - String version; - - @SerializedName("Serial Number") - @Nullable - String serialNumber; - - @SerializedName("Asset Tag") - @Nullable - String assetTag; - - @SerializedName("Features") - @Nullable - List features; - - @SerializedName("Location In Chassis") - @Nullable - String locationInChassis; - - @SerializedName("Chassis Handle") - @Nullable - String chassisHandle; - - @SerializedName("Type") - @Nullable - String type; - - @SerializedName("Contained Object Handles") - @Nullable - Integer containedObjectHandles; - - @Override - public String toString() { - return new GsonBuilder() - .serializeNulls() - .setPrettyPrinting() - .create() - .toJson(this); - } -} diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/board/DMIChassis.java b/src/main/java/io/github/eggy03/dmidecode/entity/board/DMIChassis.java deleted file mode 100644 index 1fc2df7..0000000 --- a/src/main/java/io/github/eggy03/dmidecode/entity/board/DMIChassis.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * © 2026 The dmidecode4j contributors - * Licensed under the MIT License. - * See the LICENSE file in the project root for more information. - */ -package io.github.eggy03.dmidecode.entity.board; - -import com.google.gson.GsonBuilder; -import com.google.gson.annotations.SerializedName; -import lombok.Builder; -import lombok.Value; -import org.jetbrains.annotations.Nullable; - -/** - * Immutable representation of system chassis information retrieved via DMI. - *

- * Fields correspond to properties reported by {@code dmidecode} for the Chassis - * (Type 3) SMBIOS structure. - *

- *

- * Instances of this class are thread-safe. - *

- * - *

Usage example

- *
{@code
- * DMIChassis chassis = DMIChassis.builder()
- *     .manufacturer("Dell Inc.")
- *     .type("Desktop")
- *     .serialNumber("ABC123456")
- *     .build();
- *
- * // Create a modified copy
- * DMIChassis updated = chassis.toBuilder()
- *     .assetTag("OFFICE-PC-01")
- *     .build();
- * }
- * - * @since 0.1.0 - * @author Sayan Bhattacharya - */ -@Value -@Builder(toBuilder = true) -public class DMIChassis { - - @SerializedName("Manufacturer") - @Nullable - String manufacturer; - - @SerializedName("Type") - @Nullable - String type; - - @SerializedName("Lock") - @Nullable - String lock; - - @SerializedName("Version") - @Nullable - String version; - - @SerializedName("Serial Number") - @Nullable - String serialNumber; - - @SerializedName("Asset Tag") - @Nullable - String assetTag; - - @SerializedName("Boot-up State") - @Nullable - String bootUpState; - - @SerializedName("Power Supply State") - @Nullable - String powerSupplyState; - - @SerializedName("Thermal State") - @Nullable - String thermalState; - - @SerializedName("Security Status") - @Nullable - String securityStatus; - - @SerializedName("OEM Information") - @Nullable - String oemInformation; - - @SerializedName("Height") - @Nullable - String height; - - @SerializedName("Number Of Power Cords") - @Nullable - Integer numberOfPowerCords; - - @SerializedName("Contained Elements") - @Nullable - Integer containedElements; - - @SerializedName("SKU Number") - @Nullable - String skuNumber; - - @Override - public String toString() { - return new GsonBuilder() - .serializeNulls() - .setPrettyPrinting() - .create() - .toJson(this); - } -} diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/board/DMIPortConnectorInformation.java b/src/main/java/io/github/eggy03/dmidecode/entity/board/DMIPortConnectorInformation.java deleted file mode 100644 index 07472e0..0000000 --- a/src/main/java/io/github/eggy03/dmidecode/entity/board/DMIPortConnectorInformation.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * © 2026 The dmidecode4j contributors - * Licensed under the MIT License. - * See the LICENSE file in the project root for more information. - */ -package io.github.eggy03.dmidecode.entity.board; - -import com.google.gson.GsonBuilder; -import com.google.gson.annotations.SerializedName; -import lombok.Builder; -import lombok.Value; -import org.jetbrains.annotations.Nullable; - -/** - * Immutable representation of port connector information retrieved via DMI. - *

- * Fields correspond to properties reported by {@code dmidecode} for the Port - * Connector Information (Type 8) SMBIOS structure. - *

- *

- * Instances of this class are thread-safe. - *

- * - *

Usage example

- *
{@code
- * DMIPortConnectorInformation port = DMIPortConnectorInformation.builder()
- *     .externalReferenceDesignator("USB1")
- *     .externalConnectorType("USB")
- *     .portType("USB")
- *     .build();
- *
- * // Create a modified copy
- * DMIPortConnectorInformation updated = port.toBuilder()
- *     .portType("USB Type-C")
- *     .build();
- * }
- * - * @since 0.1.0 - * @author Sayan Bhattacharya - */ -@Value -@Builder(toBuilder = true) -public class DMIPortConnectorInformation { - - @SerializedName("External Reference Designator") - @Nullable - String externalReferenceDesignator; - - @SerializedName("Internal Reference Designator") - @Nullable - String internalReferenceDesignator; - - @SerializedName("External Connector Type") - @Nullable - String externalConnectorType; - - @SerializedName("Internal Connector Type") - @Nullable - String internalConnectorType; - - @SerializedName("Port Type") - @Nullable - String portType; - - @Override - public String toString() { - return new GsonBuilder() - .serializeNulls() - .setPrettyPrinting() - .create() - .toJson(this); - } - -} diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/board/DMISystemSlots.java b/src/main/java/io/github/eggy03/dmidecode/entity/board/DMISystemSlots.java deleted file mode 100644 index 4d84fd0..0000000 --- a/src/main/java/io/github/eggy03/dmidecode/entity/board/DMISystemSlots.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * © 2026 The dmidecode4j contributors - * Licensed under the MIT License. - * See the LICENSE file in the project root for more information. - */ -package io.github.eggy03.dmidecode.entity.board; - -import com.google.gson.GsonBuilder; -import com.google.gson.annotations.SerializedName; -import lombok.Builder; -import lombok.Value; - -import java.util.List; - -/** - * Immutable representation of system slot information retrieved via DMI. - *

- * Fields correspond to properties reported by {@code dmidecode} for the System - * Slots (Type 9) SMBIOS structure. - *

- *

- * Instances of this class are thread-safe. - *

- * - *

Usage example

- *
{@code
- * DMISystemSlots slot = DMISystemSlots.builder()
- *     .designation("PCIEX16")
- *     .type("PCI Express")
- *     .currentUsage("In Use")
- *     .busAddress("0000:01:00.0")
- *     .build();
- *
- * // Create a modified copy
- * DMISystemSlots updated = slot.toBuilder()
- *     .currentUsage("Available")
- *     .build();
- * }
- * - * @since 0.1.0 - * @author Sayan Bhattacharya - */ -@Value -@Builder(toBuilder = true) -public class DMISystemSlots { - - @SerializedName("Designation") - String designation; - - @SerializedName("Type") - String type; - - @SerializedName("Current Usage") - String currentUsage; - - @SerializedName("Length") - String length; - - @SerializedName("ID") - Integer id; - - @SerializedName("Characteristics") - List characteristics; - - @SerializedName("Bus Address") - String busAddress; - - @Override - public String toString() { - return new GsonBuilder() - .serializeNulls() - .setPrettyPrinting() - .create() - .toJson(this); - } -} diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/memory/AbstractDMIMemoryDevice.java b/src/main/java/io/github/eggy03/dmidecode/entity/memory/AbstractDMIMemoryDevice.java new file mode 100644 index 0000000..099b975 --- /dev/null +++ b/src/main/java/io/github/eggy03/dmidecode/entity/memory/AbstractDMIMemoryDevice.java @@ -0,0 +1,173 @@ +/* + * © 2026 The dmidecode4j contributors + * Licensed under the MIT License. + * See the LICENSE file in the project root for more information. + */ +package io.github.eggy03.dmidecode.entity.memory; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.github.eggy03.dmidecode.annotation.ImmutableStyle; +import org.immutables.value.Value; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +/** + * Immutable representation of memory device information retrieved via DMI. + *

+ * Fields correspond to properties reported by {@code dmidecode} for the Memory + * Device (Type 17) SMBIOS structure. + *

+ *

+ * Instances of this class are thread-safe. + *

+ * + *

Usage example

+ *
{@code
+ * DMIMemoryDevice memory = new DMIMemoryDevice.Builder()
+ *     .locator("DIMM_A1")
+ *     .size("16 GB")
+ *     .type("DDR4")
+ *     .speed("3200 MT/s")
+ *     .manufacturer("Samsung")
+ *     .build();
+ *
+ * // Create a modified copy
+ * DMIMemoryDevice updated = memory
+ *     .withConfiguredMemorySpeed("2933 MT/s");
+ * }
+ * + * @since 0.2.0 + */ +@Value.Immutable +@ImmutableStyle +@NullMarked +public abstract class AbstractDMIMemoryDevice { + + @JsonProperty("Array Handle") + @Nullable + public abstract String arrayHandle(); + + @JsonProperty("Error Information Handle") + @Nullable + public abstract String errorInformationHandle(); + + @JsonProperty("Total Width") + @Nullable + public abstract String totalWidth(); + + @JsonProperty("Data Width") + @Nullable + public abstract String dataWidth(); + + @JsonProperty("Size") + @Nullable + public abstract String size(); + + @JsonProperty("Form Factor") + @Nullable + public abstract String formFactor(); + + @JsonProperty("Set") + @Nullable + public abstract String set(); + + @JsonProperty("Locator") + @Nullable + public abstract String locator(); + + @JsonProperty("Bank Locator") + @Nullable + public abstract String bankLocator(); + + @JsonProperty("Type") + @Nullable + public abstract String type(); + + @JsonProperty("Type Detail") + @Nullable + public abstract String typeDetail(); + + @JsonProperty("Speed") + @Nullable + public abstract String speed(); + + @JsonProperty("Manufacturer") + @Nullable + public abstract String manufacturer(); + + @JsonProperty("Serial Number") + @Nullable + public abstract String serialNumber(); + + @JsonProperty("Asset Tag") + @Nullable + public abstract String assetTag(); + + @JsonProperty("Part Number") + @Nullable + public abstract String partNumber(); + + @JsonProperty("Rank") + @Nullable + public abstract Integer rank(); + + @JsonProperty("Configured Memory Speed") + @Nullable + public abstract String configuredMemorySpeed(); + + @JsonProperty("Minimum Voltage") + @Nullable + public abstract String minimumVoltage(); + + @JsonProperty("Maximum Voltage") + @Nullable + public abstract String maximumVoltage(); + + @JsonProperty("Configured Voltage") + @Nullable + public abstract String configuredVoltage(); + + @JsonProperty("Memory Technology") + @Nullable + public abstract String memoryTechnology(); + + @JsonProperty("Memory Operating Mode Capability") + @Nullable + public abstract String memoryOperatingModeCapability(); + + @JsonProperty("Firmware Version") + @Nullable + public abstract String firmwareVersion(); + + @JsonProperty("Module Manufacturer ID") + @Nullable + public abstract String moduleManufacturerId(); + + @JsonProperty("Module Product ID") + @Nullable + public abstract String moduleProductId(); + + @JsonProperty("Memory Subsystem Controller Manufacturer ID") + @Nullable + public abstract String memorySubsystemControllerManufacturerId(); + + @JsonProperty("Memory Subsystem Controller Product ID") + @Nullable + public abstract String memorySubsystemControllerProductId(); + + @JsonProperty("Non-Volatile Size") + @Nullable + public abstract String nonVolatileSize(); + + @JsonProperty("Volatile Size") + @Nullable + public abstract String volatileSize(); + + @JsonProperty("Cache Size") + @Nullable + public abstract String cacheSize(); + + @JsonProperty("Logical Size") + @Nullable + public abstract String logicalSize(); +} diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/memory/AbstractDMIPhysicalMemoryArray.java b/src/main/java/io/github/eggy03/dmidecode/entity/memory/AbstractDMIPhysicalMemoryArray.java new file mode 100644 index 0000000..83fe69d --- /dev/null +++ b/src/main/java/io/github/eggy03/dmidecode/entity/memory/AbstractDMIPhysicalMemoryArray.java @@ -0,0 +1,68 @@ +/* + * © 2026 The dmidecode4j contributors + * Licensed under the MIT License. + * See the LICENSE file in the project root for more information. + */ +package io.github.eggy03.dmidecode.entity.memory; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.github.eggy03.dmidecode.annotation.ImmutableStyle; +import org.immutables.value.Value; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +/** + * Immutable representation of physical memory array information retrieved via DMI. + *

+ * Fields correspond to properties reported by {@code dmidecode} for the Physical + * Memory Array (Type 16) SMBIOS structure. + *

+ *

+ * Instances of this class are thread-safe. + *

+ * + *

Usage example

+ *
{@code
+ * DMIPhysicalMemoryArray array = new DMIPhysicalMemoryArray.Builder()
+ *     .location("System Board Or Motherboard")
+ *     .use("System Memory")
+ *     .maximumCapacity("128 GB")
+ *     .numberOfDevices(4)
+ *     .build();
+ *
+ * // Create a modified copy
+ * DMIPhysicalMemoryArray updated = array
+ *     .withErrorCorrectionType("Multi-bit ECC");
+ * }
+ * + * @since 0.2.0 + */ +@Value.Immutable +@ImmutableStyle +@NullMarked +public abstract class AbstractDMIPhysicalMemoryArray { + + @JsonProperty("Location") + @Nullable + public abstract String location(); + + @JsonProperty("Use") + @Nullable + public abstract String use(); + + @JsonProperty("Error Correction Type") + @Nullable + public abstract String errorCorrectionType(); + + @JsonProperty("Maximum Capacity") + @Nullable + public abstract String maximumCapacity(); + + @JsonProperty("Error Information Handle") + @Nullable + public abstract String errorInformationHandle(); + + @JsonProperty("Number Of Devices") + @Nullable + public abstract Integer numberOfDevices(); +} diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/memory/DMIMemoryDevice.java b/src/main/java/io/github/eggy03/dmidecode/entity/memory/DMIMemoryDevice.java deleted file mode 100644 index 7bb58b5..0000000 --- a/src/main/java/io/github/eggy03/dmidecode/entity/memory/DMIMemoryDevice.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * © 2026 The dmidecode4j contributors - * Licensed under the MIT License. - * See the LICENSE file in the project root for more information. - */ -package io.github.eggy03.dmidecode.entity.memory; - -import com.google.gson.GsonBuilder; -import com.google.gson.annotations.SerializedName; -import lombok.Builder; -import lombok.Value; -import org.jetbrains.annotations.Nullable; - -/** - * Immutable representation of memory device information retrieved via DMI. - *

- * Fields correspond to properties reported by {@code dmidecode} for the Memory - * Device (Type 17) SMBIOS structure. - *

- *

- * Instances of this class are thread-safe. - *

- * - *

Usage example

- *
{@code
- * DMIMemoryDevice memory = DMIMemoryDevice.builder()
- *     .locator("DIMM_A1")
- *     .size("16 GB")
- *     .type("DDR4")
- *     .speed("3200 MT/s")
- *     .manufacturer("Samsung")
- *     .build();
- *
- * // Create a modified copy
- * DMIMemoryDevice updated = memory.toBuilder()
- *     .configuredMemorySpeed("2933 MT/s")
- *     .build();
- * }
- * - * @since 0.1.0 - * @author Sayan Bhattacharya - */ -@Value -@Builder(toBuilder = true) -public class DMIMemoryDevice { - - @SerializedName("Array Handle") - @Nullable - String arrayHandle; - - @SerializedName("Error Information Handle") - @Nullable - String errorInformationHandle; - - @SerializedName("Total Width") - @Nullable - String totalWidth; - - @SerializedName("Data Width") - @Nullable - String dataWidth; - - @SerializedName("Size") - @Nullable - String size; - - @SerializedName("Form Factor") - @Nullable - String formFactor; - - @SerializedName("Set") - @Nullable - String set; - - @SerializedName("Locator") - @Nullable - String locator; - - @SerializedName("Bank Locator") - @Nullable - String bankLocator; - - @SerializedName("Type") - @Nullable - String type; - - @SerializedName("Type Detail") - @Nullable - String typeDetail; - - @SerializedName("Speed") - @Nullable - String speed; - - @SerializedName("Manufacturer") - @Nullable - String manufacturer; - - @SerializedName("Serial Number") - @Nullable - String serialNumber; - - @SerializedName("Asset Tag") - @Nullable - String assetTag; - - @SerializedName("Part Number") - @Nullable - String partNumber; - - @SerializedName("Rank") - @Nullable - Integer rank; - - @SerializedName("Configured Memory Speed") - @Nullable - String configuredMemorySpeed; - - @SerializedName("Minimum Voltage") - @Nullable - String minimumVoltage; - - @SerializedName("Maximum Voltage") - @Nullable - String maximumVoltage; - - @SerializedName("Configured Voltage") - @Nullable - String configuredVoltage; - - @SerializedName("Memory Technology") - @Nullable - String memoryTechnology; - - @SerializedName("Memory Operating Mode Capability") - @Nullable - String memoryOperatingModeCapability; - - @SerializedName("Firmware Version") - @Nullable - String firmwareVersion; - - @SerializedName("Module Manufacturer ID") - @Nullable - String moduleManufacturerId; - - @SerializedName("Module Product ID") - @Nullable - String moduleProductId; - - @SerializedName("Memory Subsystem Controller Manufacturer ID") - @Nullable - String memorySubsystemControllerManufacturerId; - - @SerializedName("Memory Subsystem Controller Product ID") - @Nullable - String memorySubsystemControllerProductId; - - @SerializedName("Non-Volatile Size") - @Nullable - String nonVolatileSize; - - @SerializedName("Volatile Size") - @Nullable - String volatileSize; - - @SerializedName("Cache Size") - @Nullable - String cacheSize; - - @SerializedName("Logical Size") - @Nullable - String logicalSize; - - @Override - public String toString() { - return new GsonBuilder() - .serializeNulls() - .setPrettyPrinting() - .create() - .toJson(this); - } -} diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/memory/DMIPhysicalMemoryArray.java b/src/main/java/io/github/eggy03/dmidecode/entity/memory/DMIPhysicalMemoryArray.java deleted file mode 100644 index d6ee2cc..0000000 --- a/src/main/java/io/github/eggy03/dmidecode/entity/memory/DMIPhysicalMemoryArray.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * © 2026 The dmidecode4j contributors - * Licensed under the MIT License. - * See the LICENSE file in the project root for more information. - */ -package io.github.eggy03.dmidecode.entity.memory; - -import com.google.gson.GsonBuilder; -import com.google.gson.annotations.SerializedName; -import lombok.Builder; -import lombok.Value; -import org.jetbrains.annotations.Nullable; - -/** - * Immutable representation of physical memory array information retrieved via DMI. - *

- * Fields correspond to properties reported by {@code dmidecode} for the Physical - * Memory Array (Type 16) SMBIOS structure. - *

- *

- * Instances of this class are thread-safe. - *

- * - *

Usage example

- *
{@code
- * DMIPhysicalMemoryArray array = DMIPhysicalMemoryArray.builder()
- *     .location("System Board Or Motherboard")
- *     .use("System Memory")
- *     .maximumCapacity("128 GB")
- *     .numberOfDevices(4)
- *     .build();
- *
- * // Create a modified copy
- * DMIPhysicalMemoryArray updated = array.toBuilder()
- *     .errorCorrectionType("Multi-bit ECC")
- *     .build();
- * }
- * - * @since 0.1.0 - * @author Sayan Bhattacharya - */ -@Value -@Builder(toBuilder = true) -public class DMIPhysicalMemoryArray { - - @SerializedName("Location") - @Nullable - String location; - - @SerializedName("Use") - @Nullable - String use; - - @SerializedName("Error Correction Type") - @Nullable - String errorCorrectionType; - - @SerializedName("Maximum Capacity") - @Nullable - String maximumCapacity; - - @SerializedName("Error Information Handle") - @Nullable - String errorInformationHandle; - - @SerializedName("Number Of Devices") - @Nullable - Integer numberOfDevices; - - @Override - public String toString() { - return new GsonBuilder() - .serializeNulls() - .setPrettyPrinting() - .create() - .toJson(this); - } -} diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/peripheral/AbstractDMIPortableBattery.java b/src/main/java/io/github/eggy03/dmidecode/entity/peripheral/AbstractDMIPortableBattery.java new file mode 100644 index 0000000..06c641a --- /dev/null +++ b/src/main/java/io/github/eggy03/dmidecode/entity/peripheral/AbstractDMIPortableBattery.java @@ -0,0 +1,88 @@ +/* + * © 2026 The dmidecode4j contributors + * Licensed under the MIT License. + * See the LICENSE file in the project root for more information. + */ +package io.github.eggy03.dmidecode.entity.peripheral; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.github.eggy03.dmidecode.annotation.ImmutableStyle; +import org.immutables.value.Value; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +/** + * Immutable representation of portable battery information retrieved via DMI. + *

+ * Fields correspond to properties reported by {@code dmidecode} for the Portable + * Battery (Type 22) SMBIOS structure. + *

+ *

+ * Instances of this class are thread-safe. + *

+ * + *

Usage example

+ *
{@code
+ * DMIPortableBattery battery = new DMIPortableBattery.Builder()
+ *     .location("Internal Battery")
+ *     .manufacturer("LG")
+ *     .designCapacity("50000 mWh")
+ *     .designVoltage("11.4 V")
+ *     .build();
+ *
+ * // Create a modified copy
+ * DMIPortableBattery updated = battery
+ *     .withMaximumError("2%");
+ * }
+ * + * @since 0.2.0 + */ +@Value.Immutable +@ImmutableStyle +@NullMarked +public abstract class AbstractDMIPortableBattery { + + @JsonProperty("Location") + @Nullable + public abstract String location(); + + @JsonProperty("Manufacturer") + @Nullable + public abstract String manufacturer(); + + @JsonProperty("Name") + @Nullable + public abstract String name(); + + @JsonProperty("Design Capacity") + @Nullable + public abstract String designCapacity(); + + @JsonProperty("Design Voltage") + @Nullable + public abstract String designVoltage(); + + @JsonProperty("SBDS Version") + @Nullable + public abstract String sbdsVersion(); + + @JsonProperty("Maximum Error") + @Nullable + public abstract String maximumError(); + + @JsonProperty("SBDS Serial Number") + @Nullable + public abstract String sbdsSerialNumber(); + + @JsonProperty("SBDS Manufacture Date") + @Nullable + public abstract String sbdsManufactureDate(); + + @JsonProperty("SBDS Chemistry") + @Nullable + public abstract String sbdsChemistry(); + + @JsonProperty("OEM-specific Information") + @Nullable + public abstract String oemSpecificInformation(); +} diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/peripheral/DMIPortableBattery.java b/src/main/java/io/github/eggy03/dmidecode/entity/peripheral/DMIPortableBattery.java deleted file mode 100644 index 6b15685..0000000 --- a/src/main/java/io/github/eggy03/dmidecode/entity/peripheral/DMIPortableBattery.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * © 2026 The dmidecode4j contributors - * Licensed under the MIT License. - * See the LICENSE file in the project root for more information. - */ -package io.github.eggy03.dmidecode.entity.peripheral; - -import com.google.gson.GsonBuilder; -import com.google.gson.annotations.SerializedName; -import lombok.Builder; -import lombok.Value; - -/** - * Immutable representation of portable battery information retrieved via DMI. - *

- * Fields correspond to properties reported by {@code dmidecode} for the Portable - * Battery (Type 22) SMBIOS structure. - *

- *

- * Instances of this class are thread-safe. - *

- * - *

Usage example

- *
{@code
- * DMIPortableBattery battery = DMIPortableBattery.builder()
- *     .location("Internal Battery")
- *     .manufacturer("LG")
- *     .designCapacity("50000 mWh")
- *     .designVoltage("11.4 V")
- *     .build();
- *
- * // Create a modified copy
- * DMIPortableBattery updated = battery.toBuilder()
- *     .maximumError("2%")
- *     .build();
- * }
- * - * @since 0.1.0 - * @author Sayan Bhattacharya - */ -@Value -@Builder(toBuilder = true) -public class DMIPortableBattery { - - @SerializedName("Location") - String location; - - @SerializedName("Manufacturer") - String manufacturer; - - @SerializedName("Name") - String name; - - @SerializedName("Design Capacity") - String designCapacity; - - @SerializedName("Design Voltage") - String designVoltage; - - @SerializedName("SBDS Version") - String sbdsVersion; - - @SerializedName("Maximum Error") - String maximumError; - - @SerializedName("SBDS Serial Number") - String sbdsSerialNumber; - - @SerializedName("SBDS Manufacture Date") - String sbdsManufactureDate; - - @SerializedName("SBDS Chemistry") - String sbdsChemistry; - - @SerializedName("OEM-specific Information") - String oemSpecificInformation; - - @Override - public String toString() { - return new GsonBuilder() - .serializeNulls() - .setPrettyPrinting() - .create() - .toJson(this); - } -} diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/processor/AbstractDMICache.java b/src/main/java/io/github/eggy03/dmidecode/entity/processor/AbstractDMICache.java new file mode 100644 index 0000000..73124cc --- /dev/null +++ b/src/main/java/io/github/eggy03/dmidecode/entity/processor/AbstractDMICache.java @@ -0,0 +1,94 @@ +/* + * © 2026 The dmidecode4j contributors + * Licensed under the MIT License. + * See the LICENSE file in the project root for more information. + */ +package io.github.eggy03.dmidecode.entity.processor; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.github.eggy03.dmidecode.annotation.ImmutableStyle; +import org.immutables.value.Value; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +import java.util.List; + +/** + * Immutable representation of processor cache information retrieved via DMI. + *

+ * Fields correspond to properties reported by {@code dmidecode} for the Cache + * Information (Type 7) SMBIOS structure. + *

+ *

+ * Instances of this class are thread-safe. + *

+ * + *

Usage example

+ *
{@code
+ * DMICache cache = new DMICache.Builder()
+ *     .socketDesignation("L3-Cache")
+ *     .location("Internal")
+ *     .installedSize("32 MB")
+ *     .associativity("16-way Set-Associative")
+ *     .build();
+ *
+ * // Create a modified copy
+ * DMICache updated = cache
+ *     .withInstalledSize("64 MB");
+ * }
+ * + * @since 0.2.0 + */ +@Value.Immutable +@ImmutableStyle +@NullMarked +public abstract class AbstractDMICache { + + @JsonProperty("Socket Designation") + @Nullable + public abstract String socketDesignation(); + + @JsonProperty("Configuration") + @Nullable + public abstract String configuration(); + + @JsonProperty("Operational Mode") + @Nullable + public abstract String operationalMode(); + + @JsonProperty("Location") + @Nullable + public abstract String location(); + + @JsonProperty("Installed Size") + @Nullable + public abstract String installedSize(); + + @JsonProperty("Maximum Size") + @Nullable + public abstract String maximumSize(); + + @JsonProperty("Supported SRAM Types") + @Nullable + public abstract List<@Nullable String> supportedSramTypes(); + + @JsonProperty("Installed SRAM Type") + @Nullable + public abstract String installedSramType(); + + @JsonProperty("Speed") + @Nullable + public abstract String speed(); + + @JsonProperty("Error Correction Type") + @Nullable + public abstract String errorCorrectionType(); + + @JsonProperty("System Type") + @Nullable + public abstract String systemType(); + + @JsonProperty("Associativity") + @Nullable + public abstract String associativity(); +} diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/processor/AbstractDMIProcessor.java b/src/main/java/io/github/eggy03/dmidecode/entity/processor/AbstractDMIProcessor.java new file mode 100644 index 0000000..6e5b7db --- /dev/null +++ b/src/main/java/io/github/eggy03/dmidecode/entity/processor/AbstractDMIProcessor.java @@ -0,0 +1,144 @@ +/* + * © 2026 The dmidecode4j contributors + * Licensed under the MIT License. + * See the LICENSE file in the project root for more information. + */ +package io.github.eggy03.dmidecode.entity.processor; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.github.eggy03.dmidecode.annotation.ImmutableStyle; +import org.immutables.value.Value; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +import java.util.List; + +/** + * Immutable representation of processor information retrieved via DMI. + *

+ * Fields correspond to properties reported by {@code dmidecode} for the Processor + * Information (Type 4) SMBIOS structure. + *

+ *

+ * Instances of this class are thread-safe. + *

+ * + *

Usage example

+ *
{@code
+ * DMIProcessor processor = new DMIProcessor.Builder()
+ *     .socketDesignation("CPU0")
+ *     .manufacturer("Intel")
+ *     .version("Intel(R) Core(TM) i7-12700H")
+ *     .coreCount(14)
+ *     .threadCount(20)
+ *     .currentSpeed("2700 MHz")
+ *     .build();
+ *
+ * // Create a modified copy
+ * DMIProcessor updated = processor
+ *     .withCurrentSpeed("3900 MHz");
+ * }
+ * + * @since 0.2.0 + */ +@Value.Immutable +@ImmutableStyle +@NullMarked +public abstract class AbstractDMIProcessor { + + @JsonProperty("Socket Designation") + @Nullable + public abstract String socketDesignation(); + + @JsonProperty("Type") + @Nullable + public abstract String type(); + + @JsonProperty("Family") + @Nullable + public abstract String family(); + + @JsonProperty("Manufacturer") + @Nullable + public abstract String manufacturer(); + + @JsonProperty("ID") + @Nullable + public abstract String id(); + + @JsonProperty("Signature") + @Nullable + public abstract String signature(); + + @JsonProperty("Flags") + @Nullable + public abstract List<@Nullable String> flags(); + + @JsonProperty("Version") + @Nullable + public abstract String version(); + + @JsonProperty("Voltage") + @Nullable + public abstract String voltage(); + + @JsonProperty("External Clock") + @Nullable + public abstract String externalClock(); + + @JsonProperty("Max Speed") + @Nullable + public abstract String maxSpeed(); + + @JsonProperty("Current Speed") + @Nullable + public abstract String currentSpeed(); + + @JsonProperty("Status") + @Nullable + public abstract String status(); + + @JsonProperty("Upgrade") + @Nullable + public abstract String upgrade(); + + @JsonProperty("L1 Cache Handle") + @Nullable + public abstract String l1CacheHandle(); + + @JsonProperty("L2 Cache Handle") + @Nullable + public abstract String l2CacheHandle(); + + @JsonProperty("L3 Cache Handle") + @Nullable + public abstract String l3CacheHandle(); + + @JsonProperty("Serial Number") + @Nullable + public abstract String serialNumber(); + + @JsonProperty("Asset Tag") + @Nullable + public abstract String assetTag(); + + @JsonProperty("Part Number") + @Nullable + public abstract String partNumber(); + + @JsonProperty("Core Count") + @Nullable + public abstract Integer coreCount(); + + @JsonProperty("Core Enabled") + @Nullable + public abstract Integer coreEnabled(); + + @JsonProperty("Thread Count") + @Nullable + public abstract Integer threadCount(); + + @JsonProperty("Characteristics") + @Nullable + public abstract List<@Nullable String> characteristics(); +} diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/processor/DMICache.java b/src/main/java/io/github/eggy03/dmidecode/entity/processor/DMICache.java deleted file mode 100644 index 00f23e6..0000000 --- a/src/main/java/io/github/eggy03/dmidecode/entity/processor/DMICache.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * © 2026 The dmidecode4j contributors - * Licensed under the MIT License. - * See the LICENSE file in the project root for more information. - */ -package io.github.eggy03.dmidecode.entity.processor; - -import com.google.gson.GsonBuilder; -import com.google.gson.annotations.SerializedName; -import lombok.Builder; -import lombok.Value; -import org.jetbrains.annotations.Nullable; - -import java.util.List; - -/** - * Immutable representation of processor cache information retrieved via DMI. - *

- * Fields correspond to properties reported by {@code dmidecode} for the Cache - * Information (Type 7) SMBIOS structure. - *

- *

- * Instances of this class are thread-safe. - *

- * - *

Usage example

- *
{@code
- * DMICache cache = DMICache.builder()
- *     .socketDesignation("L3-Cache")
- *     .location("Internal")
- *     .installedSize("32 MB")
- *     .associativity("16-way Set-Associative")
- *     .build();
- *
- * // Create a modified copy
- * DMICache updated = cache.toBuilder()
- *     .installedSize("64 MB")
- *     .build();
- * }
- * - * @since 0.1.0 - * @author Sayan Bhattacharya - */ -@Value -@Builder(toBuilder = true) -public class DMICache { - - @SerializedName("Socket Designation") - @Nullable - String socketDesignation; - - @SerializedName("Configuration") - @Nullable - String configuration; - - @SerializedName("Operational Mode") - @Nullable - String operationalMode; - - @SerializedName("Location") - @Nullable - String location; - - @SerializedName("Installed Size") - @Nullable - String installedSize; - - @SerializedName("Maximum Size") - @Nullable - String maximumSize; - - @SerializedName("Supported SRAM Types") - @Nullable - List supportedSramTypes; - - @SerializedName("Installed SRAM Type") - @Nullable - String installedSramType; - - @SerializedName("Speed") - @Nullable - String speed; - - @SerializedName("Error Correction Type") - @Nullable - String errorCorrectionType; - - @SerializedName("System Type") - @Nullable - String systemType; - - @SerializedName("Associativity") - @Nullable - String associativity; - - @Override - public String toString() { - return new GsonBuilder() - .serializeNulls() - .setPrettyPrinting() - .create() - .toJson(this); - } -} diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/processor/DMIProcessor.java b/src/main/java/io/github/eggy03/dmidecode/entity/processor/DMIProcessor.java deleted file mode 100644 index a00d7a5..0000000 --- a/src/main/java/io/github/eggy03/dmidecode/entity/processor/DMIProcessor.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * © 2026 The dmidecode4j contributors - * Licensed under the MIT License. - * See the LICENSE file in the project root for more information. - */ -package io.github.eggy03.dmidecode.entity.processor; - -import com.google.gson.GsonBuilder; -import com.google.gson.annotations.SerializedName; -import lombok.Builder; -import lombok.Value; -import org.jetbrains.annotations.Nullable; - -import java.util.List; - -/** - * Immutable representation of processor information retrieved via DMI. - *

- * Fields correspond to properties reported by {@code dmidecode} for the Processor - * Information (Type 4) SMBIOS structure. - *

- *

- * Instances of this class are thread-safe. - *

- * - *

Usage example

- *
{@code
- * DMIProcessor processor = DMIProcessor.builder()
- *     .socketDesignation("CPU0")
- *     .manufacturer("Intel")
- *     .version("Intel(R) Core(TM) i7-12700H")
- *     .coreCount(14)
- *     .threadCount(20)
- *     .currentSpeed("2700 MHz")
- *     .build();
- *
- * // Create a modified copy
- * DMIProcessor updated = processor.toBuilder()
- *     .currentSpeed("3900 MHz")
- *     .build();
- * }
- * - * @since 0.1.0 - * @author Sayan Bhattacharya - */ -@Value -@Builder(toBuilder = true) -public class DMIProcessor { - - @SerializedName("Socket Designation") - @Nullable - String socketDesignation; - - @SerializedName("Type") - @Nullable - String type; - - @SerializedName("Family") - @Nullable - String family; - - @SerializedName("Manufacturer") - @Nullable - String manufacturer; - - @SerializedName("ID") - @Nullable - String id; - - @SerializedName("Signature") - @Nullable - String signature; - - @SerializedName("Flags") - @Nullable - List flags; - - @SerializedName("Version") - @Nullable - String version; - - @SerializedName("Voltage") - @Nullable - String voltage; - - @SerializedName("External Clock") - @Nullable - String externalClock; - - @SerializedName("Max Speed") - @Nullable - String maxSpeed; - - @SerializedName("Current Speed") - @Nullable - String currentSpeed; - - @SerializedName("Status") - @Nullable - String status; - - @SerializedName("Upgrade") - @Nullable - String upgrade; - - @SerializedName("L1 Cache Handle") - @Nullable - String l1CacheHandle; - - @SerializedName("L2 Cache Handle") - @Nullable - String l2CacheHandle; - - @SerializedName("L3 Cache Handle") - @Nullable - String l3CacheHandle; - - @SerializedName("Serial Number") - @Nullable - String serialNumber; - - @SerializedName("Asset Tag") - @Nullable - String assetTag; - - @SerializedName("Part Number") - @Nullable - String partNumber; - - @SerializedName("Core Count") - @Nullable - Integer coreCount; - - @SerializedName("Core Enabled") - @Nullable - Integer coreEnabled; - - @SerializedName("Thread Count") - @Nullable - Integer threadCount; - - @SerializedName("Characteristics") - @Nullable - List characteristics; - - @Override - public String toString() { - return new GsonBuilder() - .serializeNulls() - .setPrettyPrinting() - .create() - .toJson(this); - } -} diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/system/AbstractDMISystem.java b/src/main/java/io/github/eggy03/dmidecode/entity/system/AbstractDMISystem.java new file mode 100644 index 0000000..455df70 --- /dev/null +++ b/src/main/java/io/github/eggy03/dmidecode/entity/system/AbstractDMISystem.java @@ -0,0 +1,76 @@ +/* + * © 2026 The dmidecode4j contributors + * Licensed under the MIT License. + * See the LICENSE file in the project root for more information. + */ +package io.github.eggy03.dmidecode.entity.system; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.github.eggy03.dmidecode.annotation.ImmutableStyle; +import org.immutables.value.Value; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +/** + * Immutable representation of system information retrieved via DMI. + *

+ * Fields correspond to properties reported by {@code dmidecode} for the System + * Information (Type 1) SMBIOS structure. + *

+ *

+ * Instances of this class are thread-safe. + *

+ * + *

Usage example

+ *
{@code
+ * DMISystem system = new DMISystem.Builder()
+ *     .manufacturer("LENOVO")
+ *     .productName("ThinkPad T14 Gen 3")
+ *     .serialNumber("PF123ABC")
+ *     .uuid("4C4C4544-0038-4D10-8051-CAC04F4A1234")
+ *     .build();
+ *
+ * // Create a modified copy
+ * DMISystem updated = system
+ *     .withSkuNumber("21CFCTO1WW");
+ * }
+ * + * @since 0.2.0 + */ +@Value.Immutable +@ImmutableStyle +@NullMarked +public abstract class AbstractDMISystem { + + @JsonProperty("Manufacturer") + @Nullable + public abstract String manufacturer(); + + @JsonProperty("Product Name") + @Nullable + public abstract String productName(); + + @JsonProperty("Version") + @Nullable + public abstract String version(); + + @JsonProperty("Serial Number") + @Nullable + public abstract String serialNumber(); + + @JsonProperty("UUID") + @Nullable + public abstract String uuid(); + + @JsonProperty("Wake-up Type") + @Nullable + public abstract String wakeupType(); + + @JsonProperty("SKU Number") + @Nullable + public abstract String skuNumber(); + + @JsonProperty("Family") + @Nullable + public abstract String family(); +} diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/system/DMISystem.java b/src/main/java/io/github/eggy03/dmidecode/entity/system/DMISystem.java deleted file mode 100644 index 8c3cc7d..0000000 --- a/src/main/java/io/github/eggy03/dmidecode/entity/system/DMISystem.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * © 2026 The dmidecode4j contributors - * Licensed under the MIT License. - * See the LICENSE file in the project root for more information. - */ -package io.github.eggy03.dmidecode.entity.system; - -import com.google.gson.GsonBuilder; -import com.google.gson.annotations.SerializedName; -import lombok.Builder; -import lombok.Value; -import org.jetbrains.annotations.Nullable; - -/** - * Immutable representation of system information retrieved via DMI. - *

- * Fields correspond to properties reported by {@code dmidecode} for the System - * Information (Type 1) SMBIOS structure. - *

- *

- * Instances of this class are thread-safe. - *

- * - *

Usage example

- *
{@code
- * DMISystem system = DMISystem.builder()
- *     .manufacturer("LENOVO")
- *     .productName("ThinkPad T14 Gen 3")
- *     .serialNumber("PF123ABC")
- *     .uuid("4C4C4544-0038-4D10-8051-CAC04F4A1234")
- *     .build();
- *
- * // Create a modified copy
- * DMISystem updated = system.toBuilder()
- *     .skuNumber("21CFCTO1WW")
- *     .build();
- * }
- * - * @since 0.1.0 - * @author Sayan Bhattacharya - */ -@Value -@Builder(toBuilder = true) -public class DMISystem { - - @Nullable - @SerializedName("Manufacturer") - String manufacturer; - - @Nullable - @SerializedName("Product Name") - String productName; - - @Nullable - @SerializedName("Version") - String version; - - @Nullable - @SerializedName("Serial Number") - String serialNumber; - - @Nullable - @SerializedName("UUID") - String uuid; - - @Nullable - @SerializedName("Wake-up Type") - String wakeupType; - - @Nullable - @SerializedName("SKU Number") - String skuNumber; - - @Nullable - @SerializedName("Family") - String family; - - @Override - public String toString() { - return new GsonBuilder() - .serializeNulls() - .setPrettyPrinting() - .create() - .toJson(this); - } -} diff --git a/src/test/java/io/github/eggy03/dmidecode/service/board/DMIBIOSLanguageServiceTest.java b/src/test/java/io/github/eggy03/dmidecode/service/board/DMIBIOSLanguageServiceTest.java index 9d8f379..04800d3 100644 --- a/src/test/java/io/github/eggy03/dmidecode/service/board/DMIBIOSLanguageServiceTest.java +++ b/src/test/java/io/github/eggy03/dmidecode/service/board/DMIBIOSLanguageServiceTest.java @@ -33,7 +33,7 @@ static void setup() { "\tCurrently Installed Language: en|US" ); - mockDMIClass = DMIBIOSLanguage.builder() + mockDMIClass = new DMIBIOSLanguage.Builder() .installableLanguages(Arrays.asList( "en|US", "fr|FR", @@ -65,7 +65,7 @@ void test_get_fail_invalidRawDmi_emptyOutput() { .when(() -> TerminalUtility.executeCommand(anyString(), anyLong())) .thenReturn("invalid output"); - assertThat(service.get(15)).contains(DMIBIOSLanguage.builder().build()); + assertThat(service.get(15)).contains(new DMIBIOSLanguage.Builder().build()); } } } diff --git a/src/test/java/io/github/eggy03/dmidecode/service/board/DMIBIOSServiceTest.java b/src/test/java/io/github/eggy03/dmidecode/service/board/DMIBIOSServiceTest.java index 809877e..5ce052f 100644 --- a/src/test/java/io/github/eggy03/dmidecode/service/board/DMIBIOSServiceTest.java +++ b/src/test/java/io/github/eggy03/dmidecode/service/board/DMIBIOSServiceTest.java @@ -39,7 +39,7 @@ static void setup() { "\tFirmware Revision: 1.12" ); - mockDMIClass = DMIBIOS.builder() + mockDMIClass = new DMIBIOS.Builder() .vendor("American Megatrends Inc.") .version("F10") .releaseDate("07/15/2023") diff --git a/src/test/java/io/github/eggy03/dmidecode/service/board/DMIBaseboardServiceTest.java b/src/test/java/io/github/eggy03/dmidecode/service/board/DMIBaseboardServiceTest.java index 0652836..6a1e65d 100644 --- a/src/test/java/io/github/eggy03/dmidecode/service/board/DMIBaseboardServiceTest.java +++ b/src/test/java/io/github/eggy03/dmidecode/service/board/DMIBaseboardServiceTest.java @@ -41,7 +41,7 @@ static void setup() { ); - mockDMIClass = DMIBaseboard.builder() + mockDMIClass = new DMIBaseboard.Builder() .manufacturer("ASUSTeK COMPUTER INC.") .productName("PRIME B550M-A") .version("Rev X.0x") @@ -84,7 +84,7 @@ void test_get_fail_invalidRawDmi_emptyOutput() { .thenReturn("invalid output"); - assertThat(service.get(15)).contains(DMIBaseboard.builder().build()); + assertThat(service.get(15)).contains(new DMIBaseboard.Builder().build()); } } diff --git a/src/test/java/io/github/eggy03/dmidecode/service/board/DMIChassisServiceTest.java b/src/test/java/io/github/eggy03/dmidecode/service/board/DMIChassisServiceTest.java index 82f0388..5ee9f49 100644 --- a/src/test/java/io/github/eggy03/dmidecode/service/board/DMIChassisServiceTest.java +++ b/src/test/java/io/github/eggy03/dmidecode/service/board/DMIChassisServiceTest.java @@ -41,7 +41,7 @@ static void setup() { "\tSKU Number: SKU-001" ); - mockDMIClass = DMIChassis.builder() + mockDMIClass = new DMIChassis.Builder() .manufacturer("Dell Inc.") .type("Desktop") .lock("Not Present") @@ -82,7 +82,7 @@ void test_get_fail_invalidRawDmi_emptyOutput() { .when(() -> TerminalUtility.executeCommand(anyString(), anyLong())) .thenReturn("invalid output"); - assertThat(service.get(15)).contains(DMIChassis.builder().build()); + assertThat(service.get(15)).contains(new DMIChassis.Builder().build()); } } } diff --git a/src/test/java/io/github/eggy03/dmidecode/service/board/DMIPortConnectorInformationServiceTest.java b/src/test/java/io/github/eggy03/dmidecode/service/board/DMIPortConnectorInformationServiceTest.java index df2cdd2..b6a63c6 100644 --- a/src/test/java/io/github/eggy03/dmidecode/service/board/DMIPortConnectorInformationServiceTest.java +++ b/src/test/java/io/github/eggy03/dmidecode/service/board/DMIPortConnectorInformationServiceTest.java @@ -32,7 +32,7 @@ static void setup() { "\tPort Type: USB" ); - mockDMIClass = DMIPortConnectorInformation.builder() + mockDMIClass = new DMIPortConnectorInformation.Builder() .externalReferenceDesignator("USB1") .internalReferenceDesignator("JUSB1") .externalConnectorType("USB") diff --git a/src/test/java/io/github/eggy03/dmidecode/service/board/DMISystemSlotsServiceTest.java b/src/test/java/io/github/eggy03/dmidecode/service/board/DMISystemSlotsServiceTest.java index e6a7ebb..4589623 100644 --- a/src/test/java/io/github/eggy03/dmidecode/service/board/DMISystemSlotsServiceTest.java +++ b/src/test/java/io/github/eggy03/dmidecode/service/board/DMISystemSlotsServiceTest.java @@ -37,7 +37,7 @@ static void setup() { "\tBus Address: 0000:01:00.0" ); - mockDMIClass = DMISystemSlots.builder() + mockDMIClass = new DMISystemSlots.Builder() .designation("PCIEX16") .type("PCI Express") .currentUsage("In Use") diff --git a/src/test/java/io/github/eggy03/dmidecode/service/memory/DMIMemoryDeviceServiceTest.java b/src/test/java/io/github/eggy03/dmidecode/service/memory/DMIMemoryDeviceServiceTest.java index 64befb3..e7183c4 100644 --- a/src/test/java/io/github/eggy03/dmidecode/service/memory/DMIMemoryDeviceServiceTest.java +++ b/src/test/java/io/github/eggy03/dmidecode/service/memory/DMIMemoryDeviceServiceTest.java @@ -47,7 +47,7 @@ static void setup() { "\tConfigured Voltage: 1.2 V" ); - mockDMIClass = DMIMemoryDevice.builder() + mockDMIClass = new DMIMemoryDevice.Builder() .arrayHandle("0x002C") .errorInformationHandle("0x002D") .totalWidth("64 bits") diff --git a/src/test/java/io/github/eggy03/dmidecode/service/memory/DMIPhysicalMemoryArrayServiceTest.java b/src/test/java/io/github/eggy03/dmidecode/service/memory/DMIPhysicalMemoryArrayServiceTest.java index 46f906f..586dc89 100644 --- a/src/test/java/io/github/eggy03/dmidecode/service/memory/DMIPhysicalMemoryArrayServiceTest.java +++ b/src/test/java/io/github/eggy03/dmidecode/service/memory/DMIPhysicalMemoryArrayServiceTest.java @@ -32,7 +32,7 @@ static void setup() { "\tNumber Of Devices: 4" ); - mockDMIClass = DMIPhysicalMemoryArray.builder() + mockDMIClass = new DMIPhysicalMemoryArray.Builder() .location("System Board Or Motherboard") .use("System Memory") .errorCorrectionType("Multi-bit ECC") @@ -65,7 +65,7 @@ void test_get_fail_invalidRawDmi_emptyOutput() { .thenReturn("invalid output"); assertThat(service.get(15)) - .contains(DMIPhysicalMemoryArray.builder().build()); + .contains(new DMIPhysicalMemoryArray.Builder().build()); } } } diff --git a/src/test/java/io/github/eggy03/dmidecode/service/peripheral/DMIPortableBatteryServiceTest.java b/src/test/java/io/github/eggy03/dmidecode/service/peripheral/DMIPortableBatteryServiceTest.java index 1eade76..896ddb8 100644 --- a/src/test/java/io/github/eggy03/dmidecode/service/peripheral/DMIPortableBatteryServiceTest.java +++ b/src/test/java/io/github/eggy03/dmidecode/service/peripheral/DMIPortableBatteryServiceTest.java @@ -37,7 +37,7 @@ static void setup() { "\tOEM-specific Information: None" ); - mockDMIClass = DMIPortableBattery.builder() + mockDMIClass = new DMIPortableBattery.Builder() .location("Internal Battery") .manufacturer("LG") .name("BAT0") diff --git a/src/test/java/io/github/eggy03/dmidecode/service/processor/DMICacheServiceTest.java b/src/test/java/io/github/eggy03/dmidecode/service/processor/DMICacheServiceTest.java index 4e6268c..a134e51 100644 --- a/src/test/java/io/github/eggy03/dmidecode/service/processor/DMICacheServiceTest.java +++ b/src/test/java/io/github/eggy03/dmidecode/service/processor/DMICacheServiceTest.java @@ -42,7 +42,7 @@ static void setup() { "\tAssociativity: 16-way Set-Associative" ); - mockDMIClass = DMICache.builder() + mockDMIClass = new DMICache.Builder() .socketDesignation("L3-Cache") .configuration("Enabled, Not Socketed, Level 3") .operationalMode("Write Back") diff --git a/src/test/java/io/github/eggy03/dmidecode/service/processor/DMIProcessorServiceTest.java b/src/test/java/io/github/eggy03/dmidecode/service/processor/DMIProcessorServiceTest.java index 4faf9d8..4489b11 100644 --- a/src/test/java/io/github/eggy03/dmidecode/service/processor/DMIProcessorServiceTest.java +++ b/src/test/java/io/github/eggy03/dmidecode/service/processor/DMIProcessorServiceTest.java @@ -59,7 +59,7 @@ static void setup() { "\t\tHardware Thread" ); - mockDMIClass = DMIProcessor.builder() + mockDMIClass = new DMIProcessor.Builder() .socketDesignation("CPU0") .type("Central Processor") .family("Core i7") diff --git a/src/test/java/io/github/eggy03/dmidecode/service/system/DMISystemServiceTest.java b/src/test/java/io/github/eggy03/dmidecode/service/system/DMISystemServiceTest.java index ee0a4c5..1d8d602 100644 --- a/src/test/java/io/github/eggy03/dmidecode/service/system/DMISystemServiceTest.java +++ b/src/test/java/io/github/eggy03/dmidecode/service/system/DMISystemServiceTest.java @@ -34,7 +34,7 @@ static void setup() { "\tFamily: ThinkPad" ); - mockDMIClass = DMISystem.builder() + mockDMIClass = new DMISystem.Builder() .manufacturer("LENOVO") .productName("ThinkPad T14 Gen 3") .version("ThinkPad T14 Gen 3") @@ -68,7 +68,7 @@ void test_get_fail_invalidRawDmi_emptyOutput() { .when(() -> TerminalUtility.executeCommand(anyString(), anyLong())) .thenReturn("invalid output"); - assertThat(service.get(15)).contains(DMISystem.builder().build()); + assertThat(service.get(15)).contains(new DMISystem.Builder().build()); } } } From b11924e16699c3ba41ef373d30dd0cb50866647e Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Tue, 31 Mar 2026 15:39:57 +0530 Subject: [PATCH 04/19] refactor(annotations): remove the remaining JetBrains annotations - replace the remaining JetBrains `@NotNull` and `@Nullable` annotations with Jspecify equivalents - replace JetBrains `@Unmodifiable` with a custom `@Unmodifiable` annotation --- .../dmidecode/annotation/Unmodifiable.java | 26 +++++++++++++++++++ .../dmidecode/mapper/CommonDMIMapper.java | 10 +++---- .../service/board/DMIBIOSLanguageService.java | 5 ++-- .../service/board/DMIBIOSService.java | 6 ++--- .../service/board/DMIBaseboardService.java | 5 ++-- .../service/board/DMIChassisService.java | 5 ++-- .../DMIPortConnectorInformationService.java | 4 ++- .../service/board/DMISystemSlotsService.java | 4 ++- .../memory/DMIMemoryDeviceService.java | 6 ++--- .../memory/DMIPhysicalMemoryArrayService.java | 3 ++- .../peripheral/DMIPortableBatteryService.java | 4 ++- .../service/processor/DMICacheService.java | 6 ++--- .../processor/DMIProcessorService.java | 6 ++--- .../service/system/DMISystemService.java | 6 ++--- .../dmidecode/utility/TerminalUtility.java | 6 ++--- 15 files changed, 66 insertions(+), 36 deletions(-) create mode 100644 src/main/java/io/github/eggy03/dmidecode/annotation/Unmodifiable.java diff --git a/src/main/java/io/github/eggy03/dmidecode/annotation/Unmodifiable.java b/src/main/java/io/github/eggy03/dmidecode/annotation/Unmodifiable.java new file mode 100644 index 0000000..10dd310 --- /dev/null +++ b/src/main/java/io/github/eggy03/dmidecode/annotation/Unmodifiable.java @@ -0,0 +1,26 @@ +package io.github.eggy03.dmidecode.annotation; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + *

+ * Indicates that the underlying `Collection` or `Map` is unmodifiable. + * Any attempts to mutate such a collection or map may result in exceptions being + * thrown, or no result at all. + *

+ *

+ * The referenced objects within the collection or map may still be mutable, depending on + * their implementation. + *

+ * + * @since 0.2.0 + */ +@Target({ElementType.TYPE_USE}) +@Retention(RetentionPolicy.CLASS) +@Documented +public @interface Unmodifiable { +} diff --git a/src/main/java/io/github/eggy03/dmidecode/mapper/CommonDMIMapper.java b/src/main/java/io/github/eggy03/dmidecode/mapper/CommonDMIMapper.java index 3056266..e506b62 100644 --- a/src/main/java/io/github/eggy03/dmidecode/mapper/CommonDMIMapper.java +++ b/src/main/java/io/github/eggy03/dmidecode/mapper/CommonDMIMapper.java @@ -7,9 +7,9 @@ import com.google.gson.Gson; import com.google.gson.JsonElement; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.Unmodifiable; +import io.github.eggy03.dmidecode.annotation.Unmodifiable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import java.util.ArrayList; import java.util.Collections; @@ -85,7 +85,7 @@ public interface CommonDMIMapper { * no mappable data is found * @since 0.1.0 */ - default @NotNull Optional mapToEntity(@Nullable String rawDMIData, @NotNull Class mappableEntityClass) { + default @NonNull Optional mapToEntity(@Nullable String rawDMIData, @NonNull Class mappableEntityClass) { if(rawDMIData==null) return Optional.empty(); @@ -185,7 +185,7 @@ public interface CommonDMIMapper { * @return a non-null list of mapped entities * @since 0.1.0 */ - default @NotNull @Unmodifiable List mapToList(@Nullable String rawDMIData, @NotNull Class mappableEntityClass) { + default @NonNull @Unmodifiable List mapToList(@Nullable String rawDMIData, @NonNull Class mappableEntityClass) { if(rawDMIData==null) return Collections.emptyList(); diff --git a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSLanguageService.java b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSLanguageService.java index 6410913..8785c18 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSLanguageService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSLanguageService.java @@ -10,7 +10,7 @@ import io.github.eggy03.dmidecode.mapper.board.DMIBIOSLanguageMapper; import io.github.eggy03.dmidecode.service.OptionalCommonDMIServiceInterface; import io.github.eggy03.dmidecode.utility.TerminalUtility; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NonNull; import java.util.Optional; @@ -47,8 +47,7 @@ public class DMIBIOSLanguageService implements OptionalCommonDMIServiceInterface * @since 0.1.0 */ @Override - @NotNull - public Optional get(long timeout) { + public @NonNull Optional get(long timeout) { return new DMIBIOSLanguageMapper().mapToEntity( TerminalUtility.executeCommand(DMIType.getCommand(DMIType.BIOS_LANGUAGE.getValue()), timeout), DMIBIOSLanguage.class diff --git a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSService.java b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSService.java index ba2cd74..dc3b490 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSService.java @@ -5,12 +5,13 @@ */ package io.github.eggy03.dmidecode.service.board; +import io.github.eggy03.dmidecode.annotation.Unmodifiable; import io.github.eggy03.dmidecode.constant.DMIType; import io.github.eggy03.dmidecode.entity.board.DMIBIOS; import io.github.eggy03.dmidecode.mapper.board.DMIBIOSMapper; import io.github.eggy03.dmidecode.service.CommonDMIServiceInterface; import io.github.eggy03.dmidecode.utility.TerminalUtility; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NonNull; import java.util.List; @@ -47,8 +48,7 @@ public class DMIBIOSService implements CommonDMIServiceInterface { * @since 0.1.0 */ @Override - @NotNull - public List get(long timeout) { + public @NonNull @Unmodifiable List get(long timeout) { return new DMIBIOSMapper().mapToList( TerminalUtility.executeCommand(DMIType.getCommand(DMIType.BIOS.getValue()), timeout), DMIBIOS.class diff --git a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBaseboardService.java b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBaseboardService.java index 0964303..7532a13 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBaseboardService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBaseboardService.java @@ -10,7 +10,7 @@ import io.github.eggy03.dmidecode.mapper.board.DMIBaseboardMapper; import io.github.eggy03.dmidecode.service.OptionalCommonDMIServiceInterface; import io.github.eggy03.dmidecode.utility.TerminalUtility; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NonNull; import java.util.Optional; @@ -48,8 +48,7 @@ public class DMIBaseboardService implements OptionalCommonDMIServiceInterface get(long timeout) { + public @NonNull Optional get(long timeout) { return new DMIBaseboardMapper().mapToEntity( TerminalUtility.executeCommand(DMIType.getCommand(DMIType.BASEBOARD.getValue()), timeout), DMIBaseboard.class diff --git a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIChassisService.java b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIChassisService.java index a7c7f9f..282164e 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIChassisService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIChassisService.java @@ -10,7 +10,7 @@ import io.github.eggy03.dmidecode.mapper.board.DMIChassisMapper; import io.github.eggy03.dmidecode.service.OptionalCommonDMIServiceInterface; import io.github.eggy03.dmidecode.utility.TerminalUtility; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NonNull; import java.util.Optional; @@ -47,8 +47,7 @@ public class DMIChassisService implements OptionalCommonDMIServiceInterface get(long timeout) { + public @NonNull Optional get(long timeout) { return new DMIChassisMapper().mapToEntity( TerminalUtility.executeCommand(DMIType.getCommand(DMIType.CHASSIS.getValue()), timeout), DMIChassis.class diff --git a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIPortConnectorInformationService.java b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIPortConnectorInformationService.java index 3d57edf..6ea8ceb 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIPortConnectorInformationService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIPortConnectorInformationService.java @@ -5,11 +5,13 @@ */ package io.github.eggy03.dmidecode.service.board; +import io.github.eggy03.dmidecode.annotation.Unmodifiable; import io.github.eggy03.dmidecode.constant.DMIType; import io.github.eggy03.dmidecode.entity.board.DMIPortConnectorInformation; import io.github.eggy03.dmidecode.mapper.board.DMIPortConnectionInformationMapper; import io.github.eggy03.dmidecode.service.CommonDMIServiceInterface; import io.github.eggy03.dmidecode.utility.TerminalUtility; +import org.jspecify.annotations.NonNull; import java.util.List; @@ -47,7 +49,7 @@ public class DMIPortConnectorInformationService implements CommonDMIServiceInter * @since 0.1.0 */ @Override - public List get(long timeout) { + public @Unmodifiable @NonNull List get(long timeout) { return new DMIPortConnectionInformationMapper().mapToList( TerminalUtility.executeCommand(DMIType.getCommand(DMIType.PORT_CONNECTOR.getValue()), timeout), DMIPortConnectorInformation.class diff --git a/src/main/java/io/github/eggy03/dmidecode/service/board/DMISystemSlotsService.java b/src/main/java/io/github/eggy03/dmidecode/service/board/DMISystemSlotsService.java index e1df848..d275212 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/board/DMISystemSlotsService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/board/DMISystemSlotsService.java @@ -5,11 +5,13 @@ */ package io.github.eggy03.dmidecode.service.board; +import io.github.eggy03.dmidecode.annotation.Unmodifiable; import io.github.eggy03.dmidecode.constant.DMIType; import io.github.eggy03.dmidecode.entity.board.DMISystemSlots; import io.github.eggy03.dmidecode.mapper.board.DMISystemSlotsMapper; import io.github.eggy03.dmidecode.service.CommonDMIServiceInterface; import io.github.eggy03.dmidecode.utility.TerminalUtility; +import org.jspecify.annotations.NonNull; import java.util.List; @@ -47,7 +49,7 @@ public class DMISystemSlotsService implements CommonDMIServiceInterface get(long timeout) { + public @Unmodifiable @NonNull List get(long timeout) { return new DMISystemSlotsMapper().mapToList( TerminalUtility.executeCommand(DMIType.getCommand(DMIType.SYSTEM_SLOTS.getValue()), timeout), DMISystemSlots.class diff --git a/src/main/java/io/github/eggy03/dmidecode/service/memory/DMIMemoryDeviceService.java b/src/main/java/io/github/eggy03/dmidecode/service/memory/DMIMemoryDeviceService.java index fb7a682..0108209 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/memory/DMIMemoryDeviceService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/memory/DMIMemoryDeviceService.java @@ -5,12 +5,13 @@ */ package io.github.eggy03.dmidecode.service.memory; +import io.github.eggy03.dmidecode.annotation.Unmodifiable; import io.github.eggy03.dmidecode.constant.DMIType; import io.github.eggy03.dmidecode.entity.memory.DMIMemoryDevice; import io.github.eggy03.dmidecode.mapper.physicalmemory.DMIMemoryDeviceMapper; import io.github.eggy03.dmidecode.service.CommonDMIServiceInterface; import io.github.eggy03.dmidecode.utility.TerminalUtility; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NonNull; import java.util.List; @@ -48,8 +49,7 @@ public class DMIMemoryDeviceService implements CommonDMIServiceInterface get(long timeout) { + public @Unmodifiable @NonNull List get(long timeout) { return new DMIMemoryDeviceMapper().mapToList( TerminalUtility.executeCommand(DMIType.getCommand(DMIType.MEMORY_DEVICE.getValue()), timeout), DMIMemoryDevice.class diff --git a/src/main/java/io/github/eggy03/dmidecode/service/memory/DMIPhysicalMemoryArrayService.java b/src/main/java/io/github/eggy03/dmidecode/service/memory/DMIPhysicalMemoryArrayService.java index 678c53e..60136aa 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/memory/DMIPhysicalMemoryArrayService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/memory/DMIPhysicalMemoryArrayService.java @@ -10,6 +10,7 @@ import io.github.eggy03.dmidecode.mapper.physicalmemory.DMIPhysicalMemoryArrayMapper; import io.github.eggy03.dmidecode.service.OptionalCommonDMIServiceInterface; import io.github.eggy03.dmidecode.utility.TerminalUtility; +import org.jspecify.annotations.NonNull; import java.util.Optional; @@ -47,7 +48,7 @@ public class DMIPhysicalMemoryArrayService implements OptionalCommonDMIServiceIn * @since 0.1.0 */ @Override - public Optional get(long timeout) { + public @NonNull Optional get(long timeout) { return new DMIPhysicalMemoryArrayMapper().mapToEntity( TerminalUtility.executeCommand(DMIType.getCommand(DMIType.PHYSICAL_MEMORY_ARRAY.getValue()), timeout), DMIPhysicalMemoryArray.class diff --git a/src/main/java/io/github/eggy03/dmidecode/service/peripheral/DMIPortableBatteryService.java b/src/main/java/io/github/eggy03/dmidecode/service/peripheral/DMIPortableBatteryService.java index f9017a4..f8ddd07 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/peripheral/DMIPortableBatteryService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/peripheral/DMIPortableBatteryService.java @@ -5,11 +5,13 @@ */ package io.github.eggy03.dmidecode.service.peripheral; +import io.github.eggy03.dmidecode.annotation.Unmodifiable; import io.github.eggy03.dmidecode.constant.DMIType; import io.github.eggy03.dmidecode.entity.peripheral.DMIPortableBattery; import io.github.eggy03.dmidecode.mapper.peripheral.DMIPortableBatteryMapper; import io.github.eggy03.dmidecode.service.CommonDMIServiceInterface; import io.github.eggy03.dmidecode.utility.TerminalUtility; +import org.jspecify.annotations.NonNull; import java.util.List; @@ -47,7 +49,7 @@ public class DMIPortableBatteryService implements CommonDMIServiceInterface get(long timeout) { + public @Unmodifiable @NonNull List get(long timeout) { return new DMIPortableBatteryMapper().mapToList( TerminalUtility.executeCommand(DMIType.getCommand(DMIType.PORTABLE_BATTERY.getValue()), timeout), DMIPortableBattery.class diff --git a/src/main/java/io/github/eggy03/dmidecode/service/processor/DMICacheService.java b/src/main/java/io/github/eggy03/dmidecode/service/processor/DMICacheService.java index 1e4385f..28b9ff3 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/processor/DMICacheService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/processor/DMICacheService.java @@ -5,12 +5,13 @@ */ package io.github.eggy03.dmidecode.service.processor; +import io.github.eggy03.dmidecode.annotation.Unmodifiable; import io.github.eggy03.dmidecode.constant.DMIType; import io.github.eggy03.dmidecode.entity.processor.DMICache; import io.github.eggy03.dmidecode.mapper.processor.DMICacheMapper; import io.github.eggy03.dmidecode.service.CommonDMIServiceInterface; import io.github.eggy03.dmidecode.utility.TerminalUtility; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NonNull; import java.util.List; @@ -48,8 +49,7 @@ public class DMICacheService implements CommonDMIServiceInterface { * @since 0.1.0 */ @Override - @NotNull - public List get(long timeout) { + public @Unmodifiable @NonNull List get(long timeout) { return new DMICacheMapper().mapToList( TerminalUtility.executeCommand(DMIType.getCommand(DMIType.CACHE.getValue()), timeout), DMICache.class diff --git a/src/main/java/io/github/eggy03/dmidecode/service/processor/DMIProcessorService.java b/src/main/java/io/github/eggy03/dmidecode/service/processor/DMIProcessorService.java index 5d32b7e..ac26b14 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/processor/DMIProcessorService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/processor/DMIProcessorService.java @@ -5,12 +5,13 @@ */ package io.github.eggy03.dmidecode.service.processor; +import io.github.eggy03.dmidecode.annotation.Unmodifiable; import io.github.eggy03.dmidecode.constant.DMIType; import io.github.eggy03.dmidecode.entity.processor.DMIProcessor; import io.github.eggy03.dmidecode.mapper.processor.DMIProcessorMapper; import io.github.eggy03.dmidecode.service.CommonDMIServiceInterface; import io.github.eggy03.dmidecode.utility.TerminalUtility; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NonNull; import java.util.List; @@ -47,8 +48,7 @@ public class DMIProcessorService implements CommonDMIServiceInterface get(long timeout) { + public @Unmodifiable @NonNull List get(long timeout) { return new DMIProcessorMapper().mapToList( TerminalUtility.executeCommand(DMIType.getCommand(DMIType.PROCESSOR.getValue()), timeout), DMIProcessor.class diff --git a/src/main/java/io/github/eggy03/dmidecode/service/system/DMISystemService.java b/src/main/java/io/github/eggy03/dmidecode/service/system/DMISystemService.java index 5852d7e..d728994 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/system/DMISystemService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/system/DMISystemService.java @@ -5,12 +5,13 @@ */ package io.github.eggy03.dmidecode.service.system; +import io.github.eggy03.dmidecode.annotation.Unmodifiable; import io.github.eggy03.dmidecode.constant.DMIType; import io.github.eggy03.dmidecode.entity.system.DMISystem; import io.github.eggy03.dmidecode.mapper.system.DMISystemMapper; import io.github.eggy03.dmidecode.service.OptionalCommonDMIServiceInterface; import io.github.eggy03.dmidecode.utility.TerminalUtility; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NonNull; import java.util.Optional; @@ -48,8 +49,7 @@ public class DMISystemService implements OptionalCommonDMIServiceInterface get(long timeout) { + public @Unmodifiable @NonNull Optional get(long timeout) { return new DMISystemMapper().mapToEntity( TerminalUtility.executeCommand(DMIType.getCommand(DMIType.SYSTEM.getValue()), timeout), DMISystem.class diff --git a/src/main/java/io/github/eggy03/dmidecode/utility/TerminalUtility.java b/src/main/java/io/github/eggy03/dmidecode/utility/TerminalUtility.java index 14a0858..7bfe63f 100644 --- a/src/main/java/io/github/eggy03/dmidecode/utility/TerminalUtility.java +++ b/src/main/java/io/github/eggy03/dmidecode/utility/TerminalUtility.java @@ -6,6 +6,7 @@ package io.github.eggy03.dmidecode.utility; import io.github.eggy03.dmidecode.exception.TerminalExecutionException; +import lombok.NonNull; import lombok.experimental.UtilityClass; import lombok.extern.slf4j.Slf4j; import org.apache.commons.exec.CommandLine; @@ -13,7 +14,6 @@ import org.apache.commons.exec.ExecuteException; import org.apache.commons.exec.ExecuteWatchdog; import org.apache.commons.exec.PumpStreamHandler; -import org.jetbrains.annotations.NotNull; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -23,7 +23,7 @@ * A utility class that provides a way to launch a terminal session *

* Mostly for internal use - * @author Sayan Bhattacharya + * * @since 0.1.0 */ @UtilityClass @@ -41,7 +41,7 @@ public class TerminalUtility { * or when the command yields an error, or when the terminal cannot be accessed. * @throws IllegalArgumentException If the provided timeout is in the negative */ - public static String executeCommand(@NotNull String command, long timeoutSeconds) { + public static String executeCommand(@NonNull String command, long timeoutSeconds) { if(timeoutSeconds<0) throw new IllegalArgumentException("Timeout cannot be negative"); From bc7457619e51cf4e658b3a52b54223a73ee7c17f Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Tue, 31 Mar 2026 15:50:03 +0530 Subject: [PATCH 05/19] chore(docs): remove remaining author tags --- src/main/java/io/github/eggy03/dmidecode/constant/DMIType.java | 1 - .../eggy03/dmidecode/exception/TerminalExecutionException.java | 1 - .../java/io/github/eggy03/dmidecode/mapper/CommonDMIMapper.java | 1 - .../eggy03/dmidecode/mapper/board/DMIBIOSLanguageMapper.java | 1 - .../io/github/eggy03/dmidecode/mapper/board/DMIBIOSMapper.java | 1 - .../github/eggy03/dmidecode/mapper/board/DMIBaseboardMapper.java | 1 - .../github/eggy03/dmidecode/mapper/board/DMIChassisMapper.java | 1 - .../mapper/board/DMIPortConnectionInformationMapper.java | 1 - .../eggy03/dmidecode/mapper/board/DMISystemSlotsMapper.java | 1 - .../dmidecode/mapper/peripheral/DMIPortableBatteryMapper.java | 1 - .../dmidecode/mapper/physicalmemory/DMIMemoryDeviceMapper.java | 1 - .../mapper/physicalmemory/DMIPhysicalMemoryArrayMapper.java | 1 - .../github/eggy03/dmidecode/mapper/processor/DMICacheMapper.java | 1 - .../eggy03/dmidecode/mapper/processor/DMIProcessorMapper.java | 1 - .../github/eggy03/dmidecode/mapper/system/DMISystemMapper.java | 1 - .../eggy03/dmidecode/service/CommonDMIServiceInterface.java | 1 - .../dmidecode/service/OptionalCommonDMIServiceInterface.java | 1 - .../eggy03/dmidecode/service/board/DMIBIOSLanguageService.java | 1 - .../io/github/eggy03/dmidecode/service/board/DMIBIOSService.java | 1 - .../eggy03/dmidecode/service/board/DMIBaseboardService.java | 1 - .../github/eggy03/dmidecode/service/board/DMIChassisService.java | 1 - .../service/board/DMIPortConnectorInformationService.java | 1 - .../eggy03/dmidecode/service/board/DMISystemSlotsService.java | 1 - .../eggy03/dmidecode/service/memory/DMIMemoryDeviceService.java | 1 - .../dmidecode/service/memory/DMIPhysicalMemoryArrayService.java | 1 - .../dmidecode/service/peripheral/DMIPortableBatteryService.java | 1 - .../eggy03/dmidecode/service/processor/DMICacheService.java | 1 - .../eggy03/dmidecode/service/processor/DMIProcessorService.java | 1 - .../github/eggy03/dmidecode/service/system/DMISystemService.java | 1 - 29 files changed, 29 deletions(-) diff --git a/src/main/java/io/github/eggy03/dmidecode/constant/DMIType.java b/src/main/java/io/github/eggy03/dmidecode/constant/DMIType.java index 48c5f12..9285755 100644 --- a/src/main/java/io/github/eggy03/dmidecode/constant/DMIType.java +++ b/src/main/java/io/github/eggy03/dmidecode/constant/DMIType.java @@ -23,7 +23,6 @@ * } * * @since 0.1.0 - * @author Sayan Bhattacharya */ @RequiredArgsConstructor @Getter diff --git a/src/main/java/io/github/eggy03/dmidecode/exception/TerminalExecutionException.java b/src/main/java/io/github/eggy03/dmidecode/exception/TerminalExecutionException.java index eb43b7b..63b08a5 100644 --- a/src/main/java/io/github/eggy03/dmidecode/exception/TerminalExecutionException.java +++ b/src/main/java/io/github/eggy03/dmidecode/exception/TerminalExecutionException.java @@ -10,7 +10,6 @@ /** * Thrown when the terminal fails to execute a command or a script * @since 0.1.0 - * @author Sayan Bhattacharya */ @StandardException public class TerminalExecutionException extends RuntimeException { diff --git a/src/main/java/io/github/eggy03/dmidecode/mapper/CommonDMIMapper.java b/src/main/java/io/github/eggy03/dmidecode/mapper/CommonDMIMapper.java index e506b62..9378ad9 100644 --- a/src/main/java/io/github/eggy03/dmidecode/mapper/CommonDMIMapper.java +++ b/src/main/java/io/github/eggy03/dmidecode/mapper/CommonDMIMapper.java @@ -43,7 +43,6 @@ * * @param the entity type returned by the service implementation * @since 0.1.0 - * @author Sayan Bhattacharjee */ public interface CommonDMIMapper { diff --git a/src/main/java/io/github/eggy03/dmidecode/mapper/board/DMIBIOSLanguageMapper.java b/src/main/java/io/github/eggy03/dmidecode/mapper/board/DMIBIOSLanguageMapper.java index 8d03cbe..7cc7e70 100644 --- a/src/main/java/io/github/eggy03/dmidecode/mapper/board/DMIBIOSLanguageMapper.java +++ b/src/main/java/io/github/eggy03/dmidecode/mapper/board/DMIBIOSLanguageMapper.java @@ -13,7 +13,6 @@ * and maps raw {@code dmidecode} output to objects or lists of {@link DMIBIOSLanguage}. * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMIBIOSLanguageMapper implements CommonDMIMapper { } diff --git a/src/main/java/io/github/eggy03/dmidecode/mapper/board/DMIBIOSMapper.java b/src/main/java/io/github/eggy03/dmidecode/mapper/board/DMIBIOSMapper.java index 01b2801..7bfff0f 100644 --- a/src/main/java/io/github/eggy03/dmidecode/mapper/board/DMIBIOSMapper.java +++ b/src/main/java/io/github/eggy03/dmidecode/mapper/board/DMIBIOSMapper.java @@ -13,7 +13,6 @@ * and maps raw {@code dmidecode} output to objects or lists of {@link DMIBIOS}. * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMIBIOSMapper implements CommonDMIMapper { } diff --git a/src/main/java/io/github/eggy03/dmidecode/mapper/board/DMIBaseboardMapper.java b/src/main/java/io/github/eggy03/dmidecode/mapper/board/DMIBaseboardMapper.java index e719e03..fe2c95e 100644 --- a/src/main/java/io/github/eggy03/dmidecode/mapper/board/DMIBaseboardMapper.java +++ b/src/main/java/io/github/eggy03/dmidecode/mapper/board/DMIBaseboardMapper.java @@ -13,7 +13,6 @@ * and maps raw {@code dmidecode} output to objects or lists of {@link DMIBaseboard}. * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMIBaseboardMapper implements CommonDMIMapper { } diff --git a/src/main/java/io/github/eggy03/dmidecode/mapper/board/DMIChassisMapper.java b/src/main/java/io/github/eggy03/dmidecode/mapper/board/DMIChassisMapper.java index 1ba18ce..08bf882 100644 --- a/src/main/java/io/github/eggy03/dmidecode/mapper/board/DMIChassisMapper.java +++ b/src/main/java/io/github/eggy03/dmidecode/mapper/board/DMIChassisMapper.java @@ -13,7 +13,6 @@ * and maps raw {@code dmidecode} output to objects or lists of {@link DMIChassis}. * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMIChassisMapper implements CommonDMIMapper { } diff --git a/src/main/java/io/github/eggy03/dmidecode/mapper/board/DMIPortConnectionInformationMapper.java b/src/main/java/io/github/eggy03/dmidecode/mapper/board/DMIPortConnectionInformationMapper.java index 2af9739..99a7d44 100644 --- a/src/main/java/io/github/eggy03/dmidecode/mapper/board/DMIPortConnectionInformationMapper.java +++ b/src/main/java/io/github/eggy03/dmidecode/mapper/board/DMIPortConnectionInformationMapper.java @@ -13,7 +13,6 @@ * and maps raw {@code dmidecode} output to objects or lists of {@link DMIPortConnectorInformation}. * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMIPortConnectionInformationMapper implements CommonDMIMapper { } diff --git a/src/main/java/io/github/eggy03/dmidecode/mapper/board/DMISystemSlotsMapper.java b/src/main/java/io/github/eggy03/dmidecode/mapper/board/DMISystemSlotsMapper.java index fa32189..2b641ee 100644 --- a/src/main/java/io/github/eggy03/dmidecode/mapper/board/DMISystemSlotsMapper.java +++ b/src/main/java/io/github/eggy03/dmidecode/mapper/board/DMISystemSlotsMapper.java @@ -13,7 +13,6 @@ * and maps raw {@code dmidecode} output to objects or lists of {@link DMISystemSlots}. * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMISystemSlotsMapper implements CommonDMIMapper { } diff --git a/src/main/java/io/github/eggy03/dmidecode/mapper/peripheral/DMIPortableBatteryMapper.java b/src/main/java/io/github/eggy03/dmidecode/mapper/peripheral/DMIPortableBatteryMapper.java index d9938a0..83803e5 100644 --- a/src/main/java/io/github/eggy03/dmidecode/mapper/peripheral/DMIPortableBatteryMapper.java +++ b/src/main/java/io/github/eggy03/dmidecode/mapper/peripheral/DMIPortableBatteryMapper.java @@ -13,7 +13,6 @@ * and maps raw {@code dmidecode} output to objects or lists of {@link DMIPortableBattery}. * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMIPortableBatteryMapper implements CommonDMIMapper { } diff --git a/src/main/java/io/github/eggy03/dmidecode/mapper/physicalmemory/DMIMemoryDeviceMapper.java b/src/main/java/io/github/eggy03/dmidecode/mapper/physicalmemory/DMIMemoryDeviceMapper.java index 680e52f..071970c 100644 --- a/src/main/java/io/github/eggy03/dmidecode/mapper/physicalmemory/DMIMemoryDeviceMapper.java +++ b/src/main/java/io/github/eggy03/dmidecode/mapper/physicalmemory/DMIMemoryDeviceMapper.java @@ -13,7 +13,6 @@ * and maps raw {@code dmidecode} output to objects or lists of {@link DMIMemoryDevice}. * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMIMemoryDeviceMapper implements CommonDMIMapper { } diff --git a/src/main/java/io/github/eggy03/dmidecode/mapper/physicalmemory/DMIPhysicalMemoryArrayMapper.java b/src/main/java/io/github/eggy03/dmidecode/mapper/physicalmemory/DMIPhysicalMemoryArrayMapper.java index 3f0961e..9a9b515 100644 --- a/src/main/java/io/github/eggy03/dmidecode/mapper/physicalmemory/DMIPhysicalMemoryArrayMapper.java +++ b/src/main/java/io/github/eggy03/dmidecode/mapper/physicalmemory/DMIPhysicalMemoryArrayMapper.java @@ -13,7 +13,6 @@ * and maps raw {@code dmidecode} output to objects or lists of {@link DMIPhysicalMemoryArray}. * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMIPhysicalMemoryArrayMapper implements CommonDMIMapper { } diff --git a/src/main/java/io/github/eggy03/dmidecode/mapper/processor/DMICacheMapper.java b/src/main/java/io/github/eggy03/dmidecode/mapper/processor/DMICacheMapper.java index 1d733ab..608ac44 100644 --- a/src/main/java/io/github/eggy03/dmidecode/mapper/processor/DMICacheMapper.java +++ b/src/main/java/io/github/eggy03/dmidecode/mapper/processor/DMICacheMapper.java @@ -13,7 +13,6 @@ * and maps raw {@code dmidecode} output to objects or lists of {@link DMICache}. * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMICacheMapper implements CommonDMIMapper { } diff --git a/src/main/java/io/github/eggy03/dmidecode/mapper/processor/DMIProcessorMapper.java b/src/main/java/io/github/eggy03/dmidecode/mapper/processor/DMIProcessorMapper.java index 5cc1957..960f886 100644 --- a/src/main/java/io/github/eggy03/dmidecode/mapper/processor/DMIProcessorMapper.java +++ b/src/main/java/io/github/eggy03/dmidecode/mapper/processor/DMIProcessorMapper.java @@ -13,7 +13,6 @@ * and maps raw {@code dmidecode} output to objects or lists of {@link DMIProcessor}. * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMIProcessorMapper implements CommonDMIMapper { } diff --git a/src/main/java/io/github/eggy03/dmidecode/mapper/system/DMISystemMapper.java b/src/main/java/io/github/eggy03/dmidecode/mapper/system/DMISystemMapper.java index 151313b..02e14c8 100644 --- a/src/main/java/io/github/eggy03/dmidecode/mapper/system/DMISystemMapper.java +++ b/src/main/java/io/github/eggy03/dmidecode/mapper/system/DMISystemMapper.java @@ -13,7 +13,6 @@ * and maps raw {@code dmidecode} output to objects or lists of {@link DMISystem}. * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMISystemMapper implements CommonDMIMapper { } diff --git a/src/main/java/io/github/eggy03/dmidecode/service/CommonDMIServiceInterface.java b/src/main/java/io/github/eggy03/dmidecode/service/CommonDMIServiceInterface.java index bd190e5..5397e7e 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/CommonDMIServiceInterface.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/CommonDMIServiceInterface.java @@ -19,7 +19,6 @@ * @param the entity type returned by the service implementation * * @since 0.1.0 - * @author Sayan Bhattacharya * @see OptionalCommonDMIServiceInterface */ public interface CommonDMIServiceInterface { diff --git a/src/main/java/io/github/eggy03/dmidecode/service/OptionalCommonDMIServiceInterface.java b/src/main/java/io/github/eggy03/dmidecode/service/OptionalCommonDMIServiceInterface.java index cc463ea..ab3cb9f 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/OptionalCommonDMIServiceInterface.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/OptionalCommonDMIServiceInterface.java @@ -19,7 +19,6 @@ * @param the entity type returned by the service implementation * * @since 0.1.0 - * @author Sayan Bhattacharya * @see CommonDMIServiceInterface */ public interface OptionalCommonDMIServiceInterface { diff --git a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSLanguageService.java b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSLanguageService.java index 8785c18..b029875 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSLanguageService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSLanguageService.java @@ -28,7 +28,6 @@ * } * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMIBIOSLanguageService implements OptionalCommonDMIServiceInterface { diff --git a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSService.java b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSService.java index dc3b490..847d840 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSService.java @@ -29,7 +29,6 @@ * } * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMIBIOSService implements CommonDMIServiceInterface { diff --git a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBaseboardService.java b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBaseboardService.java index 7532a13..763855c 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBaseboardService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBaseboardService.java @@ -29,7 +29,6 @@ * } * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMIBaseboardService implements OptionalCommonDMIServiceInterface { diff --git a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIChassisService.java b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIChassisService.java index 282164e..d4104dc 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIChassisService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIChassisService.java @@ -28,7 +28,6 @@ * } * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMIChassisService implements OptionalCommonDMIServiceInterface { diff --git a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIPortConnectorInformationService.java b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIPortConnectorInformationService.java index 6ea8ceb..521796c 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIPortConnectorInformationService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIPortConnectorInformationService.java @@ -29,7 +29,6 @@ * } * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMIPortConnectorInformationService implements CommonDMIServiceInterface { diff --git a/src/main/java/io/github/eggy03/dmidecode/service/board/DMISystemSlotsService.java b/src/main/java/io/github/eggy03/dmidecode/service/board/DMISystemSlotsService.java index d275212..3d0f8fc 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/board/DMISystemSlotsService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/board/DMISystemSlotsService.java @@ -29,7 +29,6 @@ * } * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMISystemSlotsService implements CommonDMIServiceInterface { diff --git a/src/main/java/io/github/eggy03/dmidecode/service/memory/DMIMemoryDeviceService.java b/src/main/java/io/github/eggy03/dmidecode/service/memory/DMIMemoryDeviceService.java index 0108209..632466e 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/memory/DMIMemoryDeviceService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/memory/DMIMemoryDeviceService.java @@ -29,7 +29,6 @@ * } * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMIMemoryDeviceService implements CommonDMIServiceInterface { diff --git a/src/main/java/io/github/eggy03/dmidecode/service/memory/DMIPhysicalMemoryArrayService.java b/src/main/java/io/github/eggy03/dmidecode/service/memory/DMIPhysicalMemoryArrayService.java index 60136aa..6ca1f73 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/memory/DMIPhysicalMemoryArrayService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/memory/DMIPhysicalMemoryArrayService.java @@ -28,7 +28,6 @@ * } * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMIPhysicalMemoryArrayService implements OptionalCommonDMIServiceInterface { diff --git a/src/main/java/io/github/eggy03/dmidecode/service/peripheral/DMIPortableBatteryService.java b/src/main/java/io/github/eggy03/dmidecode/service/peripheral/DMIPortableBatteryService.java index f8ddd07..c0ca3d6 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/peripheral/DMIPortableBatteryService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/peripheral/DMIPortableBatteryService.java @@ -29,7 +29,6 @@ * } * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMIPortableBatteryService implements CommonDMIServiceInterface { diff --git a/src/main/java/io/github/eggy03/dmidecode/service/processor/DMICacheService.java b/src/main/java/io/github/eggy03/dmidecode/service/processor/DMICacheService.java index 28b9ff3..9bd5b06 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/processor/DMICacheService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/processor/DMICacheService.java @@ -29,7 +29,6 @@ * } * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMICacheService implements CommonDMIServiceInterface { diff --git a/src/main/java/io/github/eggy03/dmidecode/service/processor/DMIProcessorService.java b/src/main/java/io/github/eggy03/dmidecode/service/processor/DMIProcessorService.java index ac26b14..2e370f0 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/processor/DMIProcessorService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/processor/DMIProcessorService.java @@ -29,7 +29,6 @@ * } * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMIProcessorService implements CommonDMIServiceInterface { diff --git a/src/main/java/io/github/eggy03/dmidecode/service/system/DMISystemService.java b/src/main/java/io/github/eggy03/dmidecode/service/system/DMISystemService.java index d728994..068cf0d 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/system/DMISystemService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/system/DMISystemService.java @@ -29,7 +29,6 @@ * } * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMISystemService implements OptionalCommonDMIServiceInterface { From 08f7c843c3cfdf9dda246ed767b41aa96cf0b9e7 Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Tue, 31 Mar 2026 15:50:17 +0530 Subject: [PATCH 06/19] chore: update developer mail --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5786cb3..be014ef 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ Egg-03 Sayan Bhattacharjee - egg03@duck.com + eggzerothree@proton.me https://github.com/eggy03/dmidecode4j.git scm:git:ssh://git@github.com:eggy03/dmidecode4j.git From 7b69c09fc3d1493550217cd8dcce164c592a684d Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Tue, 31 Mar 2026 15:57:12 +0530 Subject: [PATCH 07/19] refactor(dmitype): update command generation function - Replace `DMIType.getCommand(int)` with `DMIType.getCommandFor(DMIType)` - Remove Lombok's `@Getter` annotation from `DMIType` since `getValue()` is no longer needed to be a part of the public API contract. - Update all service classes to use the new `DMIType.getCommandFor()` method --- .../java/io/github/eggy03/dmidecode/constant/DMIType.java | 8 +++----- .../dmidecode/service/board/DMIBIOSLanguageService.java | 2 +- .../eggy03/dmidecode/service/board/DMIBIOSService.java | 2 +- .../dmidecode/service/board/DMIBaseboardService.java | 2 +- .../eggy03/dmidecode/service/board/DMIChassisService.java | 2 +- .../service/board/DMIPortConnectorInformationService.java | 2 +- .../dmidecode/service/board/DMISystemSlotsService.java | 2 +- .../dmidecode/service/memory/DMIMemoryDeviceService.java | 2 +- .../service/memory/DMIPhysicalMemoryArrayService.java | 2 +- .../service/peripheral/DMIPortableBatteryService.java | 2 +- .../dmidecode/service/processor/DMICacheService.java | 2 +- .../dmidecode/service/processor/DMIProcessorService.java | 2 +- .../eggy03/dmidecode/service/system/DMISystemService.java | 2 +- 13 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/main/java/io/github/eggy03/dmidecode/constant/DMIType.java b/src/main/java/io/github/eggy03/dmidecode/constant/DMIType.java index 9285755..eb1e24f 100644 --- a/src/main/java/io/github/eggy03/dmidecode/constant/DMIType.java +++ b/src/main/java/io/github/eggy03/dmidecode/constant/DMIType.java @@ -5,7 +5,6 @@ */ package io.github.eggy03.dmidecode.constant; -import lombok.Getter; import lombok.RequiredArgsConstructor; /** @@ -19,13 +18,12 @@ *

Usage example

*
{@code
  * // Build a dmidecode command for querying baseboard information
- * String command = DMIType.getCommand(DMIType.BASEBOARD.getValue());
+ * String command = DMIType.getCommandFor(DMIType.BASEBOARD);
  * }
* * @since 0.1.0 */ @RequiredArgsConstructor -@Getter public enum DMIType { BIOS(0), @@ -73,7 +71,7 @@ public enum DMIType { private final int value; - public static String getCommand(int dmiType){ - return "sudo /usr/sbin/dmidecode --type "+dmiType; + public static String getCommandFor(DMIType type){ + return "sudo /usr/sbin/dmidecode --type " + type.value; } } \ No newline at end of file diff --git a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSLanguageService.java b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSLanguageService.java index b029875..fbe2bae 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSLanguageService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSLanguageService.java @@ -48,7 +48,7 @@ public class DMIBIOSLanguageService implements OptionalCommonDMIServiceInterface @Override public @NonNull Optional get(long timeout) { return new DMIBIOSLanguageMapper().mapToEntity( - TerminalUtility.executeCommand(DMIType.getCommand(DMIType.BIOS_LANGUAGE.getValue()), timeout), + TerminalUtility.executeCommand(DMIType.getCommandFor(DMIType.BIOS_LANGUAGE), timeout), DMIBIOSLanguage.class ); } diff --git a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSService.java b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSService.java index 847d840..15d3b88 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSService.java @@ -49,7 +49,7 @@ public class DMIBIOSService implements CommonDMIServiceInterface { @Override public @NonNull @Unmodifiable List get(long timeout) { return new DMIBIOSMapper().mapToList( - TerminalUtility.executeCommand(DMIType.getCommand(DMIType.BIOS.getValue()), timeout), + TerminalUtility.executeCommand(DMIType.getCommandFor(DMIType.BIOS), timeout), DMIBIOS.class ); } diff --git a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBaseboardService.java b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBaseboardService.java index 763855c..832fda6 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBaseboardService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBaseboardService.java @@ -49,7 +49,7 @@ public class DMIBaseboardService implements OptionalCommonDMIServiceInterface get(long timeout) { return new DMIBaseboardMapper().mapToEntity( - TerminalUtility.executeCommand(DMIType.getCommand(DMIType.BASEBOARD.getValue()), timeout), + TerminalUtility.executeCommand(DMIType.getCommandFor(DMIType.BASEBOARD), timeout), DMIBaseboard.class ); } diff --git a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIChassisService.java b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIChassisService.java index d4104dc..09eca67 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIChassisService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIChassisService.java @@ -48,7 +48,7 @@ public class DMIChassisService implements OptionalCommonDMIServiceInterface get(long timeout) { return new DMIChassisMapper().mapToEntity( - TerminalUtility.executeCommand(DMIType.getCommand(DMIType.CHASSIS.getValue()), timeout), + TerminalUtility.executeCommand(DMIType.getCommandFor(DMIType.CHASSIS), timeout), DMIChassis.class ); } diff --git a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIPortConnectorInformationService.java b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIPortConnectorInformationService.java index 521796c..2884229 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIPortConnectorInformationService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIPortConnectorInformationService.java @@ -50,7 +50,7 @@ public class DMIPortConnectorInformationService implements CommonDMIServiceInter @Override public @Unmodifiable @NonNull List get(long timeout) { return new DMIPortConnectionInformationMapper().mapToList( - TerminalUtility.executeCommand(DMIType.getCommand(DMIType.PORT_CONNECTOR.getValue()), timeout), + TerminalUtility.executeCommand(DMIType.getCommandFor(DMIType.PORT_CONNECTOR), timeout), DMIPortConnectorInformation.class ); } diff --git a/src/main/java/io/github/eggy03/dmidecode/service/board/DMISystemSlotsService.java b/src/main/java/io/github/eggy03/dmidecode/service/board/DMISystemSlotsService.java index 3d0f8fc..44aa143 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/board/DMISystemSlotsService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/board/DMISystemSlotsService.java @@ -50,7 +50,7 @@ public class DMISystemSlotsService implements CommonDMIServiceInterface get(long timeout) { return new DMISystemSlotsMapper().mapToList( - TerminalUtility.executeCommand(DMIType.getCommand(DMIType.SYSTEM_SLOTS.getValue()), timeout), + TerminalUtility.executeCommand(DMIType.getCommandFor(DMIType.SYSTEM_SLOTS), timeout), DMISystemSlots.class ); } diff --git a/src/main/java/io/github/eggy03/dmidecode/service/memory/DMIMemoryDeviceService.java b/src/main/java/io/github/eggy03/dmidecode/service/memory/DMIMemoryDeviceService.java index 632466e..e939a44 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/memory/DMIMemoryDeviceService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/memory/DMIMemoryDeviceService.java @@ -50,7 +50,7 @@ public class DMIMemoryDeviceService implements CommonDMIServiceInterface get(long timeout) { return new DMIMemoryDeviceMapper().mapToList( - TerminalUtility.executeCommand(DMIType.getCommand(DMIType.MEMORY_DEVICE.getValue()), timeout), + TerminalUtility.executeCommand(DMIType.getCommandFor(DMIType.MEMORY_DEVICE), timeout), DMIMemoryDevice.class ); } diff --git a/src/main/java/io/github/eggy03/dmidecode/service/memory/DMIPhysicalMemoryArrayService.java b/src/main/java/io/github/eggy03/dmidecode/service/memory/DMIPhysicalMemoryArrayService.java index 6ca1f73..3f31f4b 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/memory/DMIPhysicalMemoryArrayService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/memory/DMIPhysicalMemoryArrayService.java @@ -49,7 +49,7 @@ public class DMIPhysicalMemoryArrayService implements OptionalCommonDMIServiceIn @Override public @NonNull Optional get(long timeout) { return new DMIPhysicalMemoryArrayMapper().mapToEntity( - TerminalUtility.executeCommand(DMIType.getCommand(DMIType.PHYSICAL_MEMORY_ARRAY.getValue()), timeout), + TerminalUtility.executeCommand(DMIType.getCommandFor(DMIType.PHYSICAL_MEMORY_ARRAY), timeout), DMIPhysicalMemoryArray.class ); } diff --git a/src/main/java/io/github/eggy03/dmidecode/service/peripheral/DMIPortableBatteryService.java b/src/main/java/io/github/eggy03/dmidecode/service/peripheral/DMIPortableBatteryService.java index c0ca3d6..9d71ed3 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/peripheral/DMIPortableBatteryService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/peripheral/DMIPortableBatteryService.java @@ -50,7 +50,7 @@ public class DMIPortableBatteryService implements CommonDMIServiceInterface get(long timeout) { return new DMIPortableBatteryMapper().mapToList( - TerminalUtility.executeCommand(DMIType.getCommand(DMIType.PORTABLE_BATTERY.getValue()), timeout), + TerminalUtility.executeCommand(DMIType.getCommandFor(DMIType.PORTABLE_BATTERY), timeout), DMIPortableBattery.class ); } diff --git a/src/main/java/io/github/eggy03/dmidecode/service/processor/DMICacheService.java b/src/main/java/io/github/eggy03/dmidecode/service/processor/DMICacheService.java index 9bd5b06..7bd1d00 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/processor/DMICacheService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/processor/DMICacheService.java @@ -50,7 +50,7 @@ public class DMICacheService implements CommonDMIServiceInterface { @Override public @Unmodifiable @NonNull List get(long timeout) { return new DMICacheMapper().mapToList( - TerminalUtility.executeCommand(DMIType.getCommand(DMIType.CACHE.getValue()), timeout), + TerminalUtility.executeCommand(DMIType.getCommandFor(DMIType.CACHE), timeout), DMICache.class ); } diff --git a/src/main/java/io/github/eggy03/dmidecode/service/processor/DMIProcessorService.java b/src/main/java/io/github/eggy03/dmidecode/service/processor/DMIProcessorService.java index 2e370f0..4c3f895 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/processor/DMIProcessorService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/processor/DMIProcessorService.java @@ -49,7 +49,7 @@ public class DMIProcessorService implements CommonDMIServiceInterface get(long timeout) { return new DMIProcessorMapper().mapToList( - TerminalUtility.executeCommand(DMIType.getCommand(DMIType.PROCESSOR.getValue()), timeout), + TerminalUtility.executeCommand(DMIType.getCommandFor(DMIType.PROCESSOR), timeout), DMIProcessor.class ); } diff --git a/src/main/java/io/github/eggy03/dmidecode/service/system/DMISystemService.java b/src/main/java/io/github/eggy03/dmidecode/service/system/DMISystemService.java index 068cf0d..0c39c9e 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/system/DMISystemService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/system/DMISystemService.java @@ -50,7 +50,7 @@ public class DMISystemService implements OptionalCommonDMIServiceInterface get(long timeout) { return new DMISystemMapper().mapToEntity( - TerminalUtility.executeCommand(DMIType.getCommand(DMIType.SYSTEM.getValue()), timeout), + TerminalUtility.executeCommand(DMIType.getCommandFor(DMIType.SYSTEM), timeout), DMISystem.class ); } From 12541f2d67b56d771dea736b0159b0512da66ffb Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Tue, 31 Mar 2026 22:17:31 +0530 Subject: [PATCH 08/19] refactor(mapper): replace Gson with Jackson - Remove `Gson` dependency from `pom.xml`. - Replace `Gson` with `Jackson` in `CommonDMIMapper`. - Update `MockEntityClass` in `CommonDMIMapperTest` to use Jackson annotations and remove Lombok. --- pom.xml | 6 -- .../dmidecode/mapper/CommonDMIMapper.java | 83 +++++++++---------- .../dmidecode/mapper/CommonDMIMapperTest.java | 75 ++++++++++------- 3 files changed, 83 insertions(+), 81 deletions(-) diff --git a/pom.xml b/pom.xml index be014ef..77fde3b 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,6 @@ 2.12.1 1.18.42 - 2.13.2 3.1.1 1.0.0 6.0.0 @@ -88,11 +87,6 @@ jackson-databind compile
- - com.google.code.gson - gson - ${google.gson.version} - org.projectlombok lombok diff --git a/src/main/java/io/github/eggy03/dmidecode/mapper/CommonDMIMapper.java b/src/main/java/io/github/eggy03/dmidecode/mapper/CommonDMIMapper.java index 9378ad9..c394276 100644 --- a/src/main/java/io/github/eggy03/dmidecode/mapper/CommonDMIMapper.java +++ b/src/main/java/io/github/eggy03/dmidecode/mapper/CommonDMIMapper.java @@ -5,11 +5,10 @@ */ package io.github.eggy03.dmidecode.mapper; -import com.google.gson.Gson; -import com.google.gson.JsonElement; import io.github.eggy03.dmidecode.annotation.Unmodifiable; import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; +import tools.jackson.databind.ObjectMapper; import java.util.ArrayList; import java.util.Collections; @@ -38,7 +37,7 @@ *
  • 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 Gson
  • + *
  • Deserializing the JSON into the requested entity class using Jackson
  • * * * @param the entity type returned by the service implementation @@ -46,7 +45,7 @@ */ public interface CommonDMIMapper { - Gson GSON = new Gson(); + ObjectMapper jacksonMapper = new ObjectMapper(); /** * Maps raw {@code dmidecode} output into a single entity of type {@code }. @@ -91,50 +90,46 @@ public interface CommonDMIMapper { Map keyValueMap = new LinkedHashMap<>(); - StringBuilder key = new StringBuilder(); - // for single-line values - Object value = null; - // for multi-line values - List values = new ArrayList<>(); + String key = null; + String singleLineValue = null; // for single-line values + List multiLineValues = new ArrayList<>(); // for multi-line values // split each line in the active block separated by a newline [each string will be a single line "key:single-line-value" or a multi line "key:multi-line-value" for (String currentLine : rawDMIData.split(System.lineSeparator())) { if (currentLine.contains(":")) { // store the previous key and value if present, indicated by a key of length greater than 0 - if (key.length() > 0) { + if (key!=null && !key.isEmpty()) { // if the value has multi lines, insert them or else insert the single line value - keyValueMap.put(key.toString(), !values.isEmpty() ? new ArrayList<>(values) : value); + keyValueMap.put(key, !multiLineValues.isEmpty() ? new ArrayList<>(multiLineValues) : singleLineValue); } // Reset state so we can start processing this new "key: value" line - key.setLength(0); - value = null; - values.clear(); // keeping this outside the key length check helps clear out any accumulated DMI headers so that they don't get added in the values. The reason is that these values have no keys, so key length is always 0 + singleLineValue = null; + multiLineValues.clear(); // keeping this outside the key length check helps clear out any accumulated DMI headers so that they don't get added in the values. The reason is that these values have no keys, so key length is always 0 // Split "Key: Value" into LHS and RHS String[] parts = currentLine.split(":", 2); - key.append(parts[0].trim()); + key = parts[0].trim(); if (!parts[1].trim().isEmpty()) // skip values that are empty near the immediate key, especially in cases where values are multi-lines; for them each value starts in a new line after the key (e.g. "Supported SRAM Types:" before the indented list) - value = parts[1].trim(); + singleLineValue = parts[1].trim(); } else {// if the value spans across multiple lines, convert the value to an arraylist // If we previously captured a single value (for this key), // move it into a list so that subsequent values append cleanly. - if (value != null) { // add the last singular value to the value list. this value is usually the first value in the array of values - values.add(value); - value = null; // set the value to null the single value does not get repeated during appending the subsequent values + if (singleLineValue != null) { // add the last singular value to the value list. this value is usually the first value in the array of values + multiLineValues.add(singleLineValue); + singleLineValue = null; // set the value to null the single value does not get repeated during appending the subsequent values } - values.add(currentLine.trim()); // Add the current list item + multiLineValues.add(currentLine.trim()); // Add the current list item } } // Store the last key/value pair - if (key.length() > 0) { - keyValueMap.put(key.toString(), !values.isEmpty() ? new ArrayList<>(values) : value); + if (key!=null && !key.isEmpty()) { + keyValueMap.put(key, !multiLineValues.isEmpty() ? new ArrayList<>(multiLineValues) : singleLineValue); } // convert the kv map to JSON and deserialize into an entity class - JsonElement mapElement = GSON.toJsonTree(keyValueMap); - return Optional.ofNullable(GSON.fromJson(mapElement, mappableEntityClass)); + return Optional.ofNullable(jacksonMapper.convertValue(keyValueMap, mappableEntityClass)); } /** @@ -193,11 +188,9 @@ public interface CommonDMIMapper { Map keyValueMap = new HashMap<>(); - StringBuilder key = new StringBuilder(); - // for single-line values - Object value = null; - // for multi-line values - List values = new ArrayList<>(); + String key = null; + String singleLineValue = null; // for single-line values + List multiLineValues = new ArrayList<>(); // for multi-line values // each DMI block is separated by a double new line for (String currentDMIObject : rawDMIData.split(System.lineSeparator() + System.lineSeparator())) { @@ -207,48 +200,46 @@ public interface CommonDMIMapper { if (currentLine.contains(":")) { // store the previous key and value if present, indicated by a key of length greater than 0 - if (key.length() > 0) { + if (key!=null && !key.isEmpty()) { // if the value has multi lines, insert them or else insert the single line value - keyValueMap.put(key.toString(), !values.isEmpty() ? new ArrayList<>(values) : value); + keyValueMap.put(key, !multiLineValues.isEmpty() ? new ArrayList<>(multiLineValues) : singleLineValue); } // Reset state so we can start processing this new "key: value" line - key.setLength(0); - value = null; - values.clear(); // keeping this outside the key length check helps clear out any accumulated DMI headers so that they don't get added in the values. The reason is that these values have no keys, so key length is always 0 + singleLineValue = null; + multiLineValues.clear(); // keeping this outside the key length check helps clear out any accumulated DMI headers so that they don't get added in the values. The reason is that these values have no keys, so key length is always 0 // Split "Key: Value" into LHS and RHS String[] parts = currentLine.split(":", 2); - key.append(parts[0].trim()); + key = parts[0].trim(); if (!parts[1].trim().isEmpty()) // skip values that are empty near the immediate key, especially in cases where values are multilines; for them each value starts in a new line after the key (e.g. "Supported SRAM Types:" before the indented list) - value = parts[1].trim(); + singleLineValue = parts[1].trim(); } else {// if the value spans across multiple lines, convert the value to an arraylist // If we previously captured a single value (for this key), // move it into a list so that subsequent values append cleanly. - if (value != null) { - values.add(value); - value = null; // set the value to null the single value does not get repeated during appending the subsequent values + if (singleLineValue != null) { + multiLineValues.add(singleLineValue); + singleLineValue = null; // set the value to null the single value does not get repeated during appending the subsequent values } - values.add(currentLine.trim()); // Add the current list item + multiLineValues.add(currentLine.trim()); // Add the current list item } } // Store the last key/value pair in this DMI block - if (key.length() > 0) { - keyValueMap.put(key.toString(), !values.isEmpty() ? new ArrayList<>(values) : value); + if (key!=null && !key.isEmpty()) { + keyValueMap.put(key, !multiLineValues.isEmpty() ? new ArrayList<>(multiLineValues) : singleLineValue); } // convert each kv map into a JSON and then deserialize into an entity class if (!keyValueMap.isEmpty()) { // prevent empty entities from being serialized - JsonElement mapElement = GSON.toJsonTree(keyValueMap); - S entity = GSON.fromJson(mapElement, mappableEntityClass); + S entity = jacksonMapper.convertValue(keyValueMap, mappableEntityClass); if (entity != null) entityList.add(entity); } // reset the kv map, key and value to get ready for the next DMIObject keyValueMap.clear(); - key.setLength(0); - value = null; + key = null; + singleLineValue = null; } return entityList.isEmpty() ? Collections.emptyList() : Collections.unmodifiableList(new ArrayList<>(entityList)); } diff --git a/src/test/java/io/github/eggy03/dmidecode/mapper/CommonDMIMapperTest.java b/src/test/java/io/github/eggy03/dmidecode/mapper/CommonDMIMapperTest.java index 8731c71..04d56ec 100644 --- a/src/test/java/io/github/eggy03/dmidecode/mapper/CommonDMIMapperTest.java +++ b/src/test/java/io/github/eggy03/dmidecode/mapper/CommonDMIMapperTest.java @@ -1,14 +1,13 @@ package io.github.eggy03.dmidecode.mapper; -import com.google.gson.annotations.SerializedName; -import lombok.Builder; -import lombok.Value; -import org.jetbrains.annotations.Nullable; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.jspecify.annotations.Nullable; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; +import java.util.Objects; import java.util.Optional; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; @@ -17,21 +16,51 @@ class CommonDMIMapperTest { private static final String LS = System.lineSeparator(); - @Value - @Builder(toBuilder = true) static class MockEntityClass { @Nullable - @SerializedName("ID") + @JsonProperty("ID") Long id; @Nullable - @SerializedName("Value") + @JsonProperty("Value") String value; @Nullable - @SerializedName("Values") - List values; + @JsonProperty("Values") + List<@Nullable String> values; + + public MockEntityClass() { + this.id=null; + this.value=null; + this.values=null; + } + + public MockEntityClass(@Nullable Long id, @Nullable String value, @Nullable List<@Nullable String> values) { + this.id=id; + this.value=value; + this.values=values; + } + + @Override + public String toString() { + return "{\n\t" + this.id + ",\n\t" + this.value + ",\n\t" + this.values + "\n}"; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof MockEntityClass)) return false; + MockEntityClass that = (MockEntityClass) o; + return Objects.equals(id, that.id) && + Objects.equals(value, that.value) && + Objects.equals(values, that.values); + } + + @Override + public int hashCode() { + return Objects.hash(id, value, values); + } } @@ -64,11 +93,7 @@ static void setSingleEntityData() { .append("\t\tValue1").append(LS) .append("\t\tValue2").append(LS); - singleEntityTestClass = MockEntityClass.builder() - .id(1L) - .value("ValueA") - .values(Arrays.asList("Value1", "Value2")) - .build(); + singleEntityTestClass = new MockEntityClass(1L, "ValueA", Arrays.asList("Value1", "Value2")); } @BeforeAll @@ -103,17 +128,9 @@ static void setMultipleEntityData() { .append("\t\tValue3").append(LS) .append("\t\tValue4").append(LS).append(LS); - multipleEntityClassOne = MockEntityClass.builder() - .id(1L) - .value("ValueA") - .values(Arrays.asList("Value1", "Value2")) - .build(); - - multipleEntityClassTwo = MockEntityClass.builder() - .id(2L) - .value("ValueB") - .values(Arrays.asList("Value3", "Value4")) - .build(); + multipleEntityClassOne = new MockEntityClass(1L, "ValueA", Arrays.asList("Value1", "Value2")); + + multipleEntityClassTwo = new MockEntityClass(2L, "ValueB", Arrays.asList("Value3", "Value4")); } @Test @@ -141,15 +158,15 @@ void test_mapToEntity_keyWithNoValue() { String data = "ID: 1" + LS + "Value:" + LS + "Values: "; Optional result = mapper.mapToEntity(data, MockEntityClass.class); - assertThat(result.isPresent()); - assertThat(result).contains(MockEntityClass.builder().id(1L).build()); + assertThat(result).isPresent(); + assertThat(result).contains(new MockEntityClass(1L, null, null)); } @Test void test_mapToEntity_empty_success() { Optional testClass = mapper.mapToEntity(emptyData.toString(), MockEntityClass.class); assertThat(testClass).isPresent(); - assertThat(testClass).contains(MockEntityClass.builder().build()); // empty entity class with null values + assertThat(testClass).contains(new MockEntityClass()); // empty entity class with null values } From 9006dbd31e4a57ec20b990a50411cffdd9f2a9b8 Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Tue, 31 Mar 2026 23:53:00 +0530 Subject: [PATCH 09/19] refactor(annotation): make `Unmodifiable` available at runtime --- .../io/github/eggy03/dmidecode/annotation/Unmodifiable.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/eggy03/dmidecode/annotation/Unmodifiable.java b/src/main/java/io/github/eggy03/dmidecode/annotation/Unmodifiable.java index 10dd310..e4f11c8 100644 --- a/src/main/java/io/github/eggy03/dmidecode/annotation/Unmodifiable.java +++ b/src/main/java/io/github/eggy03/dmidecode/annotation/Unmodifiable.java @@ -20,7 +20,7 @@ * @since 0.2.0 */ @Target({ElementType.TYPE_USE}) -@Retention(RetentionPolicy.CLASS) +@Retention(RetentionPolicy.RUNTIME) @Documented public @interface Unmodifiable { } From 9a97ad893fed93fde92b2f4a01ed5e85689a48b4 Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Wed, 1 Apr 2026 12:21:06 +0530 Subject: [PATCH 10/19] feat(annotations): document fragile dmidecode parsing methods - add `@FragileMethod` to `CommonDMIMapper`'s default methods - add `@InvokesFragileMethod` to service methods that use `CommonDMIMapper` --- .../annotation/fragility/FragileMethod.java | 52 +++++++++++++++++++ .../fragility/InvokesFragileMethod.java | 42 +++++++++++++++ .../fragility/InvokesFragileMethods.java | 15 ++++++ .../annotation/fragility/MethodType.java | 37 +++++++++++++ .../dmidecode/mapper/CommonDMIMapper.java | 14 +++++ .../service/board/DMIBIOSLanguageService.java | 4 ++ .../service/board/DMIBIOSService.java | 4 ++ .../service/board/DMIBaseboardService.java | 4 ++ .../service/board/DMIChassisService.java | 4 ++ .../DMIPortConnectorInformationService.java | 4 ++ .../service/board/DMISystemSlotsService.java | 4 ++ 11 files changed, 184 insertions(+) create mode 100644 src/main/java/io/github/eggy03/dmidecode/annotation/fragility/FragileMethod.java create mode 100644 src/main/java/io/github/eggy03/dmidecode/annotation/fragility/InvokesFragileMethod.java create mode 100644 src/main/java/io/github/eggy03/dmidecode/annotation/fragility/InvokesFragileMethods.java create mode 100644 src/main/java/io/github/eggy03/dmidecode/annotation/fragility/MethodType.java diff --git a/src/main/java/io/github/eggy03/dmidecode/annotation/fragility/FragileMethod.java b/src/main/java/io/github/eggy03/dmidecode/annotation/fragility/FragileMethod.java new file mode 100644 index 0000000..ddef574 --- /dev/null +++ b/src/main/java/io/github/eggy03/dmidecode/annotation/fragility/FragileMethod.java @@ -0,0 +1,52 @@ +package io.github.eggy03.dmidecode.annotation.fragility; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + *

    + * When marked on a method (or a constructor), it serves as an indication that + * the method's behavior depends on unstable and or environment-specific logic + * and may break without notice. + *

    + *

    + * A method annotated with {@code @FragileMethod} should not be used in production. + * However, if usage in production is unavoidable, any method or constructor that + * invokes a fragile method in its definition should be annotated with {@code @InvokesFragileMethod}. + *

    + *

    + * This annotation is for documentation purposes only. + *

    + * + * @since 0.2.0 + * @see InvokesFragileMethod + */ +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD, ElementType.CONSTRUCTOR}) +public @interface FragileMethod { + + /** + * The type of method marked with this annotation + */ + MethodType type(); + + /** + * The reason why the element is marked with this annotation + */ + String reason(); + + /** + * Indicates whether the method needs to be replaced with a better logic + */ + boolean requiresReplacement() default false; + + /** + * States any possible solutions to the fragility problem + */ + String replacementNote() default ""; + +} diff --git a/src/main/java/io/github/eggy03/dmidecode/annotation/fragility/InvokesFragileMethod.java b/src/main/java/io/github/eggy03/dmidecode/annotation/fragility/InvokesFragileMethod.java new file mode 100644 index 0000000..d50a333 --- /dev/null +++ b/src/main/java/io/github/eggy03/dmidecode/annotation/fragility/InvokesFragileMethod.java @@ -0,0 +1,42 @@ +package io.github.eggy03.dmidecode.annotation.fragility; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Repeatable; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + *

    + * When marked on a method (or a constructor), it indicates that annotated method or constructor + * has a definition that invokes a method or a constructor annotated with {@code FragileMethod} + *

    + *

    + * This annotation is for documentation purposes only. + *

    + * + * @since 0.2.0 + * @see FragileMethod + */ +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD, ElementType.CONSTRUCTOR}) +@Repeatable(InvokesFragileMethods.class) +public @interface InvokesFragileMethod { + + /** + * The class whose methods, marked with {@code FragileMethod}, are being invoked. + */ + Class targetClass(); + + /** + * The type of method that has been marked with {@code FragileMethod} + */ + MethodType methodType(); + + /** + * The method names of the {@code FragileMethod} annotated types + */ + String[] methodName() default {}; +} diff --git a/src/main/java/io/github/eggy03/dmidecode/annotation/fragility/InvokesFragileMethods.java b/src/main/java/io/github/eggy03/dmidecode/annotation/fragility/InvokesFragileMethods.java new file mode 100644 index 0000000..9db2cfd --- /dev/null +++ b/src/main/java/io/github/eggy03/dmidecode/annotation/fragility/InvokesFragileMethods.java @@ -0,0 +1,15 @@ +package io.github.eggy03.dmidecode.annotation.fragility; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD, ElementType.CONSTRUCTOR}) +public @interface InvokesFragileMethods { + + InvokesFragileMethod[] value(); +} diff --git a/src/main/java/io/github/eggy03/dmidecode/annotation/fragility/MethodType.java b/src/main/java/io/github/eggy03/dmidecode/annotation/fragility/MethodType.java new file mode 100644 index 0000000..1dc4181 --- /dev/null +++ b/src/main/java/io/github/eggy03/dmidecode/annotation/fragility/MethodType.java @@ -0,0 +1,37 @@ +package io.github.eggy03.dmidecode.annotation.fragility; + +/** + * Enum to classify the type of method that is marked as fragile + * + * @since 0.2.0 + * @see FragileMethod + * @see InvokesFragileMethod + */ +public enum MethodType { + + /** + * Indicates that an instance method is marked as {@link FragileMethod} + */ + INSTANCE_METHOD, + + /** + * Indicates that a static method is marked as {@link FragileMethod} + */ + STATIC_METHOD, + + /** + * Indicates that an abstract method from an abstract class or an interface is marked as {@link FragileMethod} + */ + ABSTRACT_METHOD, + + /** + * Indicates that a default method from an interface is marked as {@link FragileMethod} + */ + INTERFACE_DEFAULT_METHOD, + + + /** + * Indicates that a constructor is marked as {@link FragileMethod} + */ + CONSTRUCTOR +} diff --git a/src/main/java/io/github/eggy03/dmidecode/mapper/CommonDMIMapper.java b/src/main/java/io/github/eggy03/dmidecode/mapper/CommonDMIMapper.java index c394276..79f3054 100644 --- a/src/main/java/io/github/eggy03/dmidecode/mapper/CommonDMIMapper.java +++ b/src/main/java/io/github/eggy03/dmidecode/mapper/CommonDMIMapper.java @@ -6,6 +6,8 @@ package io.github.eggy03.dmidecode.mapper; import io.github.eggy03.dmidecode.annotation.Unmodifiable; +import io.github.eggy03.dmidecode.annotation.fragility.FragileMethod; +import io.github.eggy03.dmidecode.annotation.fragility.MethodType; import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import tools.jackson.databind.ObjectMapper; @@ -83,6 +85,12 @@ public interface CommonDMIMapper { * no mappable data is found * @since 0.1.0 */ + @FragileMethod( + type = MethodType.INTERFACE_DEFAULT_METHOD, + reason = "Parsing formatted human readable dmidecode output is always error-prone and subject to change without notice", + requiresReplacement = true, + replacementNote = "Consider using --json flag of dmidecode if available" + ) default @NonNull Optional mapToEntity(@Nullable String rawDMIData, @NonNull Class mappableEntityClass) { if(rawDMIData==null) @@ -179,6 +187,12 @@ public interface CommonDMIMapper { * @return a non-null list of mapped entities * @since 0.1.0 */ + @FragileMethod( + type = MethodType.INTERFACE_DEFAULT_METHOD, + reason = "Parsing formatted human readable dmidecode output is always error-prone and subject to change without notice", + requiresReplacement = true, + replacementNote = "Consider using --json flag of dmidecode if available" + ) default @NonNull @Unmodifiable List mapToList(@Nullable String rawDMIData, @NonNull Class mappableEntityClass) { if(rawDMIData==null) diff --git a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSLanguageService.java b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSLanguageService.java index fbe2bae..4287733 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSLanguageService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSLanguageService.java @@ -5,8 +5,11 @@ */ package io.github.eggy03.dmidecode.service.board; +import io.github.eggy03.dmidecode.annotation.fragility.InvokesFragileMethod; +import io.github.eggy03.dmidecode.annotation.fragility.MethodType; import io.github.eggy03.dmidecode.constant.DMIType; import io.github.eggy03.dmidecode.entity.board.DMIBIOSLanguage; +import io.github.eggy03.dmidecode.mapper.CommonDMIMapper; import io.github.eggy03.dmidecode.mapper.board.DMIBIOSLanguageMapper; import io.github.eggy03.dmidecode.service.OptionalCommonDMIServiceInterface; import io.github.eggy03.dmidecode.utility.TerminalUtility; @@ -46,6 +49,7 @@ public class DMIBIOSLanguageService implements OptionalCommonDMIServiceInterface * @since 0.1.0 */ @Override + @InvokesFragileMethod(targetClass = CommonDMIMapper.class, methodType = MethodType.INTERFACE_DEFAULT_METHOD) public @NonNull Optional get(long timeout) { return new DMIBIOSLanguageMapper().mapToEntity( TerminalUtility.executeCommand(DMIType.getCommandFor(DMIType.BIOS_LANGUAGE), timeout), diff --git a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSService.java b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSService.java index 15d3b88..594cd09 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSService.java @@ -6,8 +6,11 @@ package io.github.eggy03.dmidecode.service.board; import io.github.eggy03.dmidecode.annotation.Unmodifiable; +import io.github.eggy03.dmidecode.annotation.fragility.InvokesFragileMethod; +import io.github.eggy03.dmidecode.annotation.fragility.MethodType; import io.github.eggy03.dmidecode.constant.DMIType; import io.github.eggy03.dmidecode.entity.board.DMIBIOS; +import io.github.eggy03.dmidecode.mapper.CommonDMIMapper; import io.github.eggy03.dmidecode.mapper.board.DMIBIOSMapper; import io.github.eggy03.dmidecode.service.CommonDMIServiceInterface; import io.github.eggy03.dmidecode.utility.TerminalUtility; @@ -47,6 +50,7 @@ public class DMIBIOSService implements CommonDMIServiceInterface { * @since 0.1.0 */ @Override + @InvokesFragileMethod(targetClass = CommonDMIMapper.class, methodType = MethodType.INTERFACE_DEFAULT_METHOD) public @NonNull @Unmodifiable List get(long timeout) { return new DMIBIOSMapper().mapToList( TerminalUtility.executeCommand(DMIType.getCommandFor(DMIType.BIOS), timeout), diff --git a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBaseboardService.java b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBaseboardService.java index 832fda6..51a3c33 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBaseboardService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBaseboardService.java @@ -5,8 +5,11 @@ */ package io.github.eggy03.dmidecode.service.board; +import io.github.eggy03.dmidecode.annotation.fragility.InvokesFragileMethod; +import io.github.eggy03.dmidecode.annotation.fragility.MethodType; import io.github.eggy03.dmidecode.constant.DMIType; import io.github.eggy03.dmidecode.entity.board.DMIBaseboard; +import io.github.eggy03.dmidecode.mapper.CommonDMIMapper; import io.github.eggy03.dmidecode.mapper.board.DMIBaseboardMapper; import io.github.eggy03.dmidecode.service.OptionalCommonDMIServiceInterface; import io.github.eggy03.dmidecode.utility.TerminalUtility; @@ -47,6 +50,7 @@ public class DMIBaseboardService implements OptionalCommonDMIServiceInterface get(long timeout) { return new DMIBaseboardMapper().mapToEntity( TerminalUtility.executeCommand(DMIType.getCommandFor(DMIType.BASEBOARD), timeout), diff --git a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIChassisService.java b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIChassisService.java index 09eca67..4f10637 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIChassisService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIChassisService.java @@ -5,8 +5,11 @@ */ package io.github.eggy03.dmidecode.service.board; +import io.github.eggy03.dmidecode.annotation.fragility.InvokesFragileMethod; +import io.github.eggy03.dmidecode.annotation.fragility.MethodType; import io.github.eggy03.dmidecode.constant.DMIType; import io.github.eggy03.dmidecode.entity.board.DMIChassis; +import io.github.eggy03.dmidecode.mapper.CommonDMIMapper; import io.github.eggy03.dmidecode.mapper.board.DMIChassisMapper; import io.github.eggy03.dmidecode.service.OptionalCommonDMIServiceInterface; import io.github.eggy03.dmidecode.utility.TerminalUtility; @@ -46,6 +49,7 @@ public class DMIChassisService implements OptionalCommonDMIServiceInterface get(long timeout) { return new DMIChassisMapper().mapToEntity( TerminalUtility.executeCommand(DMIType.getCommandFor(DMIType.CHASSIS), timeout), diff --git a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIPortConnectorInformationService.java b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIPortConnectorInformationService.java index 2884229..7e6b1f5 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIPortConnectorInformationService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIPortConnectorInformationService.java @@ -6,8 +6,11 @@ package io.github.eggy03.dmidecode.service.board; import io.github.eggy03.dmidecode.annotation.Unmodifiable; +import io.github.eggy03.dmidecode.annotation.fragility.InvokesFragileMethod; +import io.github.eggy03.dmidecode.annotation.fragility.MethodType; import io.github.eggy03.dmidecode.constant.DMIType; import io.github.eggy03.dmidecode.entity.board.DMIPortConnectorInformation; +import io.github.eggy03.dmidecode.mapper.CommonDMIMapper; import io.github.eggy03.dmidecode.mapper.board.DMIPortConnectionInformationMapper; import io.github.eggy03.dmidecode.service.CommonDMIServiceInterface; import io.github.eggy03.dmidecode.utility.TerminalUtility; @@ -48,6 +51,7 @@ public class DMIPortConnectorInformationService implements CommonDMIServiceInter * @since 0.1.0 */ @Override + @InvokesFragileMethod(targetClass = CommonDMIMapper.class, methodType = MethodType.INTERFACE_DEFAULT_METHOD) public @Unmodifiable @NonNull List get(long timeout) { return new DMIPortConnectionInformationMapper().mapToList( TerminalUtility.executeCommand(DMIType.getCommandFor(DMIType.PORT_CONNECTOR), timeout), diff --git a/src/main/java/io/github/eggy03/dmidecode/service/board/DMISystemSlotsService.java b/src/main/java/io/github/eggy03/dmidecode/service/board/DMISystemSlotsService.java index 44aa143..05e1da6 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/board/DMISystemSlotsService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/board/DMISystemSlotsService.java @@ -6,8 +6,11 @@ package io.github.eggy03.dmidecode.service.board; import io.github.eggy03.dmidecode.annotation.Unmodifiable; +import io.github.eggy03.dmidecode.annotation.fragility.InvokesFragileMethod; +import io.github.eggy03.dmidecode.annotation.fragility.MethodType; import io.github.eggy03.dmidecode.constant.DMIType; import io.github.eggy03.dmidecode.entity.board.DMISystemSlots; +import io.github.eggy03.dmidecode.mapper.CommonDMIMapper; import io.github.eggy03.dmidecode.mapper.board.DMISystemSlotsMapper; import io.github.eggy03.dmidecode.service.CommonDMIServiceInterface; import io.github.eggy03.dmidecode.utility.TerminalUtility; @@ -48,6 +51,7 @@ public class DMISystemSlotsService implements CommonDMIServiceInterface get(long timeout) { return new DMISystemSlotsMapper().mapToList( TerminalUtility.executeCommand(DMIType.getCommandFor(DMIType.SYSTEM_SLOTS), timeout), From 96bc3e3d1f3bc90b3e3fedd3c4649d167823deeb Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Wed, 1 Apr 2026 20:47:57 +0530 Subject: [PATCH 11/19] refactor: remove remaining traces of lombok - remove `lombok` dependency from `pom.xml`. - replace `@StandardException` with explicit constructors in `TerminalExecutionException.java`. - replace `@RequiredArgsConstructor` with an explicit constructor in `DMIType.java`. - replace `@UtilityClass` and `@Slf4j` with explicit implementations in `TerminalUtility.java`. - replace remaining lombok `@NonNull` annotations with Jspecify equivalent annotations. --- pom.xml | 13 ------------- .../eggy03/dmidecode/constant/DMIType.java | 5 ++--- .../exception/TerminalExecutionException.java | 18 +++++++++++++++--- .../dmidecode/utility/TerminalUtility.java | 16 ++++++++++------ 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/pom.xml b/pom.xml index 77fde3b..2ae6d49 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,6 @@ 2.12.1 - 1.18.42 3.1.1 1.0.0 6.0.0 @@ -40,7 +39,6 @@ 2.0.17 - 1.18.20.0 3.14.1 3.5.4 3.2.0 @@ -87,12 +85,6 @@ jackson-databind compile - - org.projectlombok - lombok - ${lombok.version} - provided - org.jspecify jspecify @@ -163,11 +155,6 @@ ${maven.compiler.plugin.version} - - org.projectlombok - lombok - ${lombok.version} - org.immutables value diff --git a/src/main/java/io/github/eggy03/dmidecode/constant/DMIType.java b/src/main/java/io/github/eggy03/dmidecode/constant/DMIType.java index eb1e24f..599d959 100644 --- a/src/main/java/io/github/eggy03/dmidecode/constant/DMIType.java +++ b/src/main/java/io/github/eggy03/dmidecode/constant/DMIType.java @@ -5,8 +5,6 @@ */ package io.github.eggy03.dmidecode.constant; -import lombok.RequiredArgsConstructor; - /** * Enumeration of DMI types as defined by the * {@code dmidecode} specification. @@ -23,7 +21,6 @@ * * @since 0.1.0 */ -@RequiredArgsConstructor public enum DMIType { BIOS(0), @@ -71,6 +68,8 @@ public enum DMIType { private final int value; + DMIType(int value){this.value = value;} + public static String getCommandFor(DMIType type){ return "sudo /usr/sbin/dmidecode --type " + type.value; } diff --git a/src/main/java/io/github/eggy03/dmidecode/exception/TerminalExecutionException.java b/src/main/java/io/github/eggy03/dmidecode/exception/TerminalExecutionException.java index 63b08a5..e8bee6e 100644 --- a/src/main/java/io/github/eggy03/dmidecode/exception/TerminalExecutionException.java +++ b/src/main/java/io/github/eggy03/dmidecode/exception/TerminalExecutionException.java @@ -5,13 +5,25 @@ */ package io.github.eggy03.dmidecode.exception; -import lombok.experimental.StandardException; - /** * Thrown when the terminal fails to execute a command or a script * @since 0.1.0 */ -@StandardException public class TerminalExecutionException extends RuntimeException { + @SuppressWarnings("unused") + public TerminalExecutionException(String message, Throwable cause){ + super(message, cause); + } + + @SuppressWarnings("unused") + public TerminalExecutionException(String message){ + super(message); + } + + @SuppressWarnings("unused") + public TerminalExecutionException(Throwable cause){ + super("Terminal Execution Failure", cause); + } + } diff --git a/src/main/java/io/github/eggy03/dmidecode/utility/TerminalUtility.java b/src/main/java/io/github/eggy03/dmidecode/utility/TerminalUtility.java index 7bfe63f..1777ce6 100644 --- a/src/main/java/io/github/eggy03/dmidecode/utility/TerminalUtility.java +++ b/src/main/java/io/github/eggy03/dmidecode/utility/TerminalUtility.java @@ -6,14 +6,14 @@ package io.github.eggy03.dmidecode.utility; import io.github.eggy03.dmidecode.exception.TerminalExecutionException; -import lombok.NonNull; -import lombok.experimental.UtilityClass; -import lombok.extern.slf4j.Slf4j; import org.apache.commons.exec.CommandLine; import org.apache.commons.exec.DefaultExecutor; import org.apache.commons.exec.ExecuteException; import org.apache.commons.exec.ExecuteWatchdog; import org.apache.commons.exec.PumpStreamHandler; +import org.jspecify.annotations.NonNull; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -26,10 +26,14 @@ * * @since 0.1.0 */ -@UtilityClass -@Slf4j public class TerminalUtility { + private static final Logger log = LoggerFactory.getLogger(TerminalUtility.class); + + private TerminalUtility(){ + throw new IllegalStateException("Utility Class"); + } + /** * Launches a standalone terminal session, executes the given command * and returns the result @@ -41,7 +45,7 @@ public class TerminalUtility { * or when the command yields an error, or when the terminal cannot be accessed. * @throws IllegalArgumentException If the provided timeout is in the negative */ - public static String executeCommand(@NonNull String command, long timeoutSeconds) { + public static @NonNull String executeCommand(@NonNull String command, long timeoutSeconds) { if(timeoutSeconds<0) throw new IllegalArgumentException("Timeout cannot be negative"); From 430442e4f2394afe856c9a1cb4c25fb936416921 Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Sat, 4 Apr 2026 09:02:51 +0530 Subject: [PATCH 12/19] feat(entity): restore entity pretty print - Restore the `toString()` override for all entity classes. This feature was previously removed during GSON dependency removal. --- .../eggy03/dmidecode/entity/board/AbstractDMIBIOS.java | 8 ++++++++ .../dmidecode/entity/board/AbstractDMIBIOSLanguage.java | 8 ++++++++ .../dmidecode/entity/board/AbstractDMIBaseboard.java | 8 ++++++++ .../dmidecode/entity/board/AbstractDMIChassis.java | 8 ++++++++ .../board/AbstractDMIPortConnectorInformation.java | 8 ++++++++ .../dmidecode/entity/board/AbstractDMISystemSlots.java | 9 ++++++++- .../dmidecode/entity/memory/AbstractDMIMemoryDevice.java | 8 ++++++++ .../entity/memory/AbstractDMIPhysicalMemoryArray.java | 8 ++++++++ .../entity/peripheral/AbstractDMIPortableBattery.java | 8 ++++++++ .../dmidecode/entity/processor/AbstractDMICache.java | 8 ++++++++ .../dmidecode/entity/processor/AbstractDMIProcessor.java | 8 ++++++++ .../dmidecode/entity/system/AbstractDMISystem.java | 8 ++++++++ 12 files changed, 96 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBIOS.java b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBIOS.java index c1e294b..a14054b 100644 --- a/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBIOS.java +++ b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBIOS.java @@ -10,6 +10,7 @@ import org.immutables.value.Value; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; +import tools.jackson.databind.ObjectMapper; import java.util.List; @@ -78,4 +79,11 @@ public abstract class AbstractDMIBIOS { @JsonProperty("Firmware Revision") @Nullable public abstract String firmwareRevision(); + + @Override + public String toString() { + return new ObjectMapper() + .writerWithDefaultPrettyPrinter() + .writeValueAsString(this); + } } diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBIOSLanguage.java b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBIOSLanguage.java index c8eac69..5334f95 100644 --- a/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBIOSLanguage.java +++ b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBIOSLanguage.java @@ -10,6 +10,7 @@ import org.immutables.value.Value; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; +import tools.jackson.databind.ObjectMapper; import java.util.List; @@ -49,4 +50,11 @@ public abstract class AbstractDMIBIOSLanguage { @JsonProperty("Currently Installed Language") @Nullable public abstract String currentLanguage(); + + @Override + public String toString() { + return new ObjectMapper() + .writerWithDefaultPrettyPrinter() + .writeValueAsString(this); + } } diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBaseboard.java b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBaseboard.java index beec919..57aa925 100644 --- a/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBaseboard.java +++ b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBaseboard.java @@ -10,6 +10,7 @@ import org.immutables.value.Value; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; +import tools.jackson.databind.ObjectMapper; import java.util.List; @@ -83,4 +84,11 @@ public abstract class AbstractDMIBaseboard { @JsonProperty("Contained Object Handles") @Nullable public abstract Integer containedObjectHandles(); + + @Override + public String toString() { + return new ObjectMapper() + .writerWithDefaultPrettyPrinter() + .writeValueAsString(this); + } } diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIChassis.java b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIChassis.java index 48cfc1e..18c1045 100644 --- a/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIChassis.java +++ b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIChassis.java @@ -10,6 +10,7 @@ import org.immutables.value.Value; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; +import tools.jackson.databind.ObjectMapper; /** * Immutable representation of system chassis information retrieved via DMI. @@ -101,4 +102,11 @@ public abstract class AbstractDMIChassis { @Nullable public abstract String skuNumber(); + @Override + public String toString() { + return new ObjectMapper() + .writerWithDefaultPrettyPrinter() + .writeValueAsString(this); + } + } diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIPortConnectorInformation.java b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIPortConnectorInformation.java index 27f1df2..9515e2c 100644 --- a/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIPortConnectorInformation.java +++ b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIPortConnectorInformation.java @@ -10,6 +10,7 @@ import org.immutables.value.Value; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; +import tools.jackson.databind.ObjectMapper; /** * Immutable representation of port connector information retrieved via DMI. @@ -61,4 +62,11 @@ public abstract class AbstractDMIPortConnectorInformation { @Nullable public abstract String portType(); + @Override + public String toString() { + return new ObjectMapper() + .writerWithDefaultPrettyPrinter() + .writeValueAsString(this); + } + } diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMISystemSlots.java b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMISystemSlots.java index bd2c922..6b56509 100644 --- a/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMISystemSlots.java +++ b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMISystemSlots.java @@ -10,6 +10,7 @@ import org.immutables.value.Value; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; +import tools.jackson.databind.ObjectMapper; import java.util.List; @@ -71,5 +72,11 @@ public abstract class AbstractDMISystemSlots { @JsonProperty("Bus Address") @Nullable public abstract String busAddress(); - + + @Override + public String toString() { + return new ObjectMapper() + .writerWithDefaultPrettyPrinter() + .writeValueAsString(this); + } } diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/memory/AbstractDMIMemoryDevice.java b/src/main/java/io/github/eggy03/dmidecode/entity/memory/AbstractDMIMemoryDevice.java index 099b975..f9fb19a 100644 --- a/src/main/java/io/github/eggy03/dmidecode/entity/memory/AbstractDMIMemoryDevice.java +++ b/src/main/java/io/github/eggy03/dmidecode/entity/memory/AbstractDMIMemoryDevice.java @@ -10,6 +10,7 @@ import org.immutables.value.Value; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; +import tools.jackson.databind.ObjectMapper; /** * Immutable representation of memory device information retrieved via DMI. @@ -170,4 +171,11 @@ public abstract class AbstractDMIMemoryDevice { @JsonProperty("Logical Size") @Nullable public abstract String logicalSize(); + + @Override + public String toString() { + return new ObjectMapper() + .writerWithDefaultPrettyPrinter() + .writeValueAsString(this); + } } diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/memory/AbstractDMIPhysicalMemoryArray.java b/src/main/java/io/github/eggy03/dmidecode/entity/memory/AbstractDMIPhysicalMemoryArray.java index 83fe69d..ecd6342 100644 --- a/src/main/java/io/github/eggy03/dmidecode/entity/memory/AbstractDMIPhysicalMemoryArray.java +++ b/src/main/java/io/github/eggy03/dmidecode/entity/memory/AbstractDMIPhysicalMemoryArray.java @@ -10,6 +10,7 @@ import org.immutables.value.Value; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; +import tools.jackson.databind.ObjectMapper; /** * Immutable representation of physical memory array information retrieved via DMI. @@ -65,4 +66,11 @@ public abstract class AbstractDMIPhysicalMemoryArray { @JsonProperty("Number Of Devices") @Nullable public abstract Integer numberOfDevices(); + + @Override + public String toString() { + return new ObjectMapper() + .writerWithDefaultPrettyPrinter() + .writeValueAsString(this); + } } diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/peripheral/AbstractDMIPortableBattery.java b/src/main/java/io/github/eggy03/dmidecode/entity/peripheral/AbstractDMIPortableBattery.java index 06c641a..9ac1895 100644 --- a/src/main/java/io/github/eggy03/dmidecode/entity/peripheral/AbstractDMIPortableBattery.java +++ b/src/main/java/io/github/eggy03/dmidecode/entity/peripheral/AbstractDMIPortableBattery.java @@ -10,6 +10,7 @@ import org.immutables.value.Value; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; +import tools.jackson.databind.ObjectMapper; /** * Immutable representation of portable battery information retrieved via DMI. @@ -85,4 +86,11 @@ public abstract class AbstractDMIPortableBattery { @JsonProperty("OEM-specific Information") @Nullable public abstract String oemSpecificInformation(); + + @Override + public String toString() { + return new ObjectMapper() + .writerWithDefaultPrettyPrinter() + .writeValueAsString(this); + } } diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/processor/AbstractDMICache.java b/src/main/java/io/github/eggy03/dmidecode/entity/processor/AbstractDMICache.java index 73124cc..2087f86 100644 --- a/src/main/java/io/github/eggy03/dmidecode/entity/processor/AbstractDMICache.java +++ b/src/main/java/io/github/eggy03/dmidecode/entity/processor/AbstractDMICache.java @@ -10,6 +10,7 @@ import org.immutables.value.Value; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; +import tools.jackson.databind.ObjectMapper; import java.util.List; @@ -91,4 +92,11 @@ public abstract class AbstractDMICache { @JsonProperty("Associativity") @Nullable public abstract String associativity(); + + @Override + public String toString() { + return new ObjectMapper() + .writerWithDefaultPrettyPrinter() + .writeValueAsString(this); + } } diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/processor/AbstractDMIProcessor.java b/src/main/java/io/github/eggy03/dmidecode/entity/processor/AbstractDMIProcessor.java index 6e5b7db..0f12107 100644 --- a/src/main/java/io/github/eggy03/dmidecode/entity/processor/AbstractDMIProcessor.java +++ b/src/main/java/io/github/eggy03/dmidecode/entity/processor/AbstractDMIProcessor.java @@ -10,6 +10,7 @@ import org.immutables.value.Value; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; +import tools.jackson.databind.ObjectMapper; import java.util.List; @@ -141,4 +142,11 @@ public abstract class AbstractDMIProcessor { @JsonProperty("Characteristics") @Nullable public abstract List<@Nullable String> characteristics(); + + @Override + public String toString() { + return new ObjectMapper() + .writerWithDefaultPrettyPrinter() + .writeValueAsString(this); + } } diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/system/AbstractDMISystem.java b/src/main/java/io/github/eggy03/dmidecode/entity/system/AbstractDMISystem.java index 455df70..d18fe80 100644 --- a/src/main/java/io/github/eggy03/dmidecode/entity/system/AbstractDMISystem.java +++ b/src/main/java/io/github/eggy03/dmidecode/entity/system/AbstractDMISystem.java @@ -10,6 +10,7 @@ import org.immutables.value.Value; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; +import tools.jackson.databind.ObjectMapper; /** * Immutable representation of system information retrieved via DMI. @@ -73,4 +74,11 @@ public abstract class AbstractDMISystem { @JsonProperty("Family") @Nullable public abstract String family(); + + @Override + public String toString() { + return new ObjectMapper() + .writerWithDefaultPrettyPrinter() + .writeValueAsString(this); + } } From af940478a171c025f070e5023ec04ab45b7769ee Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Sat, 4 Apr 2026 10:37:46 +0530 Subject: [PATCH 13/19] refactor(annotations): rename `ImmutableStyle` - `ImmutableStyle` has been renamed to `ImmutableEntityStyle` and updated references. - Added documentation to `ImmutableEntityStyle`. --- ...mutableStyle.java => ImmutableEntityStyle.java} | 14 +++++++++++++- .../dmidecode/entity/board/AbstractDMIBIOS.java | 4 ++-- .../entity/board/AbstractDMIBIOSLanguage.java | 4 ++-- .../entity/board/AbstractDMIBaseboard.java | 4 ++-- .../dmidecode/entity/board/AbstractDMIChassis.java | 4 ++-- .../board/AbstractDMIPortConnectorInformation.java | 4 ++-- .../entity/board/AbstractDMISystemSlots.java | 4 ++-- .../entity/memory/AbstractDMIMemoryDevice.java | 4 ++-- .../memory/AbstractDMIPhysicalMemoryArray.java | 4 ++-- .../peripheral/AbstractDMIPortableBattery.java | 4 ++-- .../entity/processor/AbstractDMICache.java | 4 ++-- .../entity/processor/AbstractDMIProcessor.java | 4 ++-- .../dmidecode/entity/system/AbstractDMISystem.java | 4 ++-- 13 files changed, 37 insertions(+), 25 deletions(-) rename src/main/java/io/github/eggy03/dmidecode/annotation/{ImmutableStyle.java => ImmutableEntityStyle.java} (70%) diff --git a/src/main/java/io/github/eggy03/dmidecode/annotation/ImmutableStyle.java b/src/main/java/io/github/eggy03/dmidecode/annotation/ImmutableEntityStyle.java similarity index 70% rename from src/main/java/io/github/eggy03/dmidecode/annotation/ImmutableStyle.java rename to src/main/java/io/github/eggy03/dmidecode/annotation/ImmutableEntityStyle.java index 47e9441..afb3b4b 100644 --- a/src/main/java/io/github/eggy03/dmidecode/annotation/ImmutableStyle.java +++ b/src/main/java/io/github/eggy03/dmidecode/annotation/ImmutableEntityStyle.java @@ -8,6 +8,18 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +/** + *

    + * A custom annotation that is intended to be applied with {@link Value.Immutable}, + * on {@link io.github.eggy03.dmidecode.entity} package classes. + *

    + *

    + * It modifies the naming and structural style of the generated immutable implementations via {@link Value.Style} + * and contains {@link JsonSerialize} for automatic Jackson integration. + *

    + * + * @since 0.2.0 + */ @Target({ElementType.PACKAGE, ElementType.TYPE}) @Retention(RetentionPolicy.CLASS) // Make it class retention for incremental compilation @JsonSerialize // Jackson automatic integration @@ -19,4 +31,4 @@ // Generated builders will have attributes annotated with @JsonProperty so deserialization will work properly. defaults = @Value.Immutable(copy = true) // Enable copy methods ) -public @interface ImmutableStyle {} +public @interface ImmutableEntityStyle {} diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBIOS.java b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBIOS.java index a14054b..62de8f7 100644 --- a/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBIOS.java +++ b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBIOS.java @@ -6,7 +6,7 @@ package io.github.eggy03.dmidecode.entity.board; import com.fasterxml.jackson.annotation.JsonProperty; -import io.github.eggy03.dmidecode.annotation.ImmutableStyle; +import io.github.eggy03.dmidecode.annotation.ImmutableEntityStyle; import org.immutables.value.Value; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; @@ -40,7 +40,7 @@ * @since 0.2.0 */ @Value.Immutable -@ImmutableStyle +@ImmutableEntityStyle @NullMarked public abstract class AbstractDMIBIOS { diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBIOSLanguage.java b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBIOSLanguage.java index 5334f95..ba3cdb1 100644 --- a/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBIOSLanguage.java +++ b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBIOSLanguage.java @@ -6,7 +6,7 @@ package io.github.eggy03.dmidecode.entity.board; import com.fasterxml.jackson.annotation.JsonProperty; -import io.github.eggy03.dmidecode.annotation.ImmutableStyle; +import io.github.eggy03.dmidecode.annotation.ImmutableEntityStyle; import org.immutables.value.Value; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; @@ -39,7 +39,7 @@ * @since 0.2.0 */ @Value.Immutable -@ImmutableStyle +@ImmutableEntityStyle @NullMarked public abstract class AbstractDMIBIOSLanguage { diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBaseboard.java b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBaseboard.java index 57aa925..72adbed 100644 --- a/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBaseboard.java +++ b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBaseboard.java @@ -6,7 +6,7 @@ package io.github.eggy03.dmidecode.entity.board; import com.fasterxml.jackson.annotation.JsonProperty; -import io.github.eggy03.dmidecode.annotation.ImmutableStyle; +import io.github.eggy03.dmidecode.annotation.ImmutableEntityStyle; import org.immutables.value.Value; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; @@ -41,7 +41,7 @@ * @since 0.2.0 */ @Value.Immutable -@ImmutableStyle +@ImmutableEntityStyle @NullMarked public abstract class AbstractDMIBaseboard { diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIChassis.java b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIChassis.java index 18c1045..a36fce1 100644 --- a/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIChassis.java +++ b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIChassis.java @@ -6,7 +6,7 @@ package io.github.eggy03.dmidecode.entity.board; import com.fasterxml.jackson.annotation.JsonProperty; -import io.github.eggy03.dmidecode.annotation.ImmutableStyle; +import io.github.eggy03.dmidecode.annotation.ImmutableEntityStyle; import org.immutables.value.Value; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; @@ -38,7 +38,7 @@ * @since 0.2.0 */ @Value.Immutable -@ImmutableStyle +@ImmutableEntityStyle @NullMarked public abstract class AbstractDMIChassis { diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIPortConnectorInformation.java b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIPortConnectorInformation.java index 9515e2c..cfeaa3e 100644 --- a/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIPortConnectorInformation.java +++ b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIPortConnectorInformation.java @@ -6,7 +6,7 @@ package io.github.eggy03.dmidecode.entity.board; import com.fasterxml.jackson.annotation.JsonProperty; -import io.github.eggy03.dmidecode.annotation.ImmutableStyle; +import io.github.eggy03.dmidecode.annotation.ImmutableEntityStyle; import org.immutables.value.Value; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; @@ -38,7 +38,7 @@ * @since 0.2.0 */ @Value.Immutable -@ImmutableStyle +@ImmutableEntityStyle @NullMarked public abstract class AbstractDMIPortConnectorInformation { diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMISystemSlots.java b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMISystemSlots.java index 6b56509..956f169 100644 --- a/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMISystemSlots.java +++ b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMISystemSlots.java @@ -6,7 +6,7 @@ package io.github.eggy03.dmidecode.entity.board; import com.fasterxml.jackson.annotation.JsonProperty; -import io.github.eggy03.dmidecode.annotation.ImmutableStyle; +import io.github.eggy03.dmidecode.annotation.ImmutableEntityStyle; import org.immutables.value.Value; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; @@ -41,7 +41,7 @@ * @since 0.2.0 */ @Value.Immutable -@ImmutableStyle +@ImmutableEntityStyle @NullMarked public abstract class AbstractDMISystemSlots { diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/memory/AbstractDMIMemoryDevice.java b/src/main/java/io/github/eggy03/dmidecode/entity/memory/AbstractDMIMemoryDevice.java index f9fb19a..b448655 100644 --- a/src/main/java/io/github/eggy03/dmidecode/entity/memory/AbstractDMIMemoryDevice.java +++ b/src/main/java/io/github/eggy03/dmidecode/entity/memory/AbstractDMIMemoryDevice.java @@ -6,7 +6,7 @@ package io.github.eggy03.dmidecode.entity.memory; import com.fasterxml.jackson.annotation.JsonProperty; -import io.github.eggy03.dmidecode.annotation.ImmutableStyle; +import io.github.eggy03.dmidecode.annotation.ImmutableEntityStyle; import org.immutables.value.Value; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; @@ -40,7 +40,7 @@ * @since 0.2.0 */ @Value.Immutable -@ImmutableStyle +@ImmutableEntityStyle @NullMarked public abstract class AbstractDMIMemoryDevice { diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/memory/AbstractDMIPhysicalMemoryArray.java b/src/main/java/io/github/eggy03/dmidecode/entity/memory/AbstractDMIPhysicalMemoryArray.java index ecd6342..a6b2204 100644 --- a/src/main/java/io/github/eggy03/dmidecode/entity/memory/AbstractDMIPhysicalMemoryArray.java +++ b/src/main/java/io/github/eggy03/dmidecode/entity/memory/AbstractDMIPhysicalMemoryArray.java @@ -6,7 +6,7 @@ package io.github.eggy03.dmidecode.entity.memory; import com.fasterxml.jackson.annotation.JsonProperty; -import io.github.eggy03.dmidecode.annotation.ImmutableStyle; +import io.github.eggy03.dmidecode.annotation.ImmutableEntityStyle; import org.immutables.value.Value; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; @@ -39,7 +39,7 @@ * @since 0.2.0 */ @Value.Immutable -@ImmutableStyle +@ImmutableEntityStyle @NullMarked public abstract class AbstractDMIPhysicalMemoryArray { diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/peripheral/AbstractDMIPortableBattery.java b/src/main/java/io/github/eggy03/dmidecode/entity/peripheral/AbstractDMIPortableBattery.java index 9ac1895..1bca010 100644 --- a/src/main/java/io/github/eggy03/dmidecode/entity/peripheral/AbstractDMIPortableBattery.java +++ b/src/main/java/io/github/eggy03/dmidecode/entity/peripheral/AbstractDMIPortableBattery.java @@ -6,7 +6,7 @@ package io.github.eggy03.dmidecode.entity.peripheral; import com.fasterxml.jackson.annotation.JsonProperty; -import io.github.eggy03.dmidecode.annotation.ImmutableStyle; +import io.github.eggy03.dmidecode.annotation.ImmutableEntityStyle; import org.immutables.value.Value; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; @@ -39,7 +39,7 @@ * @since 0.2.0 */ @Value.Immutable -@ImmutableStyle +@ImmutableEntityStyle @NullMarked public abstract class AbstractDMIPortableBattery { diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/processor/AbstractDMICache.java b/src/main/java/io/github/eggy03/dmidecode/entity/processor/AbstractDMICache.java index 2087f86..c50f1f5 100644 --- a/src/main/java/io/github/eggy03/dmidecode/entity/processor/AbstractDMICache.java +++ b/src/main/java/io/github/eggy03/dmidecode/entity/processor/AbstractDMICache.java @@ -6,7 +6,7 @@ package io.github.eggy03.dmidecode.entity.processor; import com.fasterxml.jackson.annotation.JsonProperty; -import io.github.eggy03.dmidecode.annotation.ImmutableStyle; +import io.github.eggy03.dmidecode.annotation.ImmutableEntityStyle; import org.immutables.value.Value; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; @@ -41,7 +41,7 @@ * @since 0.2.0 */ @Value.Immutable -@ImmutableStyle +@ImmutableEntityStyle @NullMarked public abstract class AbstractDMICache { diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/processor/AbstractDMIProcessor.java b/src/main/java/io/github/eggy03/dmidecode/entity/processor/AbstractDMIProcessor.java index 0f12107..c5e3ee6 100644 --- a/src/main/java/io/github/eggy03/dmidecode/entity/processor/AbstractDMIProcessor.java +++ b/src/main/java/io/github/eggy03/dmidecode/entity/processor/AbstractDMIProcessor.java @@ -6,7 +6,7 @@ package io.github.eggy03.dmidecode.entity.processor; import com.fasterxml.jackson.annotation.JsonProperty; -import io.github.eggy03.dmidecode.annotation.ImmutableStyle; +import io.github.eggy03.dmidecode.annotation.ImmutableEntityStyle; import org.immutables.value.Value; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; @@ -43,7 +43,7 @@ * @since 0.2.0 */ @Value.Immutable -@ImmutableStyle +@ImmutableEntityStyle @NullMarked public abstract class AbstractDMIProcessor { diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/system/AbstractDMISystem.java b/src/main/java/io/github/eggy03/dmidecode/entity/system/AbstractDMISystem.java index d18fe80..047a54f 100644 --- a/src/main/java/io/github/eggy03/dmidecode/entity/system/AbstractDMISystem.java +++ b/src/main/java/io/github/eggy03/dmidecode/entity/system/AbstractDMISystem.java @@ -6,7 +6,7 @@ package io.github.eggy03.dmidecode.entity.system; import com.fasterxml.jackson.annotation.JsonProperty; -import io.github.eggy03.dmidecode.annotation.ImmutableStyle; +import io.github.eggy03.dmidecode.annotation.ImmutableEntityStyle; import org.immutables.value.Value; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; @@ -39,7 +39,7 @@ * @since 0.2.0 */ @Value.Immutable -@ImmutableStyle +@ImmutableEntityStyle @NullMarked public abstract class AbstractDMISystem { From b271b6faf738b78a6db6dae9f2d4cf0db88c1b9c Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Sat, 4 Apr 2026 11:25:28 +0530 Subject: [PATCH 14/19] build: update plugins and license url - Update `maven-compiler-plugin` from `3.14.1` to `3.15.0` - Update `maven-surefire-plugin` from `3.5.4` to `3.5.5` - Update `central-publishing-maven-plugin` from `0.9.0` to `0.10.0` - Correct `project.license.url` branch from `main` to `master` --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 2ae6d49..f7d3a46 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,7 @@ https://github.com/eggy03/dmidecode4j The MIT License - https://raw.githubusercontent.com/eggy03/dmidecode4j/refs/heads/main/LICENSE + https://raw.githubusercontent.com/eggy03/dmidecode4j/refs/heads/master/LICENSE Egg-03 Sayan Bhattacharjee @@ -39,13 +39,13 @@ 2.0.17 - 3.14.1 - 3.5.4 + 3.15.0 + 3.5.5 3.2.0 3.6.1 3.12.0 1.1.0 - 0.9.0 + 0.10.0 0.8.14 3.4.0 From bd21663a39dffad891e121682aeef01b1fe9dd68 Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Sat, 4 Apr 2026 11:28:06 +0530 Subject: [PATCH 15/19] style: apply intellij style fixes - standardize javadoc paragraph indentation - adjust whitespace around method signatures and conditional statements - add missing newlines in annotation and enum definitions - reorder javadoc tags Signed-off-by: Egg-03 <111327101+eggy03@users.noreply.github.com> --- .../annotation/ImmutableEntityStyle.java | 11 ++++++----- .../dmidecode/annotation/Unmodifiable.java | 10 +++++----- .../annotation/fragility/FragileMethod.java | 16 ++++++++-------- .../fragility/InvokesFragileMethod.java | 8 ++++---- .../annotation/fragility/MethodType.java | 2 +- .../eggy03/dmidecode/constant/DMIType.java | 8 +++++--- .../entity/system/AbstractDMISystem.java | 2 +- .../exception/TerminalExecutionException.java | 7 ++++--- .../dmidecode/mapper/CommonDMIMapper.java | 19 ++++++++++--------- .../service/CommonDMIServiceInterface.java | 4 +--- .../OptionalCommonDMIServiceInterface.java | 8 +++----- .../service/board/DMIBIOSLanguageService.java | 3 +-- .../service/board/DMIBIOSService.java | 3 +-- .../service/board/DMIBaseboardService.java | 3 +-- .../service/board/DMIChassisService.java | 3 +-- .../DMIPortConnectorInformationService.java | 5 ++--- .../service/board/DMISystemSlotsService.java | 5 ++--- .../memory/DMIMemoryDeviceService.java | 5 ++--- .../memory/DMIPhysicalMemoryArrayService.java | 5 ++--- .../peripheral/DMIPortableBatteryService.java | 5 ++--- .../service/processor/DMICacheService.java | 5 ++--- .../processor/DMIProcessorService.java | 3 +-- .../service/system/DMISystemService.java | 5 ++--- .../dmidecode/utility/TerminalUtility.java | 12 ++++++------ 24 files changed, 73 insertions(+), 84 deletions(-) diff --git a/src/main/java/io/github/eggy03/dmidecode/annotation/ImmutableEntityStyle.java b/src/main/java/io/github/eggy03/dmidecode/annotation/ImmutableEntityStyle.java index afb3b4b..8441871 100644 --- a/src/main/java/io/github/eggy03/dmidecode/annotation/ImmutableEntityStyle.java +++ b/src/main/java/io/github/eggy03/dmidecode/annotation/ImmutableEntityStyle.java @@ -10,12 +10,12 @@ /** *

    - * A custom annotation that is intended to be applied with {@link Value.Immutable}, - * on {@link io.github.eggy03.dmidecode.entity} package classes. + * A custom annotation that is intended to be applied with {@link Value.Immutable}, + * on {@link io.github.eggy03.dmidecode.entity} package classes. *

    *

    - * It modifies the naming and structural style of the generated immutable implementations via {@link Value.Style} - * and contains {@link JsonSerialize} for automatic Jackson integration. + * It modifies the naming and structural style of the generated immutable implementations via {@link Value.Style} + * and contains {@link JsonSerialize} for automatic Jackson integration. *

    * * @since 0.2.0 @@ -31,4 +31,5 @@ // Generated builders will have attributes annotated with @JsonProperty so deserialization will work properly. defaults = @Value.Immutable(copy = true) // Enable copy methods ) -public @interface ImmutableEntityStyle {} +public @interface ImmutableEntityStyle { +} diff --git a/src/main/java/io/github/eggy03/dmidecode/annotation/Unmodifiable.java b/src/main/java/io/github/eggy03/dmidecode/annotation/Unmodifiable.java index e4f11c8..6ffe3d2 100644 --- a/src/main/java/io/github/eggy03/dmidecode/annotation/Unmodifiable.java +++ b/src/main/java/io/github/eggy03/dmidecode/annotation/Unmodifiable.java @@ -8,13 +8,13 @@ /** *

    - * Indicates that the underlying `Collection` or `Map` is unmodifiable. - * Any attempts to mutate such a collection or map may result in exceptions being - * thrown, or no result at all. + * Indicates that the underlying `Collection` or `Map` is unmodifiable. + * Any attempts to mutate such a collection or map may result in exceptions being + * thrown, or no result at all. *

    *

    - * The referenced objects within the collection or map may still be mutable, depending on - * their implementation. + * The referenced objects within the collection or map may still be mutable, depending on + * their implementation. *

    * * @since 0.2.0 diff --git a/src/main/java/io/github/eggy03/dmidecode/annotation/fragility/FragileMethod.java b/src/main/java/io/github/eggy03/dmidecode/annotation/fragility/FragileMethod.java index ddef574..8c2d8ae 100644 --- a/src/main/java/io/github/eggy03/dmidecode/annotation/fragility/FragileMethod.java +++ b/src/main/java/io/github/eggy03/dmidecode/annotation/fragility/FragileMethod.java @@ -8,21 +8,21 @@ /** *

    - * When marked on a method (or a constructor), it serves as an indication that - * the method's behavior depends on unstable and or environment-specific logic - * and may break without notice. + * When marked on a method (or a constructor), it serves as an indication that + * the method's behavior depends on unstable and or environment-specific logic + * and may break without notice. *

    *

    - * A method annotated with {@code @FragileMethod} should not be used in production. - * However, if usage in production is unavoidable, any method or constructor that - * invokes a fragile method in its definition should be annotated with {@code @InvokesFragileMethod}. + * A method annotated with {@code @FragileMethod} should not be used in production. + * However, if usage in production is unavoidable, any method or constructor that + * invokes a fragile method in its definition should be annotated with {@code @InvokesFragileMethod}. *

    *

    - * This annotation is for documentation purposes only. + * This annotation is for documentation purposes only. *

    * - * @since 0.2.0 * @see InvokesFragileMethod + * @since 0.2.0 */ @Documented @Retention(RetentionPolicy.RUNTIME) diff --git a/src/main/java/io/github/eggy03/dmidecode/annotation/fragility/InvokesFragileMethod.java b/src/main/java/io/github/eggy03/dmidecode/annotation/fragility/InvokesFragileMethod.java index d50a333..b8ff484 100644 --- a/src/main/java/io/github/eggy03/dmidecode/annotation/fragility/InvokesFragileMethod.java +++ b/src/main/java/io/github/eggy03/dmidecode/annotation/fragility/InvokesFragileMethod.java @@ -9,15 +9,15 @@ /** *

    - * When marked on a method (or a constructor), it indicates that annotated method or constructor - * has a definition that invokes a method or a constructor annotated with {@code FragileMethod} + * When marked on a method (or a constructor), it indicates that annotated method or constructor + * has a definition that invokes a method or a constructor annotated with {@code FragileMethod} *

    *

    - * This annotation is for documentation purposes only. + * This annotation is for documentation purposes only. *

    * - * @since 0.2.0 * @see FragileMethod + * @since 0.2.0 */ @Documented @Retention(RetentionPolicy.RUNTIME) diff --git a/src/main/java/io/github/eggy03/dmidecode/annotation/fragility/MethodType.java b/src/main/java/io/github/eggy03/dmidecode/annotation/fragility/MethodType.java index 1dc4181..08a227a 100644 --- a/src/main/java/io/github/eggy03/dmidecode/annotation/fragility/MethodType.java +++ b/src/main/java/io/github/eggy03/dmidecode/annotation/fragility/MethodType.java @@ -3,9 +3,9 @@ /** * Enum to classify the type of method that is marked as fragile * - * @since 0.2.0 * @see FragileMethod * @see InvokesFragileMethod + * @since 0.2.0 */ public enum MethodType { diff --git a/src/main/java/io/github/eggy03/dmidecode/constant/DMIType.java b/src/main/java/io/github/eggy03/dmidecode/constant/DMIType.java index 599d959..64dc320 100644 --- a/src/main/java/io/github/eggy03/dmidecode/constant/DMIType.java +++ b/src/main/java/io/github/eggy03/dmidecode/constant/DMIType.java @@ -65,12 +65,14 @@ public enum DMIType { POWER_SUPPLY(39), ADDITIONAL_INFORMATION(40), ONBOARD_DEVICE(41); - + private final int value; - DMIType(int value){this.value = value;} + DMIType(int value) { + this.value = value; + } - public static String getCommandFor(DMIType type){ + public static String getCommandFor(DMIType type) { return "sudo /usr/sbin/dmidecode --type " + type.value; } } \ No newline at end of file diff --git a/src/main/java/io/github/eggy03/dmidecode/entity/system/AbstractDMISystem.java b/src/main/java/io/github/eggy03/dmidecode/entity/system/AbstractDMISystem.java index 047a54f..91081e8 100644 --- a/src/main/java/io/github/eggy03/dmidecode/entity/system/AbstractDMISystem.java +++ b/src/main/java/io/github/eggy03/dmidecode/entity/system/AbstractDMISystem.java @@ -42,7 +42,7 @@ @ImmutableEntityStyle @NullMarked public abstract class AbstractDMISystem { - + @JsonProperty("Manufacturer") @Nullable public abstract String manufacturer(); diff --git a/src/main/java/io/github/eggy03/dmidecode/exception/TerminalExecutionException.java b/src/main/java/io/github/eggy03/dmidecode/exception/TerminalExecutionException.java index e8bee6e..3a7597f 100644 --- a/src/main/java/io/github/eggy03/dmidecode/exception/TerminalExecutionException.java +++ b/src/main/java/io/github/eggy03/dmidecode/exception/TerminalExecutionException.java @@ -7,22 +7,23 @@ /** * Thrown when the terminal fails to execute a command or a script + * * @since 0.1.0 */ public class TerminalExecutionException extends RuntimeException { @SuppressWarnings("unused") - public TerminalExecutionException(String message, Throwable cause){ + public TerminalExecutionException(String message, Throwable cause) { super(message, cause); } @SuppressWarnings("unused") - public TerminalExecutionException(String message){ + public TerminalExecutionException(String message) { super(message); } @SuppressWarnings("unused") - public TerminalExecutionException(Throwable cause){ + public TerminalExecutionException(Throwable cause) { super("Terminal Execution Failure", cause); } diff --git a/src/main/java/io/github/eggy03/dmidecode/mapper/CommonDMIMapper.java b/src/main/java/io/github/eggy03/dmidecode/mapper/CommonDMIMapper.java index 79f3054..94e0b2e 100644 --- a/src/main/java/io/github/eggy03/dmidecode/mapper/CommonDMIMapper.java +++ b/src/main/java/io/github/eggy03/dmidecode/mapper/CommonDMIMapper.java @@ -79,10 +79,11 @@ public interface CommonDMIMapper { * 64-bit capable * Multi-Core * - * @param rawDMIData the raw {@code dmidecode} output + * + * @param rawDMIData the raw {@code dmidecode} output * @param mappableEntityClass the target entity class * @return an {@link Optional} containing the mapped entity, or empty if - * no mappable data is found + * no mappable data is found * @since 0.1.0 */ @FragileMethod( @@ -93,7 +94,7 @@ public interface CommonDMIMapper { ) default @NonNull Optional mapToEntity(@Nullable String rawDMIData, @NonNull Class mappableEntityClass) { - if(rawDMIData==null) + if (rawDMIData == null) return Optional.empty(); Map keyValueMap = new LinkedHashMap<>(); @@ -107,7 +108,7 @@ public interface CommonDMIMapper { if (currentLine.contains(":")) { // store the previous key and value if present, indicated by a key of length greater than 0 - if (key!=null && !key.isEmpty()) { + if (key != null && !key.isEmpty()) { // if the value has multi lines, insert them or else insert the single line value keyValueMap.put(key, !multiLineValues.isEmpty() ? new ArrayList<>(multiLineValues) : singleLineValue); } @@ -132,7 +133,7 @@ public interface CommonDMIMapper { } } // Store the last key/value pair - if (key!=null && !key.isEmpty()) { + if (key != null && !key.isEmpty()) { keyValueMap.put(key, !multiLineValues.isEmpty() ? new ArrayList<>(multiLineValues) : singleLineValue); } @@ -182,7 +183,7 @@ public interface CommonDMIMapper { * Associativity: 16-way Set-associative * * - * @param rawDMIData the raw {@code dmidecode} output + * @param rawDMIData the raw {@code dmidecode} output * @param mappableEntityClass the target entity class * @return a non-null list of mapped entities * @since 0.1.0 @@ -195,7 +196,7 @@ public interface CommonDMIMapper { ) default @NonNull @Unmodifiable List mapToList(@Nullable String rawDMIData, @NonNull Class mappableEntityClass) { - if(rawDMIData==null) + if (rawDMIData == null) return Collections.emptyList(); List entityList = new ArrayList<>(); @@ -214,7 +215,7 @@ public interface CommonDMIMapper { if (currentLine.contains(":")) { // store the previous key and value if present, indicated by a key of length greater than 0 - if (key!=null && !key.isEmpty()) { + if (key != null && !key.isEmpty()) { // if the value has multi lines, insert them or else insert the single line value keyValueMap.put(key, !multiLineValues.isEmpty() ? new ArrayList<>(multiLineValues) : singleLineValue); } @@ -239,7 +240,7 @@ public interface CommonDMIMapper { } } // Store the last key/value pair in this DMI block - if (key!=null && !key.isEmpty()) { + if (key != null && !key.isEmpty()) { keyValueMap.put(key, !multiLineValues.isEmpty() ? new ArrayList<>(multiLineValues) : singleLineValue); } diff --git a/src/main/java/io/github/eggy03/dmidecode/service/CommonDMIServiceInterface.java b/src/main/java/io/github/eggy03/dmidecode/service/CommonDMIServiceInterface.java index 5397e7e..7c02c33 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/CommonDMIServiceInterface.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/CommonDMIServiceInterface.java @@ -17,9 +17,8 @@ *

    * * @param the entity type returned by the service implementation - * - * @since 0.1.0 * @see OptionalCommonDMIServiceInterface + * @since 0.1.0 */ public interface CommonDMIServiceInterface { @@ -31,7 +30,6 @@ public interface CommonDMIServiceInterface { * {@code dmidecode} command to complete before * terminating the process * @return a {@link List} of entities of type {@code } defined by the caller - * * @since 0.1.0 */ List get(long timeout); diff --git a/src/main/java/io/github/eggy03/dmidecode/service/OptionalCommonDMIServiceInterface.java b/src/main/java/io/github/eggy03/dmidecode/service/OptionalCommonDMIServiceInterface.java index ab3cb9f..fd68207 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/OptionalCommonDMIServiceInterface.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/OptionalCommonDMIServiceInterface.java @@ -17,9 +17,8 @@ *

    * * @param the entity type returned by the service implementation - * - * @since 0.1.0 * @see CommonDMIServiceInterface + * @since 0.1.0 */ public interface OptionalCommonDMIServiceInterface { @@ -32,9 +31,8 @@ public interface OptionalCommonDMIServiceInterface { * {@code dmidecode} command to complete before * terminating the process * @return an {@link Optional} containing the entity of type {@code } - * if present, or {@link Optional#empty()} if the information - * is unavailable or not reported by the system - * + * if present, or {@link Optional#empty()} if the information + * is unavailable or not reported by the system * @since 0.1.0 */ Optional get(long timeout); diff --git a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSLanguageService.java b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSLanguageService.java index 4287733..9aa263e 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSLanguageService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSLanguageService.java @@ -44,8 +44,7 @@ public class DMIBIOSLanguageService implements OptionalCommonDMIServiceInterface * @param timeout the maximum time (in seconds) to wait for the {@code dmidecode} * command to complete before terminating the process * @return an {@link Optional} containing {@link DMIBIOSLanguage} information if present, - * or {@link Optional#empty()} if no BIOS language entry is detected - * + * or {@link Optional#empty()} if no BIOS language entry is detected * @since 0.1.0 */ @Override diff --git a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSService.java b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSService.java index 594cd09..83bdf75 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBIOSService.java @@ -45,8 +45,7 @@ public class DMIBIOSService implements CommonDMIServiceInterface { * @param timeout the maximum time (in seconds) to wait for the {@code dmidecode} * command to complete before terminating the process * @return a list of {@link DMIBIOS} objects representing the system BIOS entries. - * Returns an empty list if no BIOS entries are detected. - * + * Returns an empty list if no BIOS entries are detected. * @since 0.1.0 */ @Override diff --git a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBaseboardService.java b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBaseboardService.java index 51a3c33..71d728b 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBaseboardService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/board/DMIBaseboardService.java @@ -45,8 +45,7 @@ public class DMIBaseboardService implements OptionalCommonDMIServiceInterface { * @param timeout the maximum time (in seconds) to wait for the {@code dmidecode} * command to complete before terminating the process * @return a list of {@link DMICache} objects representing - * the system cache entries. - * Returns an empty list if no cache entries are detected. - * + * the system cache entries. + * Returns an empty list if no cache entries are detected. * @since 0.1.0 */ @Override diff --git a/src/main/java/io/github/eggy03/dmidecode/service/processor/DMIProcessorService.java b/src/main/java/io/github/eggy03/dmidecode/service/processor/DMIProcessorService.java index 4c3f895..7559a41 100644 --- a/src/main/java/io/github/eggy03/dmidecode/service/processor/DMIProcessorService.java +++ b/src/main/java/io/github/eggy03/dmidecode/service/processor/DMIProcessorService.java @@ -42,8 +42,7 @@ public class DMIProcessorService implements CommonDMIServiceInterface Date: Sat, 4 Apr 2026 23:28:06 +0530 Subject: [PATCH 16/19] docs: add implementation status table Signed-off-by: Egg-03 <111327101+eggy03@users.noreply.github.com> --- README.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/README.md b/README.md index d617b51..d119e80 100644 --- a/README.md +++ b/README.md @@ -53,5 +53,53 @@ public class ProcessorExample { } } ``` + +# Implementation Status + +| Number | Type | Status | +|--------|----------------------------------|-------------| +| 0 | BIOS | Implemented | +| 1 | SYSTEM | Implemented | +| 2 | BASEBOARD | Implemented | +| 3 | CHASSIS | Implemented | +| 4 | PROCESSOR | Implemented | +| 5 | MEMORY_CONTROLLER | Pending | +| 6 | MEMORY_MODULE | Pending | +| 7 | CACHE | Implemented | +| 8 | PORT_CONNECTOR | Implemented | +| 9 | SYSTEM_SLOTS | Implemented | +| 10 | ONBOARD_DEVICES | Pending | +| 11 | OEM_SETTINGS | Pending | +| 12 | SYSTEM_CONFIGURATION_OPTIONS | Pending | +| 13 | BIOS_LANGUAGE | Implemented | +| 14 | GROUP_ASSOCIATIONS | Pending | +| 15 | SYSTEM_EVENT_LOG | Pending | +| 16 | PHYSICAL_MEMORY_ARRAY | Implemented | +| 17 | MEMORY_DEVICE | Implemented | +| 18 | THIRTY_TWO_BIT_MEMORY_ERROR | Pending | +| 19 | MEMORY_ARRAY_MAPPED_ADDRESS | Pending | +| 20 | MEMORY_DEVICE_MAPPED_ADDRESS | Pending | +| 21 | BUILT_IN_POINTING_DEVICE | Pending | +| 22 | PORTABLE_BATTERY | Implemented | +| 23 | SYSTEM_RESET | Pending | +| 24 | HARDWARE_SECURITY | Pending | +| 25 | SYSTEM_POWER_CONTROLS | Pending | +| 26 | VOLTAGE_PROBE | Pending | +| 27 | COOLING_DEVICE | Pending | +| 28 | TEMPERATURE_PROBE | Pending | +| 29 | ELECTRICAL_CURRENT_PROBE | Pending | +| 30 | OUT_OF_BAND_REMOTE_ACCESS | Pending | +| 31 | BOOT_INTEGRITY_SERVICES | Pending | +| 32 | SYSTEM_BOOT | Pending | +| 33 | SIXTY_FOUR_BIT_MEMORY_ERROR | Pending | +| 34 | MANAGEMENT_DEVICE | Pending | +| 35 | MANAGEMENT_DEVICE_COMPONENT | Pending | +| 36 | MANAGEMENT_DEVICE_THRESHOLD_DATA | Pending | +| 37 | MEMORY_CHANNEL | Pending | +| 38 | IPMI_DEVICE | Pending | +| 39 | POWER_SUPPLY | Pending | +| 40 | ADDITIONAL_INFORMATION | Pending | +| 41 | ONBOARD_DEVICE | Pending | + # License This project is licensed under the [MIT License](/LICENSE). From 4a729dc751072869a0926b0c85d866c381e2fd17 Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Sun, 5 Apr 2026 22:08:57 +0530 Subject: [PATCH 17/19] build: remove SNAPSHOT from project version - prepare for the official `0.2.0` release Signed-off-by: Egg-03 <111327101+eggy03@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f7d3a46..e4f0560 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.github.eggy03 dmidecode4j - 0.2.0-SNAPSHOT + 0.2.0 8 From a66a1750d0f4bce39511cc433e4882e521d9f5d4 Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Sun, 5 Apr 2026 22:10:14 +0530 Subject: [PATCH 18/19] docs: update for version `0.2.0` release Signed-off-by: Egg-03 <111327101+eggy03@users.noreply.github.com> --- CHANGELOG.md | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 110 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e81cb95..822cd40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,9 +7,118 @@ commits and PRs that contributed to each of the releases. This project tries its best to adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +The following headings may be used while categorizing the list of changes made in each version: + +- New Features +- Removed Features +- Bug Fixes +- Non-Breaking Changes +- Breaking Changes +- Test Changes +- Dependency Updates +- Documentation +- Known Issues + +## [0.2.0] - April 06, 2026 + +This update introduces several breaking changes and is not backwards compatible with the previous versions. +For a complete list of changes, see the enclosed [PR](https://github.com/eggy03/dmidecode4j/pull/2) + +### Non-Breaking Changes + +- Replaced the underlying mapper from GSON to Jackson +- Replaced `DMIType.getCommand(int)` with `DMIType.getCommandFor(DMIType)` in `DMIType.java`. +- Updated all service classes to use the new `DMIType.getCommandFor()` method. + +### Breaking Changes + +- Removed all traces of `Lombok` and replaced them with `Immutables` equivalents for deep immutability of entity + classes. + As a result, the builder methods now have a slightly different syntax. The remaining changes involve writing more + boilerplate code to make up for removal of Lombok's annotations but are non-breaking in nature. + The complete list of changes can be found in the enclosed PR. + +During Lombok, the syntax for an entity builder was as follows: + +```java +import io.github.eggy03.dmidecode.entity.processor.DMIProcessor; + +void main() { + // building a new entity using builder + DMIProcessor processor = DMIProcessor.Builder.build(); + + + DMIProcessor processorTwo = processor.toBuilder().build(); + + // accessing fields + processor.getCurrentSpeed(); +} + + +``` + +With Immutables, the new syntax is: + +```java +import io.github.eggy03.dmidecode.entity.processor.DMIProcessor; + +@SuppressWarnings("all") +void main() { + + // building a new entity using builder + DMIProcessor processor = new DMIProcessor.Builder().build(); + + // updating a built entity + DMIProcessor processorTwo = processor.withProperties(); + + // accessing fields + processor.currentSpeed(); +} +``` + +- All entities have been converted to their abstract forms. + Immutables handles their concrete implementation during compile time. + This is technically not a breaking change since the generated implementations retain their `pre-0.2.0` names + +- `CommonDMIMapper#mapToList` returns an unmodifiable list using `Collections.unmodifiableList` + +### Test Changes + +- Updated corresponding entity tests to use the `Immutables` builder pattern +- Updated `MockEntityClass` in `CommonDMIMapperTest` to use Jackson's `@JsonProperty` as a replacement for GSON's + `@SerializedValue`. +- Removed all traces of Lombok from the tests. + +### Dependency Updates + +- Added Jackson and Immutables BOMs and dependencies +- Removed GSON and Lombok +- Updated source generation plugins to support packing Immutables generated code in `sources.jar` +- Updated `maven-compiler-plugin` from `3.14.1` to `3.15.0` +- Updated `maven-surefire-plugin` from `3.5.4` to `3.5.5` +- Updated `central-publishing-maven-plugin` from `0.9.0` to `0.10.0` +- Updated `assertj-core` from `3.27.6` to `3.27.7` + +### Documentation + +- Replaced JetBrains `@NotNull` and `@Nullable` and Lombok's `@NonNull` annotations with Jspecify equivalents. + For `@Unmodifiable`, an equivalent custom `@Unmodifiable` annotation has been introduced. + +- Introduced two new annotations `@FragileMethod` and `@InvokesFragileMethod`. + These two annotations when used, document that a method or a constructor's implementation is fragile in nature + and may break in the future. + +- Updated Javadocs to reflect the Immutable builder style examples +- Removed `@author` tag from Javadocs +- Updated developer mail in `pom.xml` +- Corrected `project.license.url` branch from `main` to `master` in `pom.xml` +- Added an implementation status table in `README.md` + ## [0.1.1] - January 14, 2026 -- `DMIProcessorService` now returns a list of `DMIProcessor` objects instead of an `Optional` object 0a0ea2306cbe2bf6f15bf14190c28be58f609f55 +## Breaking Changes + +- `DMIProcessorService` now returns a list of `DMIProcessor` objects instead of an `Optional` instance ## [0.1.0] - January 13, 2026 From 05ebafd128c6b2cbd6c09b44c5fc86774b4c207b Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Mon, 6 Apr 2026 09:16:49 +0530 Subject: [PATCH 19/19] ci: add a PR template Signed-off-by: Egg-03 <111327101+eggy03@users.noreply.github.com> --- .github/pull_request_template.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..81b49e6 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,19 @@ +## **Description** + +Provide a clear and concise description of the changes in this PR. +What problem does it solve? What does it add or improve? + +## **Type of Change** + +Keep all that apply: + +- Bug fix +- New feature +- Documentation update +- Refactor +- Tests +- Other (please describe): + +## **Related Issues** + +If this PR closes or relates to an existing issue, link it here: \ No newline at end of file