com.lonelystorm.air.asset.util.AssetLibraryUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of air-asset Show documentation
Show all versions of air-asset Show documentation
The LonelyStorm Air Asset library provides support to be able to compile SASS files at runtime.
The 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);
}
}