MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / mapObject

Method mapObject

java/src/org/openqa/selenium/json/JsonOutput.java:607–635  ·  view source on GitHub ↗

Convert the specified Java object via accessors that conform to the JavaBean specification. @param toConvert Java object to be converted @param maxDepth maximum depth of nested object traversal @param depthRemaining allowed traversal depth remaining @throws JsonException if allowed depth ha

(Object toConvert, int maxDepth, int depthRemaining)

Source from the content-addressed store, hash-verified

605 * @throws JsonException if allowed depth has been reached
606 */
607 private void mapObject(Object toConvert, int maxDepth, int depthRemaining) {
608 if (toConvert instanceof Class) {
609 write(((Class<?>) toConvert).getName());
610 return;
611 }
612
613 // Raw object via reflection? Nope, not needed
614 beginObject();
615 for (SimplePropertyDescriptor pd :
616 SimplePropertyDescriptor.getPropertyDescriptors(toConvert.getClass())) {
617
618 // Only include methods not on java.lang.Object to stop things being super-noisy
619 Function<Object, @Nullable Object> readMethod = pd.getReadMethod();
620 if (readMethod == null) {
621 continue;
622 }
623
624 if (!writeClassName && "class".equals(pd.getName())) {
625 continue;
626 }
627
628 Object value = readMethod.apply(toConvert);
629 if (!Optional.empty().equals(value)) {
630 name(pd.getName());
631 write0(value, maxDepth, depthRemaining - 1);
632 }
633 }
634 endObject();
635 }
636
637 /** Defines to common behavior of JSON containers (objects and arrays). */
638 private abstract class Node {

Callers 1

resolveConverterMethod · 0.80

Calls 12

writeMethod · 0.95
beginObjectMethod · 0.95
nameMethod · 0.95
write0Method · 0.95
endObjectMethod · 0.95
getReadMethodMethod · 0.80
getNameMethod · 0.65
getClassMethod · 0.65
equalsMethod · 0.45
applyMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected