io.appium.java_client.flutter.commands.LongPressParameter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-client Show documentation
Show all versions of java-client Show documentation
Java client for Appium Mobile Webdriver
The newest version!
package io.appium.java_client.flutter.commands;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.internal.Require;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
@Accessors(chain = true)
@Setter
@Getter
public class LongPressParameter extends FlutterCommandParameter {
private WebElement element;
private Point offset;
@Override
public Map toJson() {
Require.precondition(element != null || offset != null,
"Must supply a valid element or offset to perform flutter gesture event");
Map params = new HashMap<>();
Optional.ofNullable(element).ifPresent(element -> params.put("origin", element));
Optional.ofNullable(offset).ifPresent(offset ->
params.put("offset", Map.of("x", offset.getX(), "y", offset.getY())));
return Collections.unmodifiableMap(params);
}
}