Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package io.appium.java_client.internal;
 import java.util.Map;
 import  org.openqa.selenium.WebElement;
import  org.openqa.selenium.remote.internal.JsonToWebElementConverter;
Reconstitutes WebElements from their JSON representation. Will recursively convert Lists and Maps to catch nested references. All other values pass through the converter unchanged.
public abstract class JsonToMobileElementConverter extends JsonToWebElementConverter {
	protected AppiumDriver<?> driver;
		this. = driver;
	public Object apply(Object result) {
		if (result instanceof Collection<?>) {
			Collection<?> results = (Collection<?>) result;
			return Lists.newArrayList(Iterables.transform(resultsthis));
		if (result instanceof Map<?, ?>) {
			Map<?, ?> resultAsMap = (Map<?, ?>) result;
			if (resultAsMap.containsKey("ELEMENT")) {
				return element;
else {
				return Maps.transformValues(resultAsMapthis);
		if (result instanceof Number) {
			if (result instanceof Float || result instanceof Double) {
				return ((Numberresult).doubleValue();
			return ((Numberresult).longValue();
		return result;
	protected abstract MobileElement newMobileElement(); //{
		//MobileElement toReturn = new MobileElement();
		//return toReturn;
New to GrepCode? Check out our FAQ X