Skip to content

Commit 5319871

Browse files
committed
updated pom and simplified Converters
1 parent ba564ad commit 5319871

File tree

2 files changed

+16
-22
lines changed

2 files changed

+16
-22
lines changed

pom.xml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@
3737
<goal>copy-dependencies</goal>
3838
</goals>
3939
<configuration>
40-
<outputDirectory>
41-
${project.build.directory}/libs
42-
</outputDirectory>
40+
<outputDirectory>${project.build.directory}/release/libs</outputDirectory>
41+
<includeScope>runtime</includeScope>
4342
</configuration>
4443
</execution>
4544
</executions>
@@ -58,7 +57,8 @@
5857
</mainClass>
5958
</manifest>
6059
</archive>
61-
<finalName>tools-v${project.version}</finalName>
60+
<outputDirectory>${project.build.directory}/release</outputDirectory>
61+
<finalName>sepia-core-tools-v${project.version}</finalName>
6262
</configuration>
6363
</plugin>
6464
</plugins>
@@ -120,6 +120,13 @@
120120
<artifactId>httpmime</artifactId>
121121
<version>4.5.3</version>
122122
</dependency>
123+
124+
<dependency>
125+
<groupId>junit</groupId>
126+
<artifactId>junit</artifactId>
127+
<version>4.12</version>
128+
<scope>test</scope>
129+
</dependency>
123130
</dependencies>
124131

125132
<developers>

src/main/java/net/b07z/sepia/server/core/tools/Converters.java

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -364,23 +364,13 @@ public static Map<String, String> json2HashMapStrStr(JSONObject jsonObject) {
364364
return params;
365365
}
366366
/**
367-
* Convert JSONObject to HashMap&lt;String,Object&gt; by transferring all TOP-LEVEL key-value pairs.
367+
* Convert JSONObject to HashMap&lt;String,Object&gt; by unchecked cast.
368368
* Nested JSONObjects remain what they are.
369369
* @param jsonObject - simple JSON object
370370
* @return HashMap&lt;String,String&gt; (can be empty)
371371
*/
372-
@SuppressWarnings("unchecked")
373372
public static Map<String, Object> json2HashMap(JSONObject jsonObject) {
374-
Map<String, Object> params = new HashMap<>();
375-
if (jsonObject == null) {
376-
return params;
377-
}else{
378-
for (Object entry : jsonObject.entrySet()) {
379-
Map.Entry<String, Object> entryObj = (Map.Entry<String, Object>) entry;
380-
params.put(entryObj.getKey(), entryObj.getValue());
381-
}
382-
}
383-
return params;
373+
return object2HashMapStrObj(jsonObject);
384374
}
385375

386376
/**
@@ -391,8 +381,7 @@ public static Map<String, Object> json2HashMap(JSONObject jsonObject) {
391381
@SuppressWarnings("unchecked")
392382
public static Map<String, Object> object2HashMapStrObj(Object input){
393383
try {
394-
Map<String, Object> output = (HashMap<String, Object>) input;
395-
return output;
384+
return (HashMap<String, Object>) input;
396385
}catch(Exception e){
397386
e.printStackTrace();
398387
return null;
@@ -406,8 +395,7 @@ public static Map<String, Object> object2HashMapStrObj(Object input){
406395
@SuppressWarnings("unchecked")
407396
public static List<Object> object2ArrayListObj(Object input){
408397
try {
409-
List<Object> output = (ArrayList<Object>) input;
410-
return output;
398+
return (ArrayList<Object>) input;
411399
}catch(Exception e){
412400
e.printStackTrace();
413401
return null;
@@ -421,8 +409,7 @@ public static List<Object> object2ArrayListObj(Object input){
421409
@SuppressWarnings("unchecked")
422410
public static List<String> object2ArrayListStr(Object input){
423411
try {
424-
List<String> output = (ArrayList<String>) input;
425-
return output;
412+
return (ArrayList<String>) input;
426413
}catch(Exception e){
427414
e.printStackTrace();
428415
return null;

0 commit comments

Comments
 (0)