Example usage for com.liferay.portal.kernel.util ArrayUtil exists

List of usage examples for com.liferay.portal.kernel.util ArrayUtil exists

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util ArrayUtil exists.

Prototype

public static <T> boolean exists(T[] array, Predicate<T> predicate) 

Source Link

Usage

From source file:com.liferay.frontend.js.loader.modules.extender.internal.JSLoaderModule.java

License:Open Source License

protected String generateMapsConfiguration(String configuration, String[] exportJSSubmodules) {

    boolean exportAll = ArrayUtil.contains(exportJSSubmodules, StringPool.STAR);

    JSONObject mapsConfigurationJSONObject = new JSONObject();

    JSONObject configurationJSONObject = new JSONObject("{" + configuration + "}");

    JSONArray namesJSONArray = configurationJSONObject.names();

    for (int i = 0; i < namesJSONArray.length(); i++) {
        String name = (String) namesJSONArray.get(i);

        int x = name.indexOf('/');

        String moduleRootPath = name.substring(0, x + 1);

        String submodulePath = name.substring(x + 1);

        int y = submodulePath.indexOf('/');

        if (y == -1) {
            continue;
        }/*  w w w.  ja  v  a 2 s .  c  o  m*/

        final String submoduleName = submodulePath.substring(0, y);

        PredicateFilter<String> wildcardPredicateFilter = new PredicateFilter<String>() {

            public boolean filter(String item) {
                return _matchesWildcard(submoduleName, item);
            }

        };

        if (exportAll || ArrayUtil.exists(exportJSSubmodules, wildcardPredicateFilter)) {

            mapsConfigurationJSONObject.put(submoduleName, moduleRootPath.concat(submoduleName));
        }
    }

    return mapsConfigurationJSONObject.toString();
}