All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.jangaroo.jooc.mvnplugin.converter.JangarooConfig Maven / Gradle / Ivy

The newest version!
package net.jangaroo.jooc.mvnplugin.converter;

import com.google.common.collect.ImmutableList;
import net.jangaroo.jooc.mvnplugin.util.MergeHelper;

import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

public class JangarooConfig {
  private static final MergeHelper.MergeOptions SENCHA_MERGE_OPTIONS = new MergeHelper.MergeOptions(MergeHelper.ListStrategy.APPEND, MergeHelper.MapStrategy.MERGE);

  private String type;
  private String applicationClass;
  private Map appPaths;
  private String theme;
  private Map sencha;
  private Map appManifests;
  private List additionalLocales;
  private List autoLoad;
  private Map> command;

  public JangarooConfig() {
  }

  /*public JangarooConfig(String type, String applicationClass, Map rootApp, String theme, Map sencha, Map appManifests, List additionalLocales, List autoLoad, Map> command) {
    this.type = type;
    this.applicationClass = applicationClass;
    this.appPaths = rootApp;
    this.theme = theme;
    this.sencha = sencha;
    this.appManifests = appManifests;
    this.additionalLocales = additionalLocales;
    this.autoLoad = autoLoad;
    this.command = command;
  }*/

  public String getType() {
    return type;
  }

  public void setType(String type) {
    this.type = type;
  }

  public String getApplicationClass() {
    return applicationClass;
  }

  public void setApplicationClass(String applicationClass) {
    this.applicationClass = applicationClass;
  }

  public Map getAppPaths() {
    return appPaths;
  }

  public void setAppPaths(Map appPaths) {
    this.appPaths = appPaths;
  }

  public void addAppPath(String appDependencyName, String path) {
    if (this.appPaths == null) {
      this.appPaths = new HashMap<>();
    }
    this.appPaths.put(appDependencyName, path);
  }

  public String getTheme() {
    return theme;
  }

  public void setTheme(String theme) {
    this.theme = theme;
  }

  public Map getSencha() {
    return sencha;
  }

  public void setSencha(Map sencha) {
    if (sencha == null) {
      this.sencha = null;
      return;
    }
    if (this.sencha == null) {
      this.sencha = new TreeMap<>(new Comparator() {
        private final List ORDER = ImmutableList.of("name", "version", "type", "namespace", "css", "js", "sass");

        @Override
        public int compare(String a, String b) {
          int indexOfA = ORDER.indexOf(a);
          int indexOfB = ORDER.indexOf(b);
          if (indexOfA > -1 && indexOfB > -1) {
            return indexOfA - indexOfB;
          }
          if (indexOfA > -1) {
            return -1;
          }
          if (indexOfB > -1) {
            return 1;
          }
          return a.compareTo(b);
        }
      });
    }
    this.sencha.clear();
    this.addToSencha(sencha);
  }

  public void addToSencha(Map additionalEntries) {
    if (this.sencha == null) {
      setSencha(additionalEntries);
      return;
    }
    MergeHelper.mergeMapIntoBaseMap(this.sencha, additionalEntries, SENCHA_MERGE_OPTIONS);
  }

  public Map getAppManifests() {
    return appManifests;
  }

  public void addAppManifest(String name, Object manifest) {
    if (this.appManifests == null) {
      this.appManifests = new HashMap<>();
    }
    this.appManifests.put(name, manifest);
  }

  public void setAppManifests(Map appManifests) {
    this.appManifests = appManifests;
  }

  public List getAdditionalLocales() {
    return additionalLocales;
  }

  public void setAdditionalLocales(List additionalLocales) {
    this.additionalLocales = additionalLocales;
  }

  public List getAutoLoad() {
    return autoLoad;
  }

  public void setAutoLoad(List autoLoad) {
    this.autoLoad = autoLoad;
  }

  public Map> getCommand() {
    return command;
  }

  public void setCommand(Map> command) {
    this.command = command;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy