Add ReadWrite enum and update CdDriveAsset to use ReadWrite for support properties

This commit is contained in:
2025-06-09 08:42:43 +02:00
parent 5e902dd8b0
commit 54231df858
3 changed files with 59 additions and 55 deletions

View File

@@ -3,6 +3,7 @@ package be.seeseepuff.pcinv.meta;
import be.seeseepuff.pcinv.models.Asset;
import be.seeseepuff.pcinv.models.AssetCondition;
import be.seeseepuff.pcinv.models.GenericAsset;
import be.seeseepuff.pcinv.models.ReadWrite;
import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;
import lombok.AllArgsConstructor;
@@ -58,6 +59,7 @@ public class AssetProperty {
BOOLEAN(false),
CAPACITY(false),
CONDITION(true),
READWRITE(true),
;
/// Set to `true` if the type is an enum, `false` otherwise.
public final boolean isEnum;
@@ -155,6 +157,8 @@ public class AssetProperty {
return Type.BOOLEAN;
} else if (property.getType() == AssetCondition.class) {
return Type.CONDITION;
} else if (property.getType() == ReadWrite.class) {
return Type.READWRITE;
} else {
throw new IllegalArgumentException("Unsupported property type: " + property.getType());
}

View File

@@ -24,104 +24,74 @@ public class CdDriveAsset implements Asset
@OneToOne(orphanRemoval = true)
private GenericAsset asset;
@Description("Indicates if the drive supports reading CD-ROM discs.")
@Description("Indicates if the drive supports CD-ROM discs.")
@Property("CD-ROM Supported")
@HideInOverview
private Boolean supportsCdRom;
private ReadWrite supportsCdRom;
@Description("Indicates if the drive supports reading CD-R discs.")
@Description("Indicates if the drive supports CD-R discs.")
@Property("CD-R Supported")
@HideInOverview
private Boolean supportsCdR;
private ReadWrite supportsCdR;
@Description("Indicates if the drive supports writing CD-R discs.")
@Property("CD-R Writing Supported")
@HideInOverview
private Boolean supportsCdRwriting;
@Description("Indicates if the drive supports reading CD-RW discs.")
@Description("Indicates if the drive supports CD-RW discs.")
@Property("CD-RW Supported")
@HideInOverview
private Boolean supportsCdRw;
private ReadWrite supportsCdRw;
@Description("Indicates if the drive supports writing CD-RW discs.")
@Property("CD-RW Writing Supported")
@HideInOverview
private Boolean supportsCdRwwriting;
@Description("Indicates if the drive supports reading DVD discs.")
@Description("Indicates if the drive supports DVD discs.")
@Property("DVD Supported")
@HideInOverview
private Boolean supportsDvd;
private ReadWrite supportsDvd;
@Description("Indicates if the drive supports reading DVD-R discs.")
@Description("Indicates if the drive supports DVD-R discs.")
@Property("DVD-R Supported")
@HideInOverview
private Boolean supportsDvdR;
private ReadWrite supportsDvdR;
@Description("Indicates if the drive supports writing DVD-R discs.")
@Property("DVD-R Writing Supported")
@HideInOverview
private Boolean supportsDvdRwriting;
@Description("Indicates if the drive supports reading DVD-RW discs.")
@Description("Indicates if the drive supports DVD-RW discs.")
@Property("DVD-RW Supported")
@HideInOverview
private Boolean supportsDvdRw;
private ReadWrite supportsDvdRw;
@Description("Indicates if the drive supports writing DVD-RW discs.")
@Property("DVD-RW Writing Supported")
@HideInOverview
private Boolean supportsDvdRwwriting;
@Description("Indicates if the drive supports reading DVD+R discs.")
@Description("Indicates if the drive supports DVD+R discs.")
@Property("DVD+R Supported")
@HideInOverview
private Boolean supportsDvdPlusR;
private ReadWrite supportsDvdPlusR;
@Description("Indicates if the drive supports writing DVD+R discs.")
@Property("DVD+R Writing Supported")
@HideInOverview
private Boolean supportsDvdPlusRwriting;
@Description("Indicates if the drive supports reading DVD+RW discs.")
@Description("Indicates if the drive supports DVD+RW discs.")
@Property("DVD+RW Supported")
@HideInOverview
private Boolean supportsDvdPlusRw;
private ReadWrite supportsDvdPlusRw;
@Description("Indicates if the drive supports writing DVD+RW discs.")
@Property("DVD+RW Writing Supported")
@HideInOverview
private Boolean supportsDvdPlusRwwriting;
@Description("Indicates if the drive supports reading DVD-RAM discs.")
@Description("Indicates if the drive supports DVD-RAM discs.")
@Property("DVD-RAM Supported")
@HideInOverview
private Boolean supportsDvdRam;
private ReadWrite supportsDvdRam;
@Description("Indicates if the drive supports reading Blu-ray discs.")
@Description("Indicates if the drive supports Blu-ray discs.")
@Property("Blu-ray Supported")
@HideInOverview
private Boolean supportsBluRay;
private ReadWrite supportsBluRay;
@Description("Indicates if the drive supports reading HD DVD discs.")
@Description("Indicates if the drive supports HD DVD discs.")
@Property("HD DVD Supported")
@HideInOverview
private Boolean supportsHdDvd;
private ReadWrite supportsHdDvd;
@Description("Indicates if the drive supports reading Ultra HD Blu-ray discs.")
@Description("Indicates if the drive supports Ultra HD Blu-ray discs.")
@Property("Ultra HD Blu-ray Supported")
@HideInOverview
private Boolean supportsUltraHdBluRay;
private ReadWrite supportsUltraHdBluRay;
@Description("The type of interface used by the drive. E.g.: SATA, IDE, etc.")
@Property("Interface Type")
@HideInOverview
@InputList
private String interfaceType;
@Description("The form factor of the CD drive. E.g.: 5.25\", 3.5\", etc.")
@Property("Form Factor")
@HideInOverview
@InputList
private String formFactor;
}

View File

@@ -0,0 +1,30 @@
package be.seeseepuff.pcinv.models;
import be.seeseepuff.pcinv.meta.AssetEnum;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
/**
* An enum representing the read/write capabilities of a device.
* This is used to indicate whether a device can read, write, or both.
*/
@Getter
@RequiredArgsConstructor
public enum ReadWrite implements AssetEnum {
/// The capacbilities are unknown.
UNKNOWN("unknown", "Unknown"),
/// The device can only read data.
READ("read", "Read Only"),
/// The device can only write data.
WRITE("write", "Write Only"),
/// The device can both read and write data.
READ_WRITE("read_write", "Read and Write")
;
private final String value;
private final String displayName;
@Override
public boolean isDefaultValue() {
return this == UNKNOWN;
}
}