Package jsinterop.base
Class Js
java.lang.Object
jsinterop.base.Js
Utilities to provide access to JavaScript language constructs that are not available in pure
Java.
Note that this class avoids providing replacements for stuff that is already available via a pure Java or Elemental and enforce safe (runtime-checked) coding practices.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends @Nullable Object>
TandAlso(T obj1, T obj2) Applies JavaScript logical "and" operator (&&) on given objects.static JsArrayLike<@Nullable Object> static @Nullable Anystatic @Nullable Any[]static @Nullable JsArrayLike<@Nullable Object> asArrayLike(@Nullable Object obj) ReturnsJsArrayLikeview of provided array-like object.static booleanstatic bytestatic charstatic <T> JsConstructorFn<T> asConstructorFn(Class<T> clazz) static doublestatic floatstatic intstatic longstatic @Nullable JsPropertyMap<@Nullable Object> asPropertyMap(@Nullable Object obj) ReturnsJsPropertyMapview of provided object.static shortstatic Stringstatic <T extends @Nullable Object>
TPerforms checked cast to lefthand-side type.static booleancoerceToBoolean(@Nullable Object b) Coerces any object to boolean using!!operation.static doublecoerceToDouble(@Nullable Object d) Coerces any object to number using+operation.static intcoerceToInt(@Nullable Object d) Coerces any object to 32 bit signed number using|0operation.static voiddebugger()static JsPropertyMap<@Nullable Object> global()static booleanstatic booleanisTripleEqual(@Nullable Object o1, @Nullable Object o2) Returnstrueif two objects are same.static booleanstatic <T extends @Nullable Object>
TorElse(T obj1, T obj2) Applies JavaScript logical "or" operator (||) on given objects.static Stringstatic <T extends @Nullable Object>
TuncheckedCast(@Nullable Object obj) Performs unchecked cast to lefthand-side type.static @Nullable Object
-
Method Details
-
undefined
-
arguments
@JsProperty(namespace="<window>", name="arguments") public static JsArrayLike<@Nullable Object> arguments() -
debugger
@JsProperty(namespace="<window>", name="debugger") public static void debugger() -
typeof
-
global
-
asConstructorFn
-
asAny
-
asPropertyMap
ReturnsJsPropertyMapview of provided object. -
asArrayLike
ReturnsJsArrayLikeview of provided array-like object. -
asArray
-
asString
-
asBoolean
-
asDouble
-
asFloat
-
asLong
-
asInt
-
asShort
-
asChar
-
asByte
-
cast
Performs checked cast to lefthand-side type.This is useful for cases when Java won't allow you otherwise, like casting from a native interface to a final Java class (like String).
-
uncheckedCast
Performs unchecked cast to lefthand-side type.This method exists in order to lie to the type system, it is not an optimization. You should *ALWAYS* prefer regular casting over this which also optimizes for production. Using this method can leak incorrect types to the rest of the system which will result in hard to debug problems.
-
andAlso
Applies JavaScript logical "and" operator (&&) on given objects. -
orElse
Applies JavaScript logical "or" operator (||) on given objects. -
isTruthy
-
isFalsy
-
isTripleEqual
Returnstrueif two objects are same.This method mostly behaves similar to Java
==operator except that it doesn't returntruefornull==undefinedcomparison. -
coerceToDouble
Coerces any object to number using+operation. -
coerceToInt
Coerces any object to 32 bit signed number using|0operation. -
coerceToBoolean
Coerces any object to boolean using!!operation.
-