mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-07-01 04:26:42 +00:00
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!!
51 lines
1.3 KiB
Java
51 lines
1.3 KiB
Java
package me.totalfreedom.totalfreedommod.httpd;
|
|
|
|
import java.util.Collection;
|
|
import java.util.Map;
|
|
import static org.apache.commons.lang3.StringEscapeUtils.escapeHtml4;
|
|
|
|
public class HTMLGenerationTools
|
|
{
|
|
public static String paragraph(String data)
|
|
{
|
|
return "<p>" + escapeHtml4(data) + "</p>\r\n";
|
|
}
|
|
|
|
public static String heading(String data, int level)
|
|
{
|
|
return "<h" + level + ">" + escapeHtml4(data) + "</h" + level + ">\r\n";
|
|
}
|
|
|
|
public static <K, V> String list(Map<K, V> map)
|
|
{
|
|
StringBuilder output = new StringBuilder();
|
|
|
|
output.append("<ul>\r\n");
|
|
|
|
for (Map.Entry<K, V> entry : map.entrySet())
|
|
{
|
|
output.append("<li>").append(escapeHtml4(entry.getKey().toString() + " = " + entry.getValue().toString())).append("</li>\r\n");
|
|
}
|
|
|
|
output.append("</ul>\r\n");
|
|
|
|
return output.toString();
|
|
}
|
|
|
|
public static <T> String list(Collection<T> list)
|
|
{
|
|
StringBuilder output = new StringBuilder();
|
|
|
|
output.append("<ul>\r\n");
|
|
|
|
for (T entry : list)
|
|
{
|
|
output.append("<li>").append(escapeHtml4(entry.toString())).append("</li>\r\n");
|
|
}
|
|
|
|
output.append("</ul>\r\n");
|
|
|
|
return output.toString();
|
|
}
|
|
}
|