com.lonelystorm.air.asset.models.AssetLibrary 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.models;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.Self;
import com.lonelystorm.air.asset.services.LibraryAdapterManager;
import com.lonelystorm.air.asset.util.LibraryConstants;
@Model(adaptables = Resource.class)
public class AssetLibrary extends Asset {
@Self
private Resource resource;
@Inject
private String[] categories;
@Inject
private LibraryAdapterManager libraryAdapterManager;
private Set themes;
public String[] getCategories() {
return categories.clone();
}
public Set getThemes() {
return Collections.unmodifiableSet(themes);
}
@PostConstruct
protected void construct() {
setPath(resource.getPath());
setSources(resource);
themes = new HashSet<>();
for (Resource child : resource.getChildren()) {
if (child.isResourceType(LibraryConstants.ASSET_THEME_TYPE_NAME)) {
AssetTheme theme = libraryAdapterManager.theme(child);
if (theme != null) {
themes.add(theme);
}
}
}
}
}