Removal of Lombok

Lombok implementation removal.

I have also gone through and replaced things with inline methods and variables, lambdas, and simplified loops down, removed unnecessary guard clauses, and overall cleaned up every single class. This took a long time, please do remember to follow proper naming conventions, don't include unnecessary guard clauses, follow exception rules and comment rules, and please PLEASE remember to use the DIAMOND OPERATOR rather than just inferring RAW TYPES!!!

Thank you!!
This commit is contained in:
Paldiu
2020-12-25 14:46:43 -05:00
parent 210b0f8b43
commit 5c0f77c7c5
170 changed files with 3302 additions and 2383 deletions

View File

@ -4,7 +4,6 @@ import java.net.Socket;
import java.util.HashMap;
import java.util.Map;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.httpd.HTTPDPageBuilder;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.HTTPSession;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Method;
@ -21,7 +20,7 @@ public abstract class HTTPDModule extends FreedomService
protected final Socket socket;
protected final HTTPSession session;
public HTTPDModule(TotalFreedomMod plugin, HTTPSession session)
public HTTPDModule(HTTPSession session)
{
this.uri = session.getUri();
this.method = session.getMethod();

View File

@ -1,18 +1,17 @@
package me.totalfreedom.totalfreedommod.httpd.module;
import java.io.File;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
import me.totalfreedom.totalfreedommod.admin.ActivityLog;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
public class Module_activitylog extends HTTPDModule
{
public Module_activitylog(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
public Module_activitylog(NanoHTTPD.HTTPSession session)
{
super(plugin, session);
super(session);
}
@Override

View File

@ -1,15 +1,14 @@
package me.totalfreedom.totalfreedommod.httpd.module;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
public class Module_admins extends HTTPDModule
{
public Module_admins(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
public Module_admins(NanoHTTPD.HTTPSession session)
{
super(plugin, session);
super(session);
}
@Override

View File

@ -1,15 +1,14 @@
package me.totalfreedom.totalfreedommod.httpd.module;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
public class Module_bans extends HTTPDModule
{
public Module_bans(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
public Module_bans(NanoHTTPD.HTTPSession session)
{
super(plugin, session);
super(session);
}
@Override

View File

@ -2,7 +2,6 @@ package me.totalfreedom.totalfreedommod.httpd.module;
import java.io.File;
import java.io.FileInputStream;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
@ -12,7 +11,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
@ -25,7 +23,6 @@ import org.apache.commons.lang3.StringUtils;
public class Module_file extends HTTPDModule
{
private final File rootDir = new File(ConfigEntry.HTTPD_PUBLIC_FOLDER.getString());
public static final Map<String, String> MIME_TYPES = new HashMap<>();
static
@ -58,9 +55,11 @@ public class Module_file extends HTTPDModule
MIME_TYPES.put("class", "application/octet-stream");
}
public Module_file(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
private final File rootDir = new File(ConfigEntry.HTTPD_PUBLIC_FOLDER.getString());
public Module_file(NanoHTTPD.HTTPSession session)
{
super(plugin, session);
super(session);
}
private File getRootDir()
@ -70,31 +69,31 @@ public class Module_file extends HTTPDModule
private String encodeUri(String uri)
{
String newUri = "";
StringBuilder newUri = new StringBuilder();
StringTokenizer st = new StringTokenizer(uri, "/ ", true);
while (st.hasMoreTokens())
{
String tok = st.nextToken();
if (tok.equals("/"))
{
newUri += "/";
newUri.append("/");
}
else if (tok.equals(" "))
{
newUri += "%20";
newUri.append("%20");
}
else
{
try
{
newUri += URLEncoder.encode(tok, "UTF-8");
newUri.append(URLEncoder.encode(tok, "UTF-8"));
}
catch (UnsupportedEncodingException ignored)
{
}
}
}
return newUri;
return newUri.toString();
}
public Response serveFile(String uri, Map<String, String> params, File homeDir)
@ -237,7 +236,6 @@ public class Module_file extends HTTPDModule
{
res = new Response(Response.Status.RANGE_NOT_SATISFIABLE, NanoHTTPD.MIME_PLAINTEXT, "");
res.addHeader("Content-Range", "bytes 0-0/" + fileLen);
res.addHeader("ETag", etag);
}
else
{
@ -255,25 +253,25 @@ public class Module_file extends HTTPDModule
FileInputStream fis = new FileInputStream(f)
{
@Override
public int available() throws IOException
public int available()
{
return (int)dataLen;
}
};
//noinspection ResultOfMethodCallIgnored
fis.skip(startFrom);
res = new Response(Response.Status.PARTIAL_CONTENT, mime, fis);
res.addHeader("Content-Length", "" + dataLen);
res.addHeader("Content-Range", "bytes " + startFrom + "-" + endAt + "/" + fileLen);
res.addHeader("ETag", etag);
}
}
else
{
res = new Response(Response.Status.OK, mime, new FileInputStream(f));
res.addHeader("Content-Length", "" + fileLen);
res.addHeader("ETag", etag);
}
res.addHeader("ETag", etag);
}
}
catch (IOException ioe)
@ -288,12 +286,12 @@ public class Module_file extends HTTPDModule
private String listDirectory(String uri, File f)
{
String heading = "Directory " + uri;
String msg = "<html><head><title>" + heading + "</title><style><!--\n"
StringBuilder msg = new StringBuilder("<html><head><title>" + heading + "</title><style><!--\n"
+ "span.dirname { font-weight: bold; }\n"
+ "span.filesize { font-size: 75%; }\n"
+ "// -->\n"
+ "</style>"
+ "</head><body><h1>" + heading + "</h1>";
+ "</head><body><h1>" + heading + "</h1>");
String up = null;
if (uri.length() > 1)
@ -306,72 +304,56 @@ public class Module_file extends HTTPDModule
}
}
List<String> files = Arrays.asList(f.list(new FilenameFilter()
{
@Override
public boolean accept(File dir, String name)
{
return new File(dir, name).isFile();
}
}));
List<String> files = Arrays.asList(f.list((dir, name) -> new File(dir, name).isFile()));
Collections.sort(files);
List<String> directories = Arrays.asList(f.list(new FilenameFilter()
{
@Override
public boolean accept(File dir, String name)
{
return new File(dir, name).isDirectory();
}
}));
List<String> directories = Arrays.asList(f.list((dir, name) -> new File(dir, name).isDirectory()));
Collections.sort(directories);
if (up != null || directories.size() + files.size() > 0)
{
msg += "<ul>";
msg.append("<ul>");
if (up != null || directories.size() > 0)
{
msg += "<section class=\"directories\">";
msg.append("<section class=\"directories\">");
if (up != null)
{
msg += "<li><a rel=\"directory\" href=\"" + up + "\"><span class=\"dirname\">..</span></a></b></li>";
msg.append("<li><a rel=\"directory\" href=\"").append(up).append("\"><span class=\"dirname\">..</span></a></b></li>");
}
for (int i = 0; i < directories.size(); i++)
for (String directory : directories)
{
String dir = directories.get(i) + "/";
msg += "<li><a rel=\"directory\" href=\"" + encodeUri(uri + dir) + "\"><span class=\"dirname\">" + dir + "</span></a></b></li>";
String dir = directory + "/";
msg.append("<li><a rel=\"directory\" href=\"").append(encodeUri(uri + dir)).append("\"><span class=\"dirname\">").append(dir).append("</span></a></b></li>");
}
msg += "</section>";
msg.append("</section>");
}
if (files.size() > 0)
{
msg += "<section class=\"files\">";
for (int i = 0; i < files.size(); i++)
msg.append("<section class=\"files\">");
for (String file : files)
{
String file = files.get(i);
msg += "<li><a href=\"" + encodeUri(uri + file) + "\"><span class=\"filename\">" + file + "</span></a>";
msg.append("<li><a href=\"").append(encodeUri(uri + file)).append("\"><span class=\"filename\">").append(file).append("</span></a>");
File curFile = new File(f, file);
long len = curFile.length();
msg += "&nbsp;<span class=\"filesize\">(";
msg.append("&nbsp;<span class=\"filesize\">(");
if (len < 1024)
{
msg += len + " bytes";
msg.append(len).append(" bytes");
}
else if (len < 1024 * 1024)
{
msg += len / 1024 + "." + (len % 1024 / 10 % 100) + " KB";
msg.append(len / 1024).append(".").append(len % 1024 / 10 % 100).append(" KB");
}
else
{
msg += len / (1024 * 1024) + "." + len % (1024 * 1024) / 10 % 100 + " MB";
msg.append(len / (1024 * 1024)).append(".").append(len % (1024 * 1024) / 10 % 100).append(" MB");
}
msg += ")</span></li>";
msg.append(")</span></li>");
}
msg += "</section>";
msg.append("</section>");
}
msg += "</ul>";
msg.append("</ul>");
}
msg += "</body></html>";
return msg;
msg.append("</body></html>");
return msg.toString();
}
@Override

View File

@ -2,12 +2,11 @@ package me.totalfreedom.totalfreedommod.httpd.module;
import com.google.common.collect.Lists;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.command.FreedomCommand;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
@ -24,16 +23,39 @@ import static org.apache.commons.lang3.StringEscapeUtils.escapeHtml4;
public class Module_help extends HTTPDModule
{
public Module_help(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
public Module_help(NanoHTTPD.HTTPSession session)
{
super(plugin, session);
super(session);
}
private static String buildDescription(Command command)
{
StringBuilder sb = new StringBuilder();
sb.append(
"<li><span class=\"commandName\">{$CMD_NAME}</span> - Usage: <span class=\"commandUsage\">{$CMD_USAGE}</span>"
.replace("{$CMD_NAME}", escapeHtml4(command.getName().trim()))
.replace("{$CMD_USAGE}", escapeHtml4(command.getUsage().trim())));
if (!command.getAliases().isEmpty())
{
sb.append(
" - Aliases: <span class=\"commandAliases\">{$CMD_ALIASES}</span>"
.replace("{$CMD_ALIASES}", escapeHtml4(StringUtils.join(command.getAliases(), ", "))));
}
sb.append(
"<br><span class=\"commandDescription\">{$CMD_DESC}</span></li>\r\n"
.replace("{$CMD_DESC}", escapeHtml4(command.getDescription().trim())));
return sb.toString();
}
@Override
public String getBody()
{
final CommandMap map = FreedomCommand.getCommandMap();
if (map == null || !(map instanceof SimpleCommandMap))
if (!(map instanceof SimpleCommandMap))
{
return paragraph("Error loading commands.");
}
@ -60,14 +82,12 @@ public class Module_help extends HTTPDModule
pluginCommands.add(command);
}
final Iterator<Map.Entry<String, List<Command>>> it = commandsByPlugin.entrySet().iterator();
while (it.hasNext())
for (Map.Entry<String, List<Command>> entry : commandsByPlugin.entrySet())
{
final Map.Entry<String, List<Command>> entry = it.next();
final String pluginName = entry.getKey();
final List<Command> commands = entry.getValue();
Collections.sort(commands, new CommandComparator());
commands.sort(new CommandComparator());
responseBody.append(heading(pluginName, 2)).append("<ul>\r\n");
@ -80,7 +100,7 @@ public class Module_help extends HTTPDModule
continue;
}
Displayable tfmCommandLevel = FreedomCommand.getFrom(command).getPerms().level();
Displayable tfmCommandLevel = Objects.requireNonNull(FreedomCommand.getFrom(command)).getPerms().level();
if (lastTfmCommandLevel == null || lastTfmCommandLevel != tfmCommandLevel)
{
responseBody.append("</ul>\r\n").append(heading(tfmCommandLevel.getName(), 3)).append("<ul>\r\n");
@ -95,29 +115,6 @@ public class Module_help extends HTTPDModule
return responseBody.toString();
}
private static String buildDescription(Command command)
{
StringBuilder sb = new StringBuilder();
sb.append(
"<li><span class=\"commandName\">{$CMD_NAME}</span> - Usage: <span class=\"commandUsage\">{$CMD_USAGE}</span>"
.replace("{$CMD_NAME}", escapeHtml4(command.getName().trim()))
.replace("{$CMD_USAGE}", escapeHtml4(command.getUsage().trim())));
if (!command.getAliases().isEmpty())
{
sb.append(
" - Aliases: <span class=\"commandAliases\">{$CMD_ALIASES}</span>"
.replace("{$CMD_ALIASES}", escapeHtml4(StringUtils.join(command.getAliases(), ", "))));
}
sb.append(
"<br><span class=\"commandDescription\">{$CMD_DESC}</span></li>\r\n"
.replace("{$CMD_DESC}", escapeHtml4(command.getDescription().trim())));
return sb.toString();
}
@Override
public String getTitle()
{

View File

@ -1,18 +1,17 @@
package me.totalfreedom.totalfreedommod.httpd.module;
import java.io.File;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.banning.IndefiniteBanList;
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
import me.totalfreedom.totalfreedommod.admin.Admin;
public class Module_indefbans extends HTTPDModule
{
public Module_indefbans(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
public Module_indefbans(NanoHTTPD.HTTPSession session)
{
super(plugin, session);
super(session);
}
@Override

View File

@ -1,7 +1,6 @@
package me.totalfreedom.totalfreedommod.httpd.module;
import java.util.Set;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.httpd.HTMLGenerationTools;
import me.totalfreedom.totalfreedommod.httpd.HTTPDPageBuilder;
@ -11,9 +10,9 @@ import org.reflections.Reflections;
public class Module_index extends HTTPDModule
{
public Module_index(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
public Module_index(NanoHTTPD.HTTPSession session)
{
super(plugin, session);
super(session);
}
@Override
@ -32,7 +31,7 @@ public class Module_index extends HTTPDModule
Set<Class<? extends HTTPDModule>> moduleClasses = r.getSubTypesOf(HTTPDModule.class);
for (Class c : moduleClasses)
for (Class<?> c : moduleClasses)
{
String name = c.getSimpleName().replace("Module_", "");

View File

@ -2,9 +2,9 @@ package me.totalfreedom.totalfreedommod.httpd.module;
import java.util.Collection;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -16,7 +16,7 @@ public class Module_list extends HTTPDModule
public Module_list(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
{
super(plugin, session);
super(session);
}
@Override

View File

@ -7,13 +7,13 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.httpd.HTMLGenerationTools;
import me.totalfreedom.totalfreedommod.httpd.HTTPDPageBuilder;
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Response;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringEscapeUtils;
@ -31,7 +31,13 @@ public class Module_logfile extends HTTPDModule
public Module_logfile(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
{
super(plugin, session);
super(session);
}
private static String getArg(String[] args, int index)
{
String out = (args.length == index + 1 ? args[index] : null);
return (out == null ? null : (out.trim().isEmpty() ? null : out.trim()));
}
@Override
@ -169,6 +175,40 @@ public class Module_logfile extends HTTPDModule
return entry != null && entry.isActive();
}
private enum ModuleMode
{
LIST("list"),
DOWNLOAD("download"),
INVALID(null);
//
private final String modeName;
ModuleMode(String modeName)
{
this.modeName = modeName;
}
public static ModuleMode getMode(String needle)
{
for (ModuleMode mode : values())
{
final String haystack = mode.toString();
if (haystack != null && haystack.equalsIgnoreCase(needle))
{
return mode;
}
}
return INVALID;
}
@Override
public String toString()
{
return this.modeName;
}
}
private static class LogFileTransferException extends Exception
{
@ -197,44 +237,4 @@ public class Module_logfile extends HTTPDModule
return response;
}
}
private static String getArg(String[] args, int index)
{
String out = (args.length == index + 1 ? args[index] : null);
return (out == null ? null : (out.trim().isEmpty() ? null : out.trim()));
}
private static enum ModuleMode
{
LIST("list"),
DOWNLOAD("download"),
INVALID(null);
//
private final String modeName;
private ModuleMode(String modeName)
{
this.modeName = modeName;
}
@Override
public String toString()
{
return this.modeName;
}
public static ModuleMode getMode(String needle)
{
for (ModuleMode mode : values())
{
final String haystack = mode.toString();
if (haystack != null && haystack.equalsIgnoreCase(needle))
{
return mode;
}
}
return INVALID;
}
}
}

View File

@ -1,9 +1,9 @@
package me.totalfreedom.totalfreedommod.httpd.module;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -15,7 +15,7 @@ public class Module_players extends HTTPDModule
public Module_players(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
{
super(plugin, session);
super(session);
}
@Override

View File

@ -2,17 +2,17 @@ package me.totalfreedom.totalfreedommod.httpd.module;
import java.io.File;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
import me.totalfreedom.totalfreedommod.punishments.PunishmentList;
import me.totalfreedom.totalfreedommod.admin.Admin;
public class Module_punishments extends HTTPDModule
{
public Module_punishments(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
{
super(plugin, session);
super(session);
}
@Override

View File

@ -14,6 +14,7 @@ import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.httpd.HTMLGenerationTools;
import me.totalfreedom.totalfreedommod.httpd.HTTPDPageBuilder;
@ -22,7 +23,6 @@ import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Method;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Response;
import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringEscapeUtils;
@ -48,7 +48,13 @@ public class Module_schematic extends HTTPDModule
public Module_schematic(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
{
super(plugin, session);
super(session);
}
private static String getArg(String[] args, int index)
{
String out = (args.length == index + 1 ? args[index] : null);
return (out == null ? null : (out.trim().isEmpty() ? null : out.trim()));
}
@Override
@ -285,6 +291,41 @@ public class Module_schematic extends HTTPDModule
return ((adminEntry != null && adminEntry.isActive()) || data != null && data.isMasterBuilder());
}
private enum ModuleMode
{
LIST("list"),
UPLOAD("upload"),
DOWNLOAD("download"),
INVALID(null);
//
private final String modeName;
ModuleMode(String modeName)
{
this.modeName = modeName;
}
public static ModuleMode getMode(String needle)
{
for (ModuleMode mode : values())
{
final String haystack = mode.toString();
if (haystack != null && haystack.equalsIgnoreCase(needle))
{
return mode;
}
}
return INVALID;
}
@Override
public String toString()
{
return this.modeName;
}
}
private static class SchematicTransferException extends Exception
{
@ -313,45 +354,4 @@ public class Module_schematic extends HTTPDModule
return response;
}
}
private static String getArg(String[] args, int index)
{
String out = (args.length == index + 1 ? args[index] : null);
return (out == null ? null : (out.trim().isEmpty() ? null : out.trim()));
}
private static enum ModuleMode
{
LIST("list"),
UPLOAD("upload"),
DOWNLOAD("download"),
INVALID(null);
//
private final String modeName;
ModuleMode(String modeName)
{
this.modeName = modeName;
}
@Override
public String toString()
{
return this.modeName;
}
public static ModuleMode getMode(String needle)
{
for (ModuleMode mode : values())
{
final String haystack = mode.toString();
if (haystack != null && haystack.equalsIgnoreCase(needle))
{
return mode;
}
}
return INVALID;
}
}
}