19 package org.turro.visual;
22 import java.io.IOException;
23 import java.util.HashMap;
24 import java.util.function.Consumer;
25 import org.turro.elephant.context.ElephantContext;
26 import org.turro.file.CachedFileContent;
27 import org.turro.file.Document;
28 import org.turro.log.WebLoggers;
29 import org.turro.reflection.JSONSerializer;
39 private static CachedFileContent<JsonVisualConstraints> CACHED = CachedFileContent.<
JsonVisualConstraints>instance();
42 File file = Document.from(convert(visualFile)).document();
43 return CACHED.constructor(() -> {
46 save(visualFile, lvc);
50 JSONSerializer ser =
new JSONSerializer(
true);
52 }
catch (IOException ex) {
56 }).
load(visualFile, file);
61 JSONSerializer ser =
new JSONSerializer(jvc,
true);
62 Document.from(convert(visualFile)).content(ser.toJson());
63 }
catch (IOException ex) {
64 WebLoggers.info(JsonVisualConstraints.class).exception(ex).log();
68 private static String convert(String visualFile) {
69 if(!visualFile.contains(
"/")) {
70 visualFile =
"/WEB-INF/elephant/conf/visuals/json-" + visualFile +
"-visual.json";
72 return ElephantContext.getRealPath(visualFile);
static WebLoggers severe(Object entity)
WebLoggers exception(Throwable throwable)
static JsonVisualConstraints load(String visualFile, Consumer< JsonVisualConstraints > defaults)