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

View File

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