77 */
88package org .seedstack .seed ;
99
10- import java .util .Collection ;
11- import java .util .Collections ;
12- import java .util .HashMap ;
13- import java .util .Map ;
14- import java .util .Objects ;
15- import java .util .Set ;
10+ import java .util .*;
1611import java .util .function .BiConsumer ;
1712
1813/**
@@ -39,7 +34,8 @@ private ClassConfiguration(Class<T> targetClass, Map<String, String> source) {
3934 * @return the class configuration object.
4035 */
4136 public static <T > ClassConfiguration <T > of (Class <T > targetClass , Map <String , String > source ) {
42- return new ClassConfiguration <T >(targetClass , source ) {};
37+ return new ClassConfiguration <T >(targetClass , source ) {
38+ };
4339 }
4440
4541 /**
@@ -55,7 +51,8 @@ public static <T> ClassConfiguration<T> of(Class<T> targetClass, String... keyVa
5551 for (int i = 0 ; i < keyValuePairs .length - 1 ; i += 2 ) {
5652 map .put (keyValuePairs [i ], keyValuePairs [i + 1 ]);
5753 }
58- return new ClassConfiguration <T >(targetClass , map ) {};
54+ return new ClassConfiguration <T >(targetClass , map ) {
55+ };
5956 }
6057
6158 /**
@@ -66,7 +63,8 @@ public static <T> ClassConfiguration<T> of(Class<T> targetClass, String... keyVa
6663 * @return the class configuration object.
6764 */
6865 public static <T > ClassConfiguration <T > empty (Class <T > targetClass ) {
69- return new ClassConfiguration <T >(targetClass , new HashMap <>()) {};
66+ return new ClassConfiguration <T >(targetClass , new HashMap <>()) {
67+ };
7068 }
7169
7270 /**
@@ -107,6 +105,22 @@ public String get(String key) {
107105 return map .get (key );
108106 }
109107
108+ /**
109+ * Returns the value of a particular key (or null of the key doesn't exist). Should the value contain comma (,)
110+ * separators, it is split into an array of values. Each array item is trimmed using {@link String#trim()}.
111+ *
112+ * @param key the key to retrieve the value of.
113+ * @return the split value or null.
114+ */
115+ public String [] getArray (String key ) {
116+ String s = map .get (key );
117+ if (s == null ) {
118+ return null ;
119+ } else {
120+ return Arrays .stream (s .split ("," )).map (String ::trim ).toArray (String []::new );
121+ }
122+ }
123+
110124 /**
111125 * Returns an unmodifiable set of all the keys.
112126 *
0 commit comments