Skip to content

Commit

Permalink
Merge pull request alibaba#167 from LQZYC/master
Browse files Browse the repository at this point in the history
移除对fastjson的依赖
  • Loading branch information
SeanCai authored Nov 7, 2017
2 parents 1d3fe11 + 1ef434c commit 17c813b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
7 changes: 1 addition & 6 deletions p3c-pmd/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,7 @@
<artifactId>pmd-test</artifactId>
<version>${pmd.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.9</version>
</dependency>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
import java.util.Map;
import java.util.Properties;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

/**
* @author changle.lq
Expand All @@ -47,13 +48,17 @@ private static Properties initProperties() {

@Override
public List<String> getNameList(String className, String name) {
return JSON.parseArray((String)PROPERTIES.get(className + SEPARATOR + name), String.class);
Gson gson = new Gson();
return gson.fromJson((String)PROPERTIES.get(className + SEPARATOR + name),
new TypeToken<List<String>>() {}.getType());
}

@Override
public <K, V> Map<K, V> getNameMap(String className, String name, Class<K> kClass, Class<V> vClass) {
return JSON.parseObject((String)PROPERTIES.get(className + SEPARATOR + name),
new TypeReference<Map<K, V>>(kClass, vClass) {});
Gson gson = new Gson();
return gson.fromJson((String)PROPERTIES.get(className + SEPARATOR + name),
new TypeToken<Map<K, V>>() {
}.getType());
}

private static class LinkedProperties extends Properties {
Expand Down

0 comments on commit 17c813b

Please sign in to comment.