VariationTemplateImpl.java 1.68 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.cq.dam.cfm.VariationTemplate
 *  org.apache.sling.api.resource.Resource
 *  org.apache.sling.api.resource.ValueMap
 */
package com.adobe.cq.dam.cfm.impl;

import com.adobe.cq.dam.cfm.VariationTemplate;
import com.adobe.cq.dam.cfm.impl.InvalidTemplateException;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;

public class VariationTemplateImpl
implements VariationTemplate {
    private final String name;
    private final String title;
    private final String description;

    public VariationTemplateImpl(Resource resource) throws InvalidTemplateException {
        ValueMap properties = (ValueMap)resource.adaptTo(ValueMap.class);
        String name = (String)properties.get("name", String.class);
        if (name == null) {
            throw new InvalidTemplateException("Missing variation name on template.");
        }
        this.name = name;
        String title = (String)properties.get("jcr:title", String.class);
        if (title == null) {
            throw new InvalidTemplateException("Missing variation title on template.");
        }
        this.title = title;
        this.description = (String)properties.get("jcr:description", (Object)"");
    }

    VariationTemplateImpl(String name, String title, String description) {
        this.name = name;
        this.title = title;
        this.description = description != null ? description : "";
    }

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

    public String getTitle() {
        return this.title;
    }

    public String getDescription() {
        return this.description;
    }
}