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

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

class ActionConfigAdaptor
implements com.day.cq.wcm.api.msm.ActionConfig {
    private final ActionConfig adaptee;
    private final boolean inherited;

    ActionConfigAdaptor(ActionConfig delegatee, boolean inherited) {
        this.adaptee = delegatee;
        this.inherited = inherited;
    }

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

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

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

    public String getProperty(String propertyName) {
        return this.adaptee.getProperty(propertyName);
    }

    public boolean hasProperty(String propertyName) {
        return this.adaptee.hasProperty(propertyName);
    }

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

    public int compareTo(com.day.cq.wcm.api.msm.ActionConfig config) {
        if (config != null) {
            int cmp = this.getName().compareTo(config.getName());
            return cmp != 0 ? this.getRank() - config.getRank() : 0;
        }
        return -9999;
    }

    public boolean isInherited() {
        return this.inherited;
    }

    public void write(JSONWriter out) throws JSONException {
        this.adaptee.write(out);
    }

    static Set<com.day.cq.wcm.api.msm.ActionConfig> rolloutToAction(List<RolloutConfig> rolloutCfg) {
        HashSet<com.day.cq.wcm.api.msm.ActionConfig> ret = new HashSet<com.day.cq.wcm.api.msm.ActionConfig>();
        for (RolloutConfig cfg : rolloutCfg) {
            for (ActionConfig aCfg : cfg.getActionsConfig()) {
                ret.add(new ActionConfigAdaptor(aCfg, false));
            }
        }
        return ret;
    }
}