IndexRule.java 1.63 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.google.common.collect.ImmutableMap
 *  org.apache.sling.api.resource.PersistenceException
 *  org.apache.sling.api.resource.Resource
 *  org.apache.sling.api.resource.ResourceResolver
 */
package com.adobe.cq.mobile.index.impl.builder;

import com.adobe.cq.mobile.index.impl.builder.PropertyDefinition;
import com.google.common.collect.ImmutableMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;

public class IndexRule {
    String primaryType;
    List<? extends PropertyDefinition> propertyDefinitions;

    public IndexRule(String primaryType, List<? extends PropertyDefinition> propDef) {
        this.primaryType = primaryType;
        this.propertyDefinitions = propDef;
    }

    public String primaryType() {
        return this.primaryType;
    }

    public List<? extends PropertyDefinition> propertyDefinition() {
        return this.propertyDefinitions;
    }

    public void build(Resource resource) throws PersistenceException {
        ResourceResolver resolver = resource.getResourceResolver();
        Resource primaryTypeNode = resolver.create(resource, this.primaryType, new HashMap());
        Resource propertiesNode = resolver.create(primaryTypeNode, "properties", (Map)ImmutableMap.of((Object)"jcr:primaryType", (Object)"nt:unstructured"));
        for (PropertyDefinition propDef : this.propertyDefinitions) {
            propDef.build(propertiesNode);
        }
    }
}