|
|
|
@ -24,33 +24,60 @@ import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
|
|
|
|
|
|
|
|
|
|
public class CacheConfigSupport {
|
|
|
|
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
ObjectMapper jsonMapper = new ObjectMapper();
|
|
|
|
|
ObjectMapper yamlMapper = new ObjectMapper(new YAMLFactory());
|
|
|
|
|
|
|
|
|
|
public Map<String, CacheConfig> fromJSON(String content) throws IOException {
|
|
|
|
|
return mapper.readValue(content, new TypeReference<Map<String, CacheConfig>>() {});
|
|
|
|
|
return jsonMapper.readValue(content, new TypeReference<Map<String, CacheConfig>>() {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Map<String, CacheConfig> fromJSON(File file) throws IOException {
|
|
|
|
|
return mapper.readValue(file, new TypeReference<Map<String, CacheConfig>>() {});
|
|
|
|
|
return jsonMapper.readValue(file, new TypeReference<Map<String, CacheConfig>>() {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Map<String, CacheConfig> fromJSON(URL url) throws IOException {
|
|
|
|
|
return mapper.readValue(url, new TypeReference<Map<String, CacheConfig>>() {});
|
|
|
|
|
return jsonMapper.readValue(url, new TypeReference<Map<String, CacheConfig>>() {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Map<String, CacheConfig> fromJSON(Reader reader) throws IOException {
|
|
|
|
|
return mapper.readValue(reader, new TypeReference<Map<String, CacheConfig>>() {});
|
|
|
|
|
return jsonMapper.readValue(reader, new TypeReference<Map<String, CacheConfig>>() {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Map<String, CacheConfig> fromJSON(InputStream inputStream) throws IOException {
|
|
|
|
|
return mapper.readValue(inputStream, new TypeReference<Map<String, CacheConfig>>() {});
|
|
|
|
|
return jsonMapper.readValue(inputStream, new TypeReference<Map<String, CacheConfig>>() {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String toJSON(Map<String, CacheConfig> configs) throws IOException {
|
|
|
|
|
return mapper.writeValueAsString(configs);
|
|
|
|
|
return jsonMapper.writeValueAsString(configs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Map<String, CacheConfig> fromYAML(String content) throws IOException {
|
|
|
|
|
return yamlMapper.readValue(content, new TypeReference<Map<String, CacheConfig>>() {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Map<String, CacheConfig> fromYAML(File file) throws IOException {
|
|
|
|
|
return yamlMapper.readValue(file, new TypeReference<Map<String, CacheConfig>>() {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Map<String, CacheConfig> fromYAML(URL url) throws IOException {
|
|
|
|
|
return yamlMapper.readValue(url, new TypeReference<Map<String, CacheConfig>>() {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Map<String, CacheConfig> fromYAML(Reader reader) throws IOException {
|
|
|
|
|
return yamlMapper.readValue(reader, new TypeReference<Map<String, CacheConfig>>() {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Map<String, CacheConfig> fromYAML(InputStream inputStream) throws IOException {
|
|
|
|
|
return yamlMapper.readValue(inputStream, new TypeReference<Map<String, CacheConfig>>() {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String toYAML(Map<String, CacheConfig> configs) throws IOException {
|
|
|
|
|
return yamlMapper.writeValueAsString(configs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|