Class ConverterFunctions
java.lang.Object
org.openqa.selenium.bidi.ConverterFunctions
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.openqa.selenium.json.JsonThe sharedJsonevery generated BiDi type is decoded through, including viafromMap(Class)and — throughCommand'sType-based constructor — every plain command result too, so a command and an event never disagree on how strictly to accept the same wire shape. -
Method Summary
Modifier and TypeMethodDescriptionReturns a function that deserializes aMap<String, Object>event payload (or a nested union variant, already parsed into a map) into an instance oftypeviaJson.convert(Object, Type)— the same single-round-trip primitivemap(String, Type)uses, rather than a second hand-rolledtoJson/JsonInputpair.Build aCommandresult mapper for the common case where the useful value is a single field of the response'sresultobject.
-
Field Details
-
JSON
public static final org.openqa.selenium.json.Json JSONThe sharedJsonevery generated BiDi type is decoded through, including viafromMap(Class)and — throughCommand'sType-based constructor — every plain command result too, so a command and an event never disagree on how strictly to accept the same wire shape. AddsStrictLongCoercer/StrictStringCoercer/StrictNumberCoercer(each rejects a value of the wrong JSON type for a String/integer/number field, instead of silently converting it — e.g. a numericurlor a quotedtimeOrigin) andStaticInitializerCoercerahead ofEnumCoercer(so a generated enum's exact-matchfromJsonruns, not the case-insensitive default) — all scoped to this instance only.
-
-
Method Details
-
map
Build aCommandresult mapper for the common case where the useful value is a single field of the response'sresultobject.The returned function is applied to a command's
resultvalue, whichConnectionhas already parsed into aMap<String, Object>. It readskeyNamefrom that map and deserializes it totypeOfXviaJson.convert(Object, Type), without re-parsing any JSON text. Both theresultand the field are required: a missingresultor anull/absent field is an error.- Parameters:
keyName- the field to read from the command'sresultobjecttypeOfX- the type to deserialize that field to (class orTypeToken)
-
fromMap
Returns a function that deserializes aMap<String, Object>event payload (or a nested union variant, already parsed into a map) into an instance oftypeviaJson.convert(Object, Type)— the same single-round-trip primitivemap(String, Type)uses, rather than a second hand-rolledtoJson/JsonInputpair.
-