All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openqa.selenium.devtools.v88.runtime.model.CallArgument Maven / Gradle / Ivy

package org.openqa.selenium.devtools.v88.runtime.model;

import org.openqa.selenium.Beta;
import org.openqa.selenium.json.JsonInput;

/**
 * Represents function call argument. Either remote object id `objectId`, primitive `value`,
 * unserializable primitive value or neither of (for undefined) them should be specified.
 */
public class CallArgument {

    private final java.util.Optional value;

    private final java.util.Optional unserializableValue;

    private final java.util.Optional objectId;

    public CallArgument(java.util.Optional value, java.util.Optional unserializableValue, java.util.Optional objectId) {
        this.value = value;
        this.unserializableValue = unserializableValue;
        this.objectId = objectId;
    }

    /**
     * Primitive value or serializable javascript object.
     */
    public java.util.Optional getValue() {
        return value;
    }

    /**
     * Primitive value which can not be JSON-stringified.
     */
    public java.util.Optional getUnserializableValue() {
        return unserializableValue;
    }

    /**
     * Remote object handle.
     */
    public java.util.Optional getObjectId() {
        return objectId;
    }

    private static CallArgument fromJson(JsonInput input) {
        java.util.Optional value = java.util.Optional.empty();
        java.util.Optional unserializableValue = java.util.Optional.empty();
        java.util.Optional objectId = java.util.Optional.empty();
        input.beginObject();
        while (input.hasNext()) {
            switch(input.nextName()) {
                case "value":
                    value = java.util.Optional.ofNullable(input.read(Object.class));
                    break;
                case "unserializableValue":
                    unserializableValue = java.util.Optional.ofNullable(input.read(org.openqa.selenium.devtools.v88.runtime.model.UnserializableValue.class));
                    break;
                case "objectId":
                    objectId = java.util.Optional.ofNullable(input.read(org.openqa.selenium.devtools.v88.runtime.model.RemoteObjectId.class));
                    break;
                default:
                    input.skipValue();
                    break;
            }
        }
        input.endObject();
        return new CallArgument(value, unserializableValue, objectId);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy