ActionConfigImpl.java 2.24 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.day.cq.wcm.msm.api.ActionConfig
 *  org.apache.sling.commons.json.JSONException
 *  org.apache.sling.commons.json.io.JSONWriter
 */
package com.day.cq.wcm.msm.impl.actions;

import com.day.cq.wcm.msm.api.ActionConfig;
import java.util.Map;
import java.util.Set;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.io.JSONWriter;

public class ActionConfigImpl
implements ActionConfig {
    private String name;
    private String parameterName;
    private int rank;
    private Map<String, String> properties;

    public ActionConfigImpl(String name, String parameterName, Map<String, String> properties, int rank) {
        this.name = name;
        this.parameterName = parameterName;
        this.properties = properties;
        this.rank = rank;
    }

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

    public int getRank() {
        return this.rank;
    }

    public Map<String, String> getProperties() {
        return this.properties;
    }

    public String getProperty(String propertyName) {
        if (this.properties != null) {
            return this.properties.get(propertyName);
        }
        return null;
    }

    public boolean hasProperty(String propertyName) {
        return this.properties != null && this.properties.containsKey(propertyName);
    }

    public String getParameterName() {
        return this.parameterName;
    }

    public int compareTo(ActionConfig config) {
        if (config != null) {
            int cmp = this.name.compareTo(config.getName());
            return cmp != 0 ? this.getRank() - config.getRank() : 0;
        }
        return -9999;
    }

    public void write(JSONWriter jsonWriter) throws JSONException {
        jsonWriter.object();
        jsonWriter.key("name").value((Object)this.getName());
        jsonWriter.key("parameterName").value((Object)this.getParameterName());
        jsonWriter.key("rank").value((long)this.getRank());
        if (this.properties != null) {
            for (String key : this.properties.keySet()) {
                jsonWriter.key(key).value((Object)this.properties.get(key));
            }
        }
        jsonWriter.endObject();
    }
}