MCPcopy Create free account
hub / github.com/boxbeam/RedLib / serialize

Method serialize

src/redempt/redlib/itemutils/ItemSerializer.java:105–123  ·  view source on GitHub ↗
(Object o)

Source from the content-addressed store, hash-verified

103 }
104
105 public static Object serialize(Object o) {
106 if (o instanceof ConfigurationSerializable) {
107 Class<?> clazz = o.getClass();
108 return toJSON((ConfigurationSerializable) o, clazz);
109 } else if (o instanceof Map) {
110 Map map = (Map) o;
111 JSONMap json = new JSONMap();
112 map.forEach((k, v) -> {
113 json.put(k.toString(), serialize(v));
114 });
115 return json;
116 } else if (o instanceof List) {
117 List list = (List) o;
118 JSONList json = new JSONList();
119 list.stream().map(ItemSerializer::serialize).forEach(json::add);
120 return json;
121 }
122 return o;
123 }
124
125}

Callers 1

toJSONMethod · 0.95

Calls 6

toJSONMethod · 0.95
getClassMethod · 0.80
forEachMethod · 0.80
mapMethod · 0.80
toStringMethod · 0.65
streamMethod · 0.45

Tested by

no test coverage detected