aboutsummaryrefslogtreecommitdiff
path: root/src/esieequest/controller/Utils.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/esieequest/controller/Utils.java')
-rw-r--r--src/esieequest/controller/Utils.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/esieequest/controller/Utils.java b/src/esieequest/controller/Utils.java
new file mode 100644
index 0000000..139798c
--- /dev/null
+++ b/src/esieequest/controller/Utils.java
@@ -0,0 +1,40 @@
1package esieequest.controller;
2
3import java.util.Set;
4
5public class Utils {
6
7 /**
8 *
9 * @param elements
10 * the elements
11 * @param prefix
12 * the prefix of the list
13 * @param emptyText
14 * the text that will be returned if the Set is empty
15 * @return the list
16 */
17 public static String list(final Set<String> elements, final String prefix, final String emptyText) {
18 if (!elements.isEmpty()) {
19 return prefix + Utils.buildListString(elements) + ".";
20 }
21 return emptyText;
22 }
23
24 /**
25 * Builds a list in the form of a String from a given Set.
26 *
27 * @param elements
28 * the Set of Strings
29 *
30 * @return the list
31 */
32 private static String buildListString(final Set<String> elements) {
33 final StringBuilder list = new StringBuilder();
34 for (final String string : elements) {
35 list.append(" ").append(string);
36 }
37 return list.toString();
38 }
39
40}