MCPcopy Create free account
hub / github.com/apache/solr / writeMap

Method writeMap

solr/core/src/java/org/apache/solr/core/PluginInfo.java:195–226  ·  view source on GitHub ↗
(EntryWriter ew)

Source from the content-addressed store, hash-verified

193 }
194
195 @Override
196 @SuppressWarnings({"unchecked", "rawtypes"})
197 public void writeMap(EntryWriter ew) throws IOException {
198 // Direct forEach(ew::putNoEx) does not work: attributes is declared Map<String, String> but
199 // the PluginInfo(String, Map<String, Object>) constructor assigns it via raw types, so values
200 // may not be Strings. The bridge method generated for forEach would CCE on non-String values.
201 new NamedList<>(attributes).writeMap(ew);
202 if (initArgs != null) {
203 initArgs.asMap(3).forEach((k, v) -> ew.putNoEx((String) k, v));
204 }
205 if (children == null || children.isEmpty()) {
206 return;
207 }
208
209 Map<String, Object> childrenGrouped = new LinkedHashMap<>();
210 for (PluginInfo child : children) {
211 Object old = childrenGrouped.get(child.name);
212 if (old == null) {
213 childrenGrouped.put(child.name, child);
214 } else if (old instanceof List list) {
215 list.add(child);
216 } else {
217 List<Object> l = new ArrayList<>();
218 l.add(old);
219 l.add(child);
220 childrenGrouped.put(child.name, l);
221 }
222 }
223 for (Map.Entry<String, Object> entry : childrenGrouped.entrySet()) {
224 ew.put(entry.getKey(), entry.getValue());
225 }
226 }
227
228 /**
229 * Filter children by type

Callers

nothing calls this directly

Calls 11

putNoExMethod · 0.80
writeMapMethod · 0.65
getMethod · 0.65
putMethod · 0.65
addMethod · 0.65
getKeyMethod · 0.65
getValueMethod · 0.65
forEachMethod · 0.45
asMapMethod · 0.45
isEmptyMethod · 0.45
entrySetMethod · 0.45

Tested by

no test coverage detected