Package io.appium.java_client.internal
Class CapabilityHelpers
- java.lang.Object
-
- io.appium.java_client.internal.CapabilityHelpers
-
public class CapabilityHelpers extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringAPPIUM_PREFIX
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> @Nullable TgetCapability(org.openqa.selenium.Capabilities caps, java.lang.String name, java.lang.Class<T> expectedType)Helper that is used for capability values retrieval.static @Nullable java.lang.DoubletoDouble(java.lang.Object value)Converts generic capability value to double.static @Nullable java.time.DurationtoDuration(java.lang.Object value)Converts generic capability value to duration.static @Nullable java.time.DurationtoDuration(java.lang.Object value, java.util.function.Function<java.lang.Long,java.time.Duration> converter)Converts generic capability value to duration.static @Nullable java.lang.IntegertoInteger(java.lang.Object value)Converts generic capability value to integer.static @Nullable java.lang.LongtoLong(java.lang.Object value)Converts generic capability value to long.static @Nullable java.lang.BooleantoSafeBoolean(java.lang.Object value)Converts generic capability value to boolean without throwing exceptions.static @Nullable java.net.URLtoUrl(java.lang.Object value)Converts generic capability value to a url.
-
-
-
Field Detail
-
APPIUM_PREFIX
public static final java.lang.String APPIUM_PREFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
getCapability
public static <T> @Nullable T getCapability(org.openqa.selenium.Capabilities caps, java.lang.String name, java.lang.Class<T> expectedType)Helper that is used for capability values retrieval. Supports both prefixed W3C and "classic" capability names.- Type Parameters:
T- The corresponding capability type.- Parameters:
caps- driver caps objectname- capability nameexpectedType- the expected capability type- Returns:
- The retrieved capability value or null if the cap either not present has an unexpected type
-
toSafeBoolean
public static @Nullable java.lang.Boolean toSafeBoolean(java.lang.Object value)
Converts generic capability value to boolean without throwing exceptions.- Parameters:
value- The capability value.- Returns:
- null is the passed value is null otherwise the converted value.
-
toInteger
public static @Nullable java.lang.Integer toInteger(java.lang.Object value)
Converts generic capability value to integer.- Parameters:
value- The capability value.- Returns:
- null is the passed value is null otherwise the converted value.
- Throws:
java.lang.NumberFormatException- If the given value cannot be parsed to a valid integer.
-
toLong
public static @Nullable java.lang.Long toLong(java.lang.Object value)
Converts generic capability value to long.- Parameters:
value- The capability value.- Returns:
- null is the passed value is null otherwise the converted value.
- Throws:
java.lang.NumberFormatException- If the given value cannot be parsed to a valid long.
-
toDouble
public static @Nullable java.lang.Double toDouble(java.lang.Object value)
Converts generic capability value to double.- Parameters:
value- The capability value.- Returns:
- null is the passed value is null otherwise the converted value.
- Throws:
java.lang.NumberFormatException- If the given value cannot be parsed to a valid long.
-
toDuration
public static @Nullable java.time.Duration toDuration(java.lang.Object value)
Converts generic capability value to duration. The value is assumed to be measured in milliseconds.- Parameters:
value- The capability value.- Returns:
- null is the passed value is null otherwise the converted value.
- Throws:
java.lang.NumberFormatException- If the given value cannot be parsed to a valid number.
-
toDuration
public static @Nullable java.time.Duration toDuration(java.lang.Object value, java.util.function.Function<java.lang.Long,java.time.Duration> converter)Converts generic capability value to duration.- Parameters:
value- The capability value.converter- Converts the numeric value to a Duration instance.- Returns:
- null is the passed value is null otherwise the converted value.
- Throws:
java.lang.NumberFormatException- If the given value cannot be parsed to a valid number.
-
toUrl
public static @Nullable java.net.URL toUrl(java.lang.Object value)
Converts generic capability value to a url.- Parameters:
value- The capability value.- Returns:
- null is the passed value is null otherwise the converted value.
- Throws:
java.lang.IllegalArgumentException- If the given value cannot be parsed to a valid url.
-
-