List of usage examples for jdk.nashorn.internal.runtime ScriptFunction toSource
public final String toSource()
From source file:org.wso2.carbon.identity.application.authentication.framework.config.model.graph.SerializableJsFunction.java
License:Open Source License
/** * This will return the converted SerializableJsFunction if the given ScriptObjectMirror is a function. * @param scriptObjectMirror/* w w w . j a v a2 s .co m*/ * @return null if the ScriptObjectMirror is not a function. */ public static SerializableJsFunction toSerializableForm(ScriptObjectMirror scriptObjectMirror) { if (!scriptObjectMirror.isFunction()) { return null; } //TODO try to get rid of ScriptFunction Object unwrapped = ScriptUtils.unwrap(scriptObjectMirror); if (unwrapped instanceof ScriptFunction) { ScriptFunction scriptFunction = (ScriptFunction) unwrapped; boolean isFunction = scriptObjectMirror.isFunction(); String source = scriptFunction.toSource(); return new SerializableJsFunction(source, isFunction); } else { return new SerializableJsFunction(unwrapped.toString(), true); } }