Java Comma Separated List resolveCommandParam(List params, String name, double defaultValue)

Here you can find the source of resolveCommandParam(List params, String name, double defaultValue)

Description

resolve Command Param

License

Open Source License

Declaration

public static double resolveCommandParam(List<String> params, String name, double defaultValue) 

Method Source Code

//package com.java2s;

import java.util.List;
import java.util.Map;

public class Main {
    public static double resolveCommandParam(List<String> params, String name, double defaultValue) {
        String v = resolveCommandParam(params, name, null);
        return v == null ? defaultValue : Double.parseDouble(v);
    }/* w  w w .  ja v a2s  .c om*/

    public static int resolveCommandParam(List<String> params, String name, int defaultValue) {
        final String v = resolveCommandParam(params, name, null);
        return v == null ? defaultValue : Integer.parseInt(v);
    }

    public static String resolveCommandParam(List<String> params, String name, String defaultValue) {
        final int index = params.indexOf("-" + name);
        if (index < 0 || index == params.size() - 1)
            return defaultValue;
        return params.get(index + 1);
    }

    public static String resolveCommandParam(Map<String, ?> params, String name, String defaultValue) {
        final Object v = params.get(name);
        return v != null ? v.toString() : defaultValue;
    }

    public static int resolveCommandParam(Map<String, ?> params, String name, int defaultValue) {
        final String v = resolveCommandParam(params, name, null);
        return v == null ? defaultValue : Integer.parseInt(v);
    }
}

Related

  1. listToString(List list, boolean doCommas)
  2. loadListFromStrings(final String commaDelimitedStrings, final boolean sortList)
  3. moveClasspathArgToEnvironmentVariable(List commandArgs, ProcessBuilder pb)
  4. parseCommaList(String nameCommaList)
  5. parseRsfCommands(List rsfLines, List addItemCommands, List appendEntryCommands)
  6. splitCommandsToList(String row, String delimiter)
  7. splitListByComma(List hosts)
  8. splitListWithComma(List StringList)
  9. splitOnCommas(final String commaSeparatedList)