GenericMetaDataProperty.java 1.62 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.cq.dam.cfm.MetaDataProperty
 *  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.MetaDataProperty;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;

public class GenericMetaDataProperty
implements MetaDataProperty {
    private final String name;
    private final String title;
    private final String type;
    private final Map<String, Object> config;

    public GenericMetaDataProperty(Resource resource) {
        ValueMap properties = (ValueMap)resource.adaptTo(ValueMap.class);
        this.name = resource.getName();
        this.title = (String)properties.get("jcr:title", String.class);
        this.type = (String)properties.get("type", String.class);
        this.config = new HashMap<String, Object>(4);
        for (String propName : properties.keySet()) {
            if (propName.startsWith("jcr:") || propName.equals("type")) continue;
            this.config.put(propName, properties.get((Object)propName));
        }
    }

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

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

    public String getType() {
        return this.type;
    }

    public Object getConfig(String name) {
        return this.config.get(name);
    }

    public Iterator<String> getConfigNames() {
        return this.config.keySet().iterator();
    }
}