Example usage for org.apache.commons.collections4 MapUtils getInteger

List of usage examples for org.apache.commons.collections4 MapUtils getInteger

Introduction

In this page you can find the example usage for org.apache.commons.collections4 MapUtils getInteger.

Prototype

public static <K> Integer getInteger(final Map<? super K, ?> map, final K key, final Integer defaultValue) 

Source Link

Document

Looks up the given key in the given map, converting the result into an integer, using the default value if the the conversion fails.

Usage

From source file:org.apache.ofbiz.widget.renderer.Paginator.java

/**
 * @param context//w  w  w .  j a v  a  2 s.c  om
 * @param viewIndexName
 * @param defaultValue
 * @return value of viewIndexName in context map (as an int) or return defaultValue
 */
public static Integer getViewIndex(final Map<String, ? extends Object> context, final String viewIndexName,
        final int defaultValue) {
    return MapUtils.getInteger(context, viewIndexName, defaultValue);
}

From source file:org.apache.ofbiz.widget.renderer.Paginator.java

/**
 * @param context/*from w w w.  java  2s  .  co m*/
 * @param viewSizeName
 * @return value of viewSizeName in context map (as an int) or return 
 *         default value from widget.properties
 */
public static Integer getViewSize(Map<String, ? extends Object> context, String viewSizeName) {
    int defaultSize = UtilProperties.getPropertyAsInteger("widget", "widget.form.defaultViewSize", 20);
    if (context.containsKey(viewSizeName)) {
        return MapUtils.getInteger(context, viewSizeName, defaultSize);
    }
    return defaultSize;
}