Module.java 2.52 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  org.apache.sling.api.resource.Resource
 *  org.apache.sling.api.resource.ResourceUtil
 *  org.apache.sling.api.resource.ValueMap
 */
package com.adobe.granite.contexthub.api;

import com.adobe.granite.contexthub.impl.ClientLib;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceUtil;
import org.apache.sling.api.resource.ValueMap;

/*
 * This class specifies class file version 49.0 but uses Java 6 signatures.  Assumed Java 6.
 */
public class Module {
    private boolean enabled;
    private String theme;
    private String name;
    private String resourceType;
    private ValueMap properties;
    private Resource resource;
    private String path;
    private Set<String> runModes;

    public Module(Resource resource) {
        this.resource = resource;
        this.path = resource.getPath();
        this.properties = ResourceUtil.getValueMap((Resource)resource);
        String[] runModesProperty = (String[])this.properties.get("runModes", String[].class);
        this.enabled = (Boolean)this.properties.get("enabled", (Object)false);
        this.name = (String)this.properties.get("moduleType", String.class);
        this.theme = (String)this.properties.get("theme", String.class);
        this.resourceType = resource.getResourceType();
        this.runModes = new TreeSet<String>();
        if (runModesProperty != null) {
            this.runModes.addAll(Arrays.asList(runModesProperty));
        }
    }

    public Set<String> getRunModes() {
        return this.runModes;
    }

    public boolean isEnabled() {
        return this.enabled;
    }

    public String getTheme() {
        return this.theme;
    }

    public String getName() {
        return this.name;
    }

    public String getResourceType() {
        return this.resourceType;
    }

    public ValueMap getProperties() {
        return this.properties;
    }

    public Resource getResource() {
        return this.resource;
    }

    public String getPath() {
        return this.path;
    }

    public List<String> getCategories() {
        ArrayList<String> clientLibs = new ArrayList<String>();
        clientLibs.add(ClientLib.buildClientlibName("module", this.getName()));
        clientLibs.add(ClientLib.buildClientlibName("module", this.getName(), "override"));
        return clientLibs;
    }
}