Class JsUtils
- java.lang.Object
-
- org.kie.workbench.common.dmn.webapp.kogito.marshaller.mapper.JsUtils
-
public class JsUtils extends Object
Utility class to provide generic methods used by all specific JSInterop classes
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <D> voidadd(jsinterop.base.JsArrayLike<D> jsArrayLike, D element)static <D,E extends D>
voidaddAll(jsinterop.base.JsArrayLike<D> jsArrayLike, E... elements)static <D> DfromAttributesMap(Map<QName,String> original)Extracts the otherAttributes property from a regular Java Map to a JavaScriptObject.static JSINamegetJSIName(String namespaceURI, String localPart, String prefix)static <D> jsinterop.base.JsArrayLike<D>getNativeArray()Helper method to create a new, emptyJsArrayLikestatic <D> jsinterop.base.JsArrayLike<D>getNativeElementsArray(jsinterop.base.JsArrayLike<D> original)Returns the originalJsArrayLikeor, ift the originalJsArrayLikeisnull, a new, empty onestatic StringgetTypeName(Object instance)static ObjectgetUnwrappedElement(Object original)static <D> jsinterop.base.JsArrayLike<D>getUnwrappedElementsArray(jsinterop.base.JsArrayLike<D> original)Returns aJsArrayLikewhere each element represents the unwrapped object (i.e. object.value) of the original one.static <D> DgetWrappedElement(Object value)static <D> DnewWrappedInstance()Returns a stub object with name and value attributesstatic <D> voidremove(jsinterop.base.JsArrayLike<D> jsArrayLike, int index)static <D> voidsetNameOnWrapped(D wrappedObject, JSIName name)Set the name attribute of the given wrappedDwith the json representation of the givenJSINamestatic <D,E>
voidsetValueOnWrapped(D wrappedObject, E value)Set the value attribute of the given wrappedDwith the json representation of valueEstatic Map<QName,String>toAttributesMap(Object original)Extracts the otherAttributes property from a JavaScriptObject to a regular Java Map.static <D> jsinterop.base.JsArrayLike<D>toJsArrayLike(List<D> list)static <D> List<D>toList(jsinterop.base.JsArrayLike<D> jsArrayLike)
-
-
-
Method Detail
-
add
public static <D> void add(jsinterop.base.JsArrayLike<D> jsArrayLike, D element)
-
addAll
public static <D,E extends D> void addAll(jsinterop.base.JsArrayLike<D> jsArrayLike, E... elements)
-
remove
public static <D> void remove(jsinterop.base.JsArrayLike<D> jsArrayLike, int index)
-
toList
public static <D> List<D> toList(jsinterop.base.JsArrayLike<D> jsArrayLike)
-
toJsArrayLike
public static <D> jsinterop.base.JsArrayLike<D> toJsArrayLike(List<D> list)
-
toAttributesMap
public static Map<QName,String> toAttributesMap(Object original)
Extracts the otherAttributes property from a JavaScriptObject to a regular Java Map.- Parameters:
original- js object to transform.- Returns:
- the populated
Map<QName, String>
-
fromAttributesMap
public static <D> D fromAttributesMap(Map<QName,String> original)
Extracts the otherAttributes property from a regular Java Map to a JavaScriptObject.- Parameters:
original- theMap<QName, String>to transform.- Returns:
- the populated JavaScriptObject
-
newWrappedInstance
public static <D> D newWrappedInstance()
Returns a stub object with name and value attributes- Returns:
-
setNameOnWrapped
public static <D> void setNameOnWrapped(D wrappedObject, JSIName name)Set the name attribute of the given wrappedDwith the json representation of the givenJSIName- Parameters:
wrappedObject-name-
-
setValueOnWrapped
public static <D,E> void setValueOnWrapped(D wrappedObject, E value)Set the value attribute of the given wrappedDwith the json representation of valueE- Parameters:
wrappedObject-value-
-
getNativeElementsArray
public static <D> jsinterop.base.JsArrayLike<D> getNativeElementsArray(jsinterop.base.JsArrayLike<D> original)
Returns the originalJsArrayLikeor, ift the originalJsArrayLikeisnull, a new, empty one- Type Parameters:
D-- Parameters:
original-- Returns:
-
getUnwrappedElementsArray
public static <D> jsinterop.base.JsArrayLike<D> getUnwrappedElementsArray(jsinterop.base.JsArrayLike<D> original)
Returns aJsArrayLikewhere each element represents the unwrapped object (i.e. object.value) of the original one. It the originalJsArrayLikeisnull, returns a new, empty one- Type Parameters:
D-- Parameters:
original-- Returns:
-
getWrappedElement
public static <D> D getWrappedElement(Object value)
-
getNativeArray
public static <D> jsinterop.base.JsArrayLike<D> getNativeArray()
Helper method to create a new, emptyJsArrayLike- Returns:
-
-