mirror of
https://github.com/Qortal/qortal.git
synced 2025-07-23 04:36:50 +00:00
Fall back to UNCATEGORIZED if the parsed category doesn't match any available categories.
This allows for deletion of categories, as the resources will just move into UNCATEGORIZED until they are next updated.
This commit is contained in:
@@ -42,7 +42,7 @@ public class ArbitraryDataTransactionMetadata extends ArbitraryDataMetadata {
|
||||
this.tags = metadata.getString("tags");
|
||||
}
|
||||
if (metadata.has("category")) {
|
||||
this.category = Category.valueOf(metadata.getString("category"));
|
||||
this.category = Category.uncategorizedValueOf(metadata.getString("category"));
|
||||
}
|
||||
|
||||
List<byte[]> chunksList = new ArrayList<>();
|
||||
|
@@ -64,4 +64,18 @@ public enum Category {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as valueOf() but with fallback to UNCATEGORIZED if there's no match
|
||||
* @param name
|
||||
* @return a Category (using UNCATEGORIZED if no match found)
|
||||
*/
|
||||
public static Category uncategorizedValueOf(String name) {
|
||||
try {
|
||||
return Category.valueOf(name);
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
return Category.UNCATEGORIZED;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user