All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lonelystorm.air.asset.util.AssetLibraryUtil Maven / Gradle / Ivy

Go to download

The LonelyStorm Air Asset library provides support to be able to compile SASS files at runtime.

There is a newer version: 0.1.8
Show newest version
package com.lonelystorm.air.asset.util;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import com.lonelystorm.air.asset.models.AssetLibrary;
import com.lonelystorm.air.asset.models.AssetTheme;
import com.lonelystorm.air.asset.services.LibraryResolver;

public class AssetLibraryUtil {

    private AssetLibraryUtil() {
    };

    public static Set categories(LibraryResolver resolver, String categories) {
        Set libraries = new HashSet<>();

        for (String category : split(categories)) {
            List library = resolver.findLibrariesByCategory(category);
            if (library != null) {
                libraries.addAll(library);
            }
        }

        return libraries;
    }

    public static Set themes(LibraryResolver resolver, Set libraries, String categories) {
        List splitCategories = split(categories);
        Set results = new HashSet<>();

        for (AssetLibrary library : libraries) {
            Set themes = library.getThemes();
            for (AssetTheme theme : themes) {
                for (String category : splitCategories) {
                    if (Arrays.asList(theme.getThemes()).contains(category)) {
                        results.add(theme);
                    }
                }
            }

        }

        return results;
    }

    public static List split(String text) {
        List parts = new ArrayList<>();

        if (text != null) {
            String[] split = text.split(",");
            for (String part : split) {
                parts.add(part.trim());
            }
        }

        return parts;
    }

    public static String include(String path, String extension) {
        return String.format("", path, extension);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy