Enum Class NumberHelper
- All Implemented Interfaces:
com.github.jknack.handlebars.Helper<Object>,Serializable,Comparable<NumberHelper>,Constable
public enum NumberHelper
extends Enum<NumberHelper>
implements com.github.jknack.handlebars.Helper<Object>
Commons number function helpers.
- Author:
- https://github.com/Jarlakxen
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionYou can use the isEven helper to return a value only if the first argument is even.You can use the isOdd helper to return a value only if the first argument is odd.You can use the stripes helper to return different value if the passed argument is odd or even. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidregister(com.github.jknack.handlebars.Handlebars handlebars) Register all the number helpers.voidregisterHelper(com.github.jknack.handlebars.Handlebars handlebars) Register the helper in a handlebars instance.static NumberHelperReturns the enum constant of this class with the specified name.static NumberHelper[]values()Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class java.lang.Enum
compareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Enum Constant Details
-
isEven
You can use the isEven helper to return a value only if the first argument is even. Otherwise return null.
If value is 2, the output will be "leftBox".<li class="{{isEven value "leftBox"}}"> -
isOdd
You can use the isOdd helper to return a value only if the first argument is odd. Otherwise return null.
If value is 3, the output will be "rightBox".<li class="{{isOdd value "rightBox"}}"> -
stripes
You can use the stripes helper to return different value if the passed argument is odd or even.
If value is 2, the output will be "row-even".<tr class="{{stripes value "row-even" "row-odd"}}">
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
apply
public Object apply(Object context, com.github.jknack.handlebars.Options options) throws IOException - Specified by:
applyin interfacecom.github.jknack.handlebars.Helper<Object>- Throws:
IOException
-
registerHelper
public void registerHelper(com.github.jknack.handlebars.Handlebars handlebars) Register the helper in a handlebars instance.- Parameters:
handlebars- A handlebars object. Required.
-
register
public static void register(com.github.jknack.handlebars.Handlebars handlebars) Register all the number helpers.- Parameters:
handlebars- The helper's owner. Required.
-