From: David ‘Bombe’ Roden Date: Sun, 18 Mar 2012 01:13:12 +0000 (+0100) Subject: Add method to parse a priority from a string. X-Git-Tag: 0.10-rc1~6 X-Git-Url: https://git.pterodactylus.net/?p=jSite.git;a=commitdiff_plain;h=53c860450fde63ab927a457611e49e94ce2649db Add method to parse a priority from a string. --- diff --git a/src/de/todesbaum/util/freenet/fcp2/PriorityClass.java b/src/de/todesbaum/util/freenet/fcp2/PriorityClass.java index d9af597..729acc1 100644 --- a/src/de/todesbaum/util/freenet/fcp2/PriorityClass.java +++ b/src/de/todesbaum/util/freenet/fcp2/PriorityClass.java @@ -89,4 +89,25 @@ public final class PriorityClass { return value; } + // + // STATIC METHODS + // + + /** + * Returns the priority class with the given name, matched case-insensitive. + * + * @param value + * The name of the priority + * @return The priority with the given name, or {@code null} if no priority + * matches the given name + */ + public static PriorityClass valueOf(String value) { + for (PriorityClass priorityClass : new PriorityClass[] { MINIMUM, PREFETCH, BULK, UPDATABLE, SEMI_INTERACTIVE, INTERACTIVE, MAXIMUM }) { + if (priorityClass.getName().equalsIgnoreCase(value)) { + return priorityClass; + } + } + return null; + } + }