< prev index next >

src/jdk.jpackage/share/classes/jdk/jpackage/internal/BundleParams.java

Print this page




  92 
  93     // boolean - Adds a dialog to let the user choose a directory
  94     // where the product will be installed.
  95     public static final String PARAM_INSTALLDIR_CHOOSER = "installdirChooser";
  96 
  97     /**
  98      * create a new bundle with all default values
  99      */
 100     public BundleParams() {
 101         params = new HashMap<>();
 102     }
 103 
 104     /**
 105      * Create a bundle params with a copy of the params
 106      * @param params map of initial parameters to be copied in.
 107      */
 108     public BundleParams(Map<String, ?> params) {
 109         this.params = new HashMap<>(params);
 110     }
 111 
 112     public void addAllBundleParams(Map<String, ? super Object> p) {
 113         params.putAll(p);
 114     }
 115 
 116     public <T> T fetchParam(BundlerParamInfo<T> paramInfo) {
 117         return paramInfo.fetchFrom(params);
 118     }
 119 
 120     @SuppressWarnings("unchecked")
 121     public <T> T fetchParamWithDefault(
 122             Class<T> klass, T defaultValue, String... keys) {
 123         for (String key : keys) {
 124             Object o = params.get(key);
 125             if (klass.isInstance(o)) {
 126                 return (T) o;
 127             } else if (params.containsKey(key) && o == null) {
 128                 return null;
 129             } else if (o != null) {
 130                 Log.debug("Bundle param " + key + " is not type " + klass);
 131             }
 132         }
 133         return defaultValue;




  92 
  93     // boolean - Adds a dialog to let the user choose a directory
  94     // where the product will be installed.
  95     public static final String PARAM_INSTALLDIR_CHOOSER = "installdirChooser";
  96 
  97     /**
  98      * create a new bundle with all default values
  99      */
 100     public BundleParams() {
 101         params = new HashMap<>();
 102     }
 103 
 104     /**
 105      * Create a bundle params with a copy of the params
 106      * @param params map of initial parameters to be copied in.
 107      */
 108     public BundleParams(Map<String, ?> params) {
 109         this.params = new HashMap<>(params);
 110     }
 111 
 112     public void addAllBundleParams(Map<String, ? super Object> params) {
 113         this.params.putAll(params);
 114     }
 115 
 116     public <T> T fetchParam(BundlerParamInfo<T> paramInfo) {
 117         return paramInfo.fetchFrom(params);
 118     }
 119 
 120     @SuppressWarnings("unchecked")
 121     public <T> T fetchParamWithDefault(
 122             Class<T> klass, T defaultValue, String... keys) {
 123         for (String key : keys) {
 124             Object o = params.get(key);
 125             if (klass.isInstance(o)) {
 126                 return (T) o;
 127             } else if (params.containsKey(key) && o == null) {
 128                 return null;
 129             } else if (o != null) {
 130                 Log.debug("Bundle param " + key + " is not type " + klass);
 131             }
 132         }
 133         return defaultValue;


< prev index next >