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 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 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). diff --git a/pom.xml b/pom.xml index 8714ffe..e4f0560 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.github.eggy03 dmidecode4j - 0.1.1 + 0.2.0 8 @@ -17,11 +17,11 @@ 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 - egg03@duck.com + eggzerothree@proton.me https://github.com/eggy03/dmidecode4j.git scm:git:ssh://git@github.com:eggy03/dmidecode4j.git @@ -29,43 +29,66 @@ egg-03 - 1.18.42 - 2.13.2 - 26.0.2 + 2.12.1 + 3.1.1 + 1.0.0 6.0.0 5.20.0 - 3.27.6 + 3.27.7 1.5.0 2.0.17 - 1.18.20.0 - 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 + + + + org.immutables + bom + ${immutables.version} + pom + import + + + tools.jackson + jackson-bom + ${jackson.version} + pom + import + + + + - com.google.code.gson - gson - ${google.gson.version} + org.immutables + value + provided - org.projectlombok - lombok - ${lombok.version} - provided + com.fasterxml.jackson.core + jackson-annotations + compile - org.jetbrains - annotations - ${jetbrains.annotations.version} + tools.jackson.core + jackson-databind + compile + + + org.jspecify + jspecify + ${jspecify.version} org.slf4j @@ -133,9 +156,9 @@ - org.projectlombok - lombok - ${lombok.version} + org.immutables + value + ${immutables.version} @@ -147,76 +170,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 - - - diff --git a/src/main/java/io/github/eggy03/dmidecode/annotation/ImmutableEntityStyle.java b/src/main/java/io/github/eggy03/dmidecode/annotation/ImmutableEntityStyle.java new file mode 100644 index 0000000..8441871 --- /dev/null +++ b/src/main/java/io/github/eggy03/dmidecode/annotation/ImmutableEntityStyle.java @@ -0,0 +1,35 @@ +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; + +/** + *

+ * 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 +@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 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 new file mode 100644 index 0000000..6ffe3d2 --- /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.RUNTIME) +@Documented +public @interface Unmodifiable { +} 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..8c2d8ae --- /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. + *

+ * + * @see InvokesFragileMethod + * @since 0.2.0 + */ +@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..b8ff484 --- /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. + *

+ * + * @see FragileMethod + * @since 0.2.0 + */ +@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..08a227a --- /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 + * + * @see FragileMethod + * @see InvokesFragileMethod + * @since 0.2.0 + */ +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/constant/DMIType.java b/src/main/java/io/github/eggy03/dmidecode/constant/DMIType.java index 48c5f12..64dc320 100644 --- a/src/main/java/io/github/eggy03/dmidecode/constant/DMIType.java +++ b/src/main/java/io/github/eggy03/dmidecode/constant/DMIType.java @@ -5,9 +5,6 @@ */ package io.github.eggy03.dmidecode.constant; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - /** * Enumeration of DMI types as defined by the * {@code dmidecode} specification. @@ -19,14 +16,11 @@ *

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 - * @author Sayan Bhattacharya */ -@RequiredArgsConstructor -@Getter public enum DMIType { BIOS(0), @@ -71,10 +65,14 @@ public enum DMIType { POWER_SUPPLY(39), ADDITIONAL_INFORMATION(40), ONBOARD_DEVICE(41); - + private final int value; - public static String getCommand(int dmiType){ - return "sudo /usr/sbin/dmidecode --type "+dmiType; + DMIType(int value) { + this.value = value; + } + + 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/board/AbstractDMIBIOS.java b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBIOS.java new file mode 100644 index 0000000..62de8f7 --- /dev/null +++ b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBIOS.java @@ -0,0 +1,89 @@ +/* + * © 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.ImmutableEntityStyle; +import org.immutables.value.Value; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; +import tools.jackson.databind.ObjectMapper; + +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 +@ImmutableEntityStyle +@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(); + + @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 new file mode 100644 index 0000000..ba3cdb1 --- /dev/null +++ b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBIOSLanguage.java @@ -0,0 +1,60 @@ +/* + * © 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.ImmutableEntityStyle; +import org.immutables.value.Value; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; +import tools.jackson.databind.ObjectMapper; + +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 +@ImmutableEntityStyle +@NullMarked +public abstract class AbstractDMIBIOSLanguage { + + @JsonProperty("Installable Languages") + @Nullable + public abstract List<@Nullable String> installableLanguages(); + + @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 new file mode 100644 index 0000000..72adbed --- /dev/null +++ b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIBaseboard.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.board; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.github.eggy03.dmidecode.annotation.ImmutableEntityStyle; +import org.immutables.value.Value; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; +import tools.jackson.databind.ObjectMapper; + +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 +@ImmutableEntityStyle +@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(); + + @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 new file mode 100644 index 0000000..a36fce1 --- /dev/null +++ b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIChassis.java @@ -0,0 +1,112 @@ +/* + * © 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.ImmutableEntityStyle; +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. + *

+ * 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 +@ImmutableEntityStyle +@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(); + + @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 new file mode 100644 index 0000000..cfeaa3e --- /dev/null +++ b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMIPortConnectorInformation.java @@ -0,0 +1,72 @@ +/* + * © 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.ImmutableEntityStyle; +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. + *

+ * 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 +@ImmutableEntityStyle +@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(); + + @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 new file mode 100644 index 0000000..956f169 --- /dev/null +++ b/src/main/java/io/github/eggy03/dmidecode/entity/board/AbstractDMISystemSlots.java @@ -0,0 +1,82 @@ +/* + * © 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.ImmutableEntityStyle; +import org.immutables.value.Value; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; +import tools.jackson.databind.ObjectMapper; + +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 +@ImmutableEntityStyle +@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(); + + @Override + public String toString() { + return new ObjectMapper() + .writerWithDefaultPrettyPrinter() + .writeValueAsString(this); + } +} 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..b448655 --- /dev/null +++ b/src/main/java/io/github/eggy03/dmidecode/entity/memory/AbstractDMIMemoryDevice.java @@ -0,0 +1,181 @@ +/* + * © 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.ImmutableEntityStyle; +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. + *

+ * 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 +@ImmutableEntityStyle +@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(); + + @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 new file mode 100644 index 0000000..a6b2204 --- /dev/null +++ b/src/main/java/io/github/eggy03/dmidecode/entity/memory/AbstractDMIPhysicalMemoryArray.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.memory; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.github.eggy03.dmidecode.annotation.ImmutableEntityStyle; +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. + *

+ * 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 +@ImmutableEntityStyle +@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(); + + @Override + public String toString() { + return new ObjectMapper() + .writerWithDefaultPrettyPrinter() + .writeValueAsString(this); + } +} 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..1bca010 --- /dev/null +++ b/src/main/java/io/github/eggy03/dmidecode/entity/peripheral/AbstractDMIPortableBattery.java @@ -0,0 +1,96 @@ +/* + * © 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.ImmutableEntityStyle; +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. + *

+ * 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 +@ImmutableEntityStyle +@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(); + + @Override + public String toString() { + return new ObjectMapper() + .writerWithDefaultPrettyPrinter() + .writeValueAsString(this); + } +} 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..c50f1f5 --- /dev/null +++ b/src/main/java/io/github/eggy03/dmidecode/entity/processor/AbstractDMICache.java @@ -0,0 +1,102 @@ +/* + * © 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.ImmutableEntityStyle; +import org.immutables.value.Value; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; +import tools.jackson.databind.ObjectMapper; + +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 +@ImmutableEntityStyle +@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(); + + @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 new file mode 100644 index 0000000..c5e3ee6 --- /dev/null +++ b/src/main/java/io/github/eggy03/dmidecode/entity/processor/AbstractDMIProcessor.java @@ -0,0 +1,152 @@ +/* + * © 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.ImmutableEntityStyle; +import org.immutables.value.Value; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; +import tools.jackson.databind.ObjectMapper; + +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 +@ImmutableEntityStyle +@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(); + + @Override + public String toString() { + return new ObjectMapper() + .writerWithDefaultPrettyPrinter() + .writeValueAsString(this); + } +} 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..91081e8 --- /dev/null +++ b/src/main/java/io/github/eggy03/dmidecode/entity/system/AbstractDMISystem.java @@ -0,0 +1,84 @@ +/* + * © 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.ImmutableEntityStyle; +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. + *

+ * 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 +@ImmutableEntityStyle +@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(); + + @Override + public String toString() { + return new ObjectMapper() + .writerWithDefaultPrettyPrinter() + .writeValueAsString(this); + } +} 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/main/java/io/github/eggy03/dmidecode/exception/TerminalExecutionException.java b/src/main/java/io/github/eggy03/dmidecode/exception/TerminalExecutionException.java index eb43b7b..3a7597f 100644 --- a/src/main/java/io/github/eggy03/dmidecode/exception/TerminalExecutionException.java +++ b/src/main/java/io/github/eggy03/dmidecode/exception/TerminalExecutionException.java @@ -5,14 +5,26 @@ */ 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 - * @author Sayan Bhattacharya */ -@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/mapper/CommonDMIMapper.java b/src/main/java/io/github/eggy03/dmidecode/mapper/CommonDMIMapper.java index 2acae89..94e0b2e 100644 --- a/src/main/java/io/github/eggy03/dmidecode/mapper/CommonDMIMapper.java +++ b/src/main/java/io/github/eggy03/dmidecode/mapper/CommonDMIMapper.java @@ -5,10 +5,12 @@ */ package io.github.eggy03.dmidecode.mapper; -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +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; import java.util.ArrayList; import java.util.Collections; @@ -37,16 +39,15 @@ *
  • 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 * @since 0.1.0 - * @author Sayan Bhattacharjee */ public interface CommonDMIMapper { - Gson GSON = new Gson(); + ObjectMapper jacksonMapper = new ObjectMapper(); /** * Maps raw {@code dmidecode} output into a single entity of type {@code }. @@ -78,63 +79,66 @@ 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 */ - default Optional mapToEntity(@Nullable String rawDMIData, @NotNull Class mappableEntityClass) { + @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) + if (rawDMIData == null) return Optional.empty(); 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)); } /** @@ -179,25 +183,29 @@ default Optional mapToEntity(@Nullable String rawDMIData, @NotNull Class m * 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 */ - default List mapToList(@Nullable String rawDMIData, @NotNull Class mappableEntityClass) { + @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) + if (rawDMIData == null) return Collections.emptyList(); List entityList = new ArrayList<>(); 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,49 +215,47 @@ default List mapToList(@Nullable String rawDMIData, @NotNull Class mappabl 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; + return entityList.isEmpty() ? Collections.emptyList() : Collections.unmodifiableList(new ArrayList<>(entityList)); } } \ No newline at end of file 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..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,10 +17,8 @@ *

    * * @param the entity type returned by the service implementation - * - * @since 0.1.0 - * @author Sayan Bhattacharya * @see OptionalCommonDMIServiceInterface + * @since 0.1.0 */ public interface CommonDMIServiceInterface { @@ -32,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 cc463ea..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,10 +17,8 @@ *

    * * @param the entity type returned by the service implementation - * - * @since 0.1.0 - * @author Sayan Bhattacharya * @see CommonDMIServiceInterface + * @since 0.1.0 */ public interface OptionalCommonDMIServiceInterface { @@ -33,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 6410913..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 @@ -5,12 +5,15 @@ */ 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; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NonNull; import java.util.Optional; @@ -28,7 +31,6 @@ * } * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMIBIOSLanguageService implements OptionalCommonDMIServiceInterface { @@ -42,15 +44,14 @@ 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 - @NotNull - public Optional get(long timeout) { + @InvokesFragileMethod(targetClass = CommonDMIMapper.class, methodType = MethodType.INTERFACE_DEFAULT_METHOD) + 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 ba2cd74..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 @@ -5,12 +5,16 @@ */ 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; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NonNull; import java.util.List; @@ -28,7 +32,6 @@ * } * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMIBIOSService implements CommonDMIServiceInterface { @@ -42,15 +45,14 @@ 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 - @NotNull - public List get(long timeout) { + @InvokesFragileMethod(targetClass = CommonDMIMapper.class, methodType = MethodType.INTERFACE_DEFAULT_METHOD) + 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 0964303..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 @@ -5,12 +5,15 @@ */ 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; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NonNull; import java.util.Optional; @@ -29,7 +32,6 @@ * } * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMIBaseboardService implements OptionalCommonDMIServiceInterface { @@ -43,15 +45,14 @@ public class DMIBaseboardService implements OptionalCommonDMIServiceInterface get(long timeout) { + @InvokesFragileMethod(targetClass = CommonDMIMapper.class, methodType = MethodType.INTERFACE_DEFAULT_METHOD) + public @NonNull Optional 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 a7c7f9f..33517a1 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,12 +5,15 @@ */ 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; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NonNull; import java.util.Optional; @@ -28,7 +31,6 @@ * } * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMIChassisService implements OptionalCommonDMIServiceInterface { @@ -42,15 +44,14 @@ public class DMIChassisService implements OptionalCommonDMIServiceInterface get(long timeout) { + @InvokesFragileMethod(targetClass = CommonDMIMapper.class, methodType = MethodType.INTERFACE_DEFAULT_METHOD) + public @NonNull Optional 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 3d57edf..da214d8 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,16 @@ */ 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; +import org.jspecify.annotations.NonNull; import java.util.List; @@ -27,7 +32,6 @@ * } * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMIPortConnectorInformationService implements CommonDMIServiceInterface { @@ -41,15 +45,15 @@ public class DMIPortConnectorInformationService implements CommonDMIServiceInter * @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 DMIPortConnectorInformation} objects representing - * the system port connector entries. - * Returns an empty list if no port connector entries are detected. - * + * the system port connector entries. + * Returns an empty list if no port connector entries are detected. * @since 0.1.0 */ @Override - public List get(long timeout) { + @InvokesFragileMethod(targetClass = CommonDMIMapper.class, methodType = MethodType.INTERFACE_DEFAULT_METHOD) + 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 e1df848..e3ee2b0 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,16 @@ */ 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; +import org.jspecify.annotations.NonNull; import java.util.List; @@ -27,7 +32,6 @@ * } * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMISystemSlotsService implements CommonDMIServiceInterface { @@ -41,15 +45,15 @@ public class DMISystemSlotsService implements CommonDMIServiceInterface get(long timeout) { + @InvokesFragileMethod(targetClass = CommonDMIMapper.class, methodType = MethodType.INTERFACE_DEFAULT_METHOD) + public @Unmodifiable @NonNull List 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 fb7a682..8579237 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; @@ -28,7 +29,6 @@ * } * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMIMemoryDeviceService implements CommonDMIServiceInterface { @@ -42,16 +42,14 @@ 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), + 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 678c53e..74b6aa6 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; @@ -27,7 +28,6 @@ * } * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMIPhysicalMemoryArrayService implements OptionalCommonDMIServiceInterface { @@ -41,15 +41,14 @@ public class DMIPhysicalMemoryArrayService implements OptionalCommonDMIServiceIn * @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 DMIPhysicalMemoryArray} information - * if present, or {@link Optional#empty()} if no physical memory array - * entry is detected - * + * if present, or {@link Optional#empty()} if no physical memory array + * entry is detected * @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), + 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 f9017a4..3748a44 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; @@ -27,7 +29,6 @@ * } * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMIPortableBatteryService implements CommonDMIServiceInterface { @@ -41,15 +42,14 @@ 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), + 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 1e4385f..b4e1aa9 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; @@ -28,7 +29,6 @@ * } * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMICacheService implements CommonDMIServiceInterface { @@ -42,16 +42,14 @@ public class DMICacheService 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 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 - @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), + 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 5d32b7e..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 @@ -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; @@ -28,7 +29,6 @@ * } * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMIProcessorService implements CommonDMIServiceInterface { @@ -42,15 +42,13 @@ 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), + 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 5852d7e..18000bd 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; @@ -28,7 +29,6 @@ * } * * @since 0.1.0 - * @author Sayan Bhattacharya */ public class DMISystemService implements OptionalCommonDMIServiceInterface { @@ -42,16 +42,14 @@ 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), + TerminalUtility.executeCommand(DMIType.getCommandFor(DMIType.SYSTEM), 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..442938e 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.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.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NonNull; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -23,27 +23,31 @@ * A utility class that provides a way to launch a terminal session *

    * Mostly for internal use - * @author Sayan Bhattacharya + * * @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 * - * @param command The command/script to be executed in the terminal + * @param command The command/script to be executed in the terminal * @param timeoutSeconds Time in seconds after which the session will be force stopped * @return The result of the command executed * @throws TerminalExecutionException When the process is killed pre-maturely upon reaching the timeout - * or when the command yields an error, or when the terminal cannot be accessed. - * @throws IllegalArgumentException If the provided timeout is in the negative + * 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 @NonNull String executeCommand(@NonNull String command, long timeoutSeconds) { - if(timeoutSeconds<0) + if (timeoutSeconds < 0) throw new IllegalArgumentException("Timeout cannot be negative"); CommandLine cmdLine = new CommandLine("bash"); @@ -66,7 +70,7 @@ public static String executeCommand(@NotNull String command, long timeoutSeconds } catch (ExecuteException e) { String reason = watchdog.killedProcess() ? "\nProcess executing the following command: " + command + "\nWas killed after a timeout of " + timeoutSeconds + " seconds\n" : - "\nProcess executing the following command: " + command + "\nExited with a non-zero exit code\nTerminal Error Output: "+ err; + "\nProcess executing the following command: " + command + "\nExited with a non-zero exit code\nTerminal Error Output: " + err; throw new TerminalExecutionException(reason, e); } catch (IOException e) { 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 } 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()); } } }