/** * Create an If statement and add it to this block * * @param aTest * {@link IJSExpression} to be tested to determine branching * @param aThen * "then" block content. May be <code>null</code>. * @return Newly generated conditional statement */ @Nonnull public JSConditional _if (@Nonnull final IJSExpression aTest, @Nullable final IHasJSCode aThen) { return addStatement (new JSConditional (aTest, aThen)); }
/** * Creates <tt>... else if(...) ...</tt> code. * * @param aBoolExp * The boolean expression * @return The conditional for the next "if" */ @Nonnull public JSConditional elseif (@Nonnull final IJSExpression aBoolExp) { return _else ()._if (aBoolExp); }
@Nonnull public static JSAnonymousFunction createFunctionIntVal (@Nullable final JSAnonymousFunction aValueCleanupFunc) { final JSAnonymousFunction aFuncIntVal = new JSAnonymousFunction (); final JSVar aVal = aFuncIntVal.param ("v"); // If string final JSBlock aIfString = aFuncIntVal.body ()._if (aVal.typeof ().eeq ("string"))._then (); if (aValueCleanupFunc != null) aIfString.assign (aVal, aValueCleanupFunc.invoke ().arg (aVal)); aIfString._return (JSGlobal.parseFloat (aVal)); // If number aFuncIntVal.body ()._if (aVal.typeof ().eeq ("number"))._then ()._return (aVal); // Assume 0 aFuncIntVal.body ()._return (0); return aFuncIntVal; }
/** * Create an If statement and add it to this block * * @param aTest * {@link IJSExpression} to be tested to determine branching * @param aThen * "then" block content. May be <code>null</code>. * @return Newly generated conditional statement */ @Nonnull public JSConditional _if (@Nonnull final IJSExpression aTest, @Nullable final IHasJSCode aThen) { return addStatement (new JSConditional (aTest, aThen)); }
/** * Creates <tt>... else if(...) ...</tt> code. * * @param aBoolExp * The boolean expression * @return The conditional for the next "if" */ @Nonnull public JSConditional elseif (@Nonnull final IJSExpression aBoolExp) { return _else ()._if (aBoolExp); }
/** * Create an If statement and add it to this block * * @param aTest * {@link IJSExpression} to be tested to determine branching * @return Newly generated conditional statement */ @Nonnull public JSConditional _if (@Nonnull final IJSExpression aTest) { return addStatement (new JSConditional (aTest)); }
/** * Create an If statement * * @param aTest * {@link IJSExpression} to be tested to determine branching * @param aThen * "then" block content. May be <code>null</code>. * @param aElse * "else" block content. May be <code>null</code>. */ public JSConditional (@Nonnull final IJSExpression aTest, @Nullable final IHasJSCode aThen, @Nullable final IHasJSCode aElse) { this (aTest, aThen); if (aElse != null) _else ().add (aElse); }
final JSBlock aJSDelOld = aJSBody._if (aOldChart)._then (); aJSDelOld.add (aOldChart.invoke ("destroy")); aJSDelOld.delete (aOldChart);
/** * Create an If statement and add it to this block * * @param aTest * {@link IJSExpression} to be tested to determine branching * @return Newly generated conditional statement */ @Nonnull public JSConditional _if (@Nonnull final IJSExpression aTest) { return addStatement (new JSConditional (aTest)); }
/** * Create an If statement * * @param aTest * {@link IJSExpression} to be tested to determine branching * @param aThen * "then" block content. May be <code>null</code>. * @param aElse * "else" block content. May be <code>null</code>. */ public JSConditional (@Nonnull final IJSExpression aTest, @Nullable final IHasJSCode aThen, @Nullable final IHasJSCode aElse) { this (aTest, aThen); if (aElse != null) _else ().add (aElse); }
/** * Create an If statement and add it to this block * * @param aTest * {@link IJSExpression} to be tested to determine branching * @param aThen * "then" block content. May be <code>null</code>. * @param aElse * "else" block content. May be <code>null</code>. * @return Newly generated conditional statement */ @Nonnull public JSConditional _if (@Nonnull final IJSExpression aTest, @Nullable final IHasJSCode aThen, @Nullable final IHasJSCode aElse) { return addStatement (new JSConditional (aTest, aThen, aElse)); }
/** * Create an If statement and add it to this block * * @param aTest * {@link IJSExpression} to be tested to determine branching * @param aThen * "then" block content. May be <code>null</code>. * @param aElse * "else" block content. May be <code>null</code>. * @return Newly generated conditional statement */ @Nonnull public JSConditional _if (@Nonnull final IJSExpression aTest, @Nullable final IHasJSCode aThen, @Nullable final IHasJSCode aElse) { return addStatement (new JSConditional (aTest, aThen, aElse)); }