Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
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;
Expand All @@ -15,17 +14,15 @@
* </p>
* <p>
* It modifies the naming and structural style of the generated immutable implementations via {@link Value.Style}
* and contains {@link JsonSerialize} for automatic Jackson integration.
* </p>
*
* @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
typeAbstract = {"*"}, // No prefixes or suffixes will be detected and trimmed
typeImmutable = "Immutable*", // Generated immutable type will have Immutable prefix added
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.annotation.JsonDeserialize;
import tools.jackson.databind.annotation.JsonSerialize;

import java.util.List;

Expand All @@ -24,25 +26,14 @@
* Instances of this class are thread-safe.
* </p>
*
* <h2>Usage example</h2>
* <pre>{@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");
* }</pre>
*
* @since 0.2.0
*/
@Value.Immutable
@ImmutableEntityStyle
@NullMarked
public abstract class AbstractDMIBIOS {
@JsonSerialize(as = ImmutableDMIBIOS.class)
@JsonDeserialize(as = ImmutableDMIBIOS.class)
public abstract class DMIBIOS {

@JsonProperty("Vendor")
@Nullable
Expand Down Expand Up @@ -80,8 +71,7 @@ public abstract class AbstractDMIBIOS {
@Nullable
public abstract String firmwareRevision();

@Override
public String toString() {
public String toJson() {
return new ObjectMapper()
.writerWithDefaultPrettyPrinter()
.writeValueAsString(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.annotation.JsonDeserialize;
import tools.jackson.databind.annotation.JsonSerialize;

import java.util.List;

Expand All @@ -24,24 +26,14 @@
* Instances of this class are thread-safe.
* </p>
*
* <h2>Usage example</h2>
* <pre>{@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");
* }</pre>
*
* @since 0.2.0
*/
@Value.Immutable
@ImmutableEntityStyle
@NullMarked
public abstract class AbstractDMIBIOSLanguage {
@JsonSerialize(as = ImmutableDMIBIOSLanguage.class)
@JsonDeserialize(as = ImmutableDMIBIOSLanguage.class)
public abstract class DMIBIOSLanguage {

@JsonProperty("Installable Languages")
@Nullable
Expand All @@ -51,8 +43,7 @@ public abstract class AbstractDMIBIOSLanguage {
@Nullable
public abstract String currentLanguage();

@Override
public String toString() {
public String toJson() {
return new ObjectMapper()
.writerWithDefaultPrettyPrinter()
.writeValueAsString(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.annotation.JsonDeserialize;
import tools.jackson.databind.annotation.JsonSerialize;

import java.util.List;

Expand All @@ -24,26 +26,14 @@
* Instances of this class are thread-safe.
* </p>
*
* <h2>Usage example</h2>
* <pre>{@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");
* }</pre>
*
* @since 0.2.0
*/
@Value.Immutable
@ImmutableEntityStyle
@NullMarked
public abstract class AbstractDMIBaseboard {
@JsonSerialize(as = ImmutableDMIBaseboard.class)
@JsonDeserialize(as = ImmutableDMIBaseboard.class)
public abstract class DMIBaseboard {

@JsonProperty("Manufacturer")
@Nullable
Expand Down Expand Up @@ -85,8 +75,7 @@ public abstract class AbstractDMIBaseboard {
@Nullable
public abstract Integer containedObjectHandles();

@Override
public String toString() {
public String toJson() {
return new ObjectMapper()
.writerWithDefaultPrettyPrinter()
.writeValueAsString(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.annotation.JsonDeserialize;
import tools.jackson.databind.annotation.JsonSerialize;

/**
* Immutable representation of system chassis information retrieved via DMI.
Expand All @@ -22,25 +24,14 @@
* Instances of this class are thread-safe.
* </p>
*
* <h2>Usage example</h2>
* <pre>{@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");
* }</pre>
*
* @since 0.2.0
*/
@Value.Immutable
@ImmutableEntityStyle
@NullMarked
public abstract class AbstractDMIChassis {
@JsonSerialize(as = ImmutableDMIChassis.class)
@JsonDeserialize(as = ImmutableDMIChassis.class)
public abstract class DMIChassis {

@JsonProperty("Manufacturer")
@Nullable
Expand Down Expand Up @@ -102,8 +93,7 @@ public abstract class AbstractDMIChassis {
@Nullable
public abstract String skuNumber();

@Override
public String toString() {
public String toJson() {
return new ObjectMapper()
.writerWithDefaultPrettyPrinter()
.writeValueAsString(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.annotation.JsonDeserialize;
import tools.jackson.databind.annotation.JsonSerialize;

/**
* Immutable representation of port connector information retrieved via DMI.
Expand All @@ -22,25 +24,14 @@
* Instances of this class are thread-safe.
* </p>
*
* <h2>Usage example</h2>
* <pre>{@code
* DMIPortConnectorInformation port = new DMIPortConnectorInformation.Builder()
* .externalReferenceDesignator("USB1")
* .externalConnectorType("USB")
* .portType("USB")
* .build();
*
* // Create a modified copy
* DMIPortConnectorInformation updated = port
* .withPortType("USB Type-C");
* }</pre>
*
* @since 0.2.0
*/
@Value.Immutable
@ImmutableEntityStyle
@NullMarked
public abstract class AbstractDMIPortConnectorInformation {
@JsonSerialize(as = ImmutableDMIPortConnectorInformation.class)
@JsonDeserialize(as = ImmutableDMIPortConnectorInformation.class)
public abstract class DMIPortConnectorInformation {

@JsonProperty("External Reference Designator")
@Nullable
Expand All @@ -62,8 +53,7 @@ public abstract class AbstractDMIPortConnectorInformation {
@Nullable
public abstract String portType();

@Override
public String toString() {
public String toJson() {
return new ObjectMapper()
.writerWithDefaultPrettyPrinter()
.writeValueAsString(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.annotation.JsonDeserialize;
import tools.jackson.databind.annotation.JsonSerialize;

import java.util.List;

Expand All @@ -24,26 +26,14 @@
* Instances of this class are thread-safe.
* </p>
*
* <h2>Usage example</h2>
* <pre>{@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");
* }</pre>
*
* @since 0.2.0
*/
@Value.Immutable
@ImmutableEntityStyle
@NullMarked
public abstract class AbstractDMISystemSlots {
@JsonSerialize(as = ImmutableDMISystemSlots.class)
@JsonDeserialize(as = ImmutableDMISystemSlots.class)
public abstract class DMISystemSlots {

@JsonProperty("Designation")
@Nullable
Expand Down Expand Up @@ -73,8 +63,7 @@ public abstract class AbstractDMISystemSlots {
@Nullable
public abstract String busAddress();

@Override
public String toString() {
public String toJson() {
return new ObjectMapper()
.writerWithDefaultPrettyPrinter()
.writeValueAsString(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.annotation.JsonDeserialize;
import tools.jackson.databind.annotation.JsonSerialize;

/**
* Immutable representation of memory device information retrieved via DMI.
Expand All @@ -22,27 +24,14 @@
* Instances of this class are thread-safe.
* </p>
*
* <h2>Usage example</h2>
* <pre>{@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");
* }</pre>
*
* @since 0.2.0
*/
@Value.Immutable
@ImmutableEntityStyle
@NullMarked
public abstract class AbstractDMIMemoryDevice {
@JsonSerialize(as = ImmutableDMIMemoryDevice.class)
@JsonDeserialize(as = ImmutableDMIMemoryDevice.class)
public abstract class DMIMemoryDevice {

@JsonProperty("Array Handle")
@Nullable
Expand Down Expand Up @@ -172,8 +161,7 @@ public abstract class AbstractDMIMemoryDevice {
@Nullable
public abstract String logicalSize();

@Override
public String toString() {
public String toJson() {
return new ObjectMapper()
.writerWithDefaultPrettyPrinter()
.writeValueAsString(this);
Expand Down
Loading
Loading