Example usage for org.apache.commons.lang3 StringUtils defaultString

List of usage examples for org.apache.commons.lang3 StringUtils defaultString

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils defaultString.

Prototype

public static String defaultString(final String str) 

Source Link

Document

Returns either the passed in String, or if the String is null , an empty String ("").

 StringUtils.defaultString(null)  = "" StringUtils.defaultString("")    = "" StringUtils.defaultString("bat") = "bat" 

Usage

From source file:io.github.robwin.swagger2markup.utils.ParameterUtils.java

private static String getTypeWithFormat(String typeWithoutFormat, String format) {
    String type;//from   w  w  w  .  j  a  v a2  s .c  o  m
    if (StringUtils.isNotBlank(format)) {
        type = StringUtils.defaultString(typeWithoutFormat) + " (" + format + ")";
    } else {
        type = StringUtils.defaultString(typeWithoutFormat);
    }
    return type;
}

From source file:io.redlink.solrlib.cloud.SolrCloudConnector.java

public SolrCloudConnector(Set<SolrCoreDescriptor> coreDescriptors,
        SolrCloudConnectorConfiguration configuration, ExecutorService executorService) {
    super(coreDescriptors, executorService);

    this.config = configuration;
    this.prefix = StringUtils.defaultString(configuration.getPrefix());
}

From source file:com.sonicle.webtop.core.util.LoggerUtils.java

public synchronized static String getUserServiceVariable() {
    return StringUtils.defaultString(MDC.get(VAR_USER_SERVICE));
}

From source file:com.netsteadfast.greenstep.bsc.command.ProcessBscTreeItemsCommand.java

@Override
public boolean execute(Context context) throws Exception {
    if (this.getResult(context) == null || !(this.getResult(context) instanceof BscStructTreeObj)) {
        return false;
    }/*from   w w  w  . ja  va  2 s .c om*/
    String host = StringUtils.defaultString((String) context.get("http"))
            + ApplicationSiteUtils.getHost(Constants.getMainSystem()) + "/"
            + ApplicationSiteUtils.getContextPathFromMap(Constants.getMainSystem()) + "/";
    String iconImg = IconUtils.getMenuIcon(host, "STAR");
    BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context);
    List<Map<String, Object>> items = new LinkedList<Map<String, Object>>();
    for (VisionVO vision : treeObj.getVisions()) {
        Map<String, Object> visionDataMap = new HashMap<String, Object>();
        visionDataMap.put("type", "parent");
        visionDataMap.put("name", vision.getTitle());
        visionDataMap.put("id", BscConstants.KPI_TREE_NOT_ITEM + vision.getOid());
        items.add(visionDataMap);
        List<Map<String, Object>> perspectiveItems = new LinkedList<Map<String, Object>>();
        for (PerspectiveVO perspective : vision.getPerspectives()) {
            Map<String, Object> perspectiveDataMap = new HashMap<String, Object>();
            perspectiveDataMap.put("type", "parent");
            perspectiveDataMap.put("name", perspective.getName());
            perspectiveDataMap.put("id", BscConstants.KPI_TREE_NOT_ITEM + perspective.getOid());
            perspectiveItems.add(perspectiveDataMap);
            visionDataMap.put("children", perspectiveItems);
            List<Map<String, Object>> objectivesStrategyList = new LinkedList<Map<String, Object>>();
            for (ObjectiveVO objective : perspective.getObjectives()) {
                Map<String, Object> objectiveMap = new HashMap<String, Object>();
                objectiveMap.put("type", "parent");
                objectiveMap.put("name", objective.getName());
                objectiveMap.put("id", BscConstants.KPI_TREE_NOT_ITEM + objective.getOid());
                objectivesStrategyList.add(objectiveMap);
                perspectiveDataMap.put("children", objectivesStrategyList);
                List<Map<String, Object>> kpiList = new LinkedList<Map<String, Object>>();
                for (KpiVO kpi : objective.getKpis()) {
                    Map<String, Object> kpiMap = new HashMap<String, Object>();
                    kpiMap.put("type", "Leaf");
                    kpiMap.put("name", iconImg + kpi.getName());
                    kpiMap.put("id", kpi.getOid());
                    kpiList.add(kpiMap);
                    objectiveMap.put("children", kpiList);
                }
            }
        }
    }
    this.setResult(context, items);
    if (null == items || items.size() < 1) {
        this.setMessage(context, SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA));
    }
    return false;
}

From source file:net.andydvorak.intellij.lessc.state.LessProfile.java

@NotNull
public String getIncludePattern() {
    return StringUtils.defaultString(includePattern);
}

From source file:de.micromata.genome.gwiki.page.impl.wiki.MacroAttributesUtils.java

public static Map<String, String> decode(String text) {
    Map<String, String> map = new HashMap<String, String>();
    if (StringUtils.isEmpty(text) == true)
        return map;

    text = trim(text);/*from ww w.  j a v  a  2s.com*/

    List<String> tlist = Converter.parseStringTokens(text, "|\\=", true);
    if (tlist.size() == 0)
        return map;
    if (tlist.size() == 1) {
        map.put(MacroAttributes.DEFAULT_VALUE_KEY, tlist.get(0));
        return map;
    }
    StringBuilder sb = new StringBuilder();
    String curKey = null;
    String curValue = null;
    State state = State.ParseKey;
    for (int i = 0; i < tlist.size(); ++i) {
        String t = tlist.get(i);
        if ("\\".equals(t) == true) {
            ++i;
            t = tlist.get(i);
            sb.append(t);
            continue;
        } else if ("=".equals(t) == true) {
            if (state == State.ParseValue) {
                sb.append(t);
                continue;
            }
            curKey = sb.toString();
            sb = new StringBuilder();
            state = State.ParseValue;
        } else if ("|".equals(t) == true) {
            // if (state != State.ParseValue) {
            // //eigentlich fehler
            // throw new IllegalStateException("Parsing '|' in state: " + state);
            // }
            curValue = sb.toString();
            map.put(curKey, curValue);
            sb = new StringBuilder();
            curKey = null;
            curValue = null;
            state = State.ParseKey;
        } else {
            sb.append(t);
        }
    }
    if (curKey != null) {
        curValue = sb.toString();
        map.put(curKey, StringUtils.defaultString(curValue));
    }
    return map;
}

From source file:com.netsteadfast.greenstep.bsc.esb.router.ApiRouteBuilder.java

@Override
public void configure() throws Exception {
    this.from("servlet:///api").process(new Processor() {

        @Override// w w w  .j a  v a 2s. com
        public void process(Exchange exchange) throws Exception {
            String format = StringUtils.defaultString(exchange.getIn().getHeader("format", String.class)).trim()
                    .toLowerCase();
            String visionOid = StringUtils.defaultString(exchange.getIn().getHeader("visionOid", String.class))
                    .trim().toLowerCase();
            String startDate = StringUtils.defaultString(exchange.getIn().getHeader("startDate", String.class))
                    .trim().toLowerCase();
            String endDate = StringUtils.defaultString(exchange.getIn().getHeader("endDate", String.class))
                    .trim().toLowerCase();
            String startYearDate = StringUtils
                    .defaultString(exchange.getIn().getHeader("startYearDate", String.class)).trim()
                    .toLowerCase();
            String endYearDate = StringUtils
                    .defaultString(exchange.getIn().getHeader("endYearDate", String.class)).trim()
                    .toLowerCase();
            String frequency = StringUtils.defaultString(exchange.getIn().getHeader("frequency", String.class))
                    .trim().toLowerCase();
            String dataFor = StringUtils.defaultString(exchange.getIn().getHeader("dataFor", String.class))
                    .trim().toLowerCase();
            String measureDataOrganizationOid = StringUtils
                    .defaultString(exchange.getIn().getHeader("measureDataOrganizationOid", String.class))
                    .trim().toLowerCase();
            String measureDataEmployeeOid = StringUtils
                    .defaultString(exchange.getIn().getHeader("measureDataEmployeeOid", String.class)).trim()
                    .toLowerCase();
            String contentFlag = StringUtils
                    .defaultString(exchange.getIn().getHeader("contentFlag", String.class)).trim()
                    .toUpperCase();
            String responseContent = "";
            // ? gsbsc-web applicationContext-STANDARD-CXF.xml
            ApiWebService apiWebService = (ApiWebService) AppContext.getBean("bsc.webservice.ApiWebService");
            BscApiServiceResponse responseObj = apiWebService.getScorecard1(visionOid, startDate, endDate,
                    startYearDate, endYearDate, frequency, dataFor, measureDataOrganizationOid,
                    measureDataEmployeeOid, contentFlag);
            if ("xml".equals(format)) { // xml
                XStream xstream = new XStream();
                xstream.setMode(XStream.NO_REFERENCES);
                xstream.alias("response", BscApiServiceResponse.class);
                responseContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + xstream.toXML(responseObj);
            } else { // json
                ObjectMapper mapper = new ObjectMapper();
                responseContent = mapper.writeValueAsString(responseObj);
            }
            exchange.getOut().setBody(responseContent);
        }

    }).to("stream:out");
}

From source file:com.netsteadfast.greenstep.bsc.command.PersonalAndOrganizationReportDateRangeScoreCommand.java

@SuppressWarnings("unchecked")
@Override/*w w  w .j  ava 2 s .com*/
public boolean execute(Context context) throws Exception {
    if (this.getResult(context) == null || !(this.getResult(context) instanceof BscStructTreeObj)) {
        return false;
    }
    float total = 0.0f;
    BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context);
    String year = StringUtils.defaultString((String) context.get("startYearDate")).trim();
    String dateType = StringUtils.defaultString((String) context.get("dateType")).trim();
    for (VisionVO vision : treeObj.getVisions()) {
        for (PerspectiveVO perspective : vision.getPerspectives()) {
            for (ObjectiveVO objective : perspective.getObjectives()) {
                for (KpiVO kpi : objective.getKpis()) {
                    this.setDateRangeScore(kpi, dateType, year);
                    total = total + kpi.getDateRangeScores().get(0).getScore(); // ?
                }
            }
        }
    }
    context.put("total", total);
    return false;
}

From source file:atg.tools.dynunit.DynUnit.java

public static String getHome() {
    logger.entry();//from  w  w w . jav a2s.c  o m
    String dynUnitHome = PropertiesUtil.getSystemProperty(DYNUNIT_HOME_PROPERTY);
    if (StringUtils.isEmpty(dynUnitHome)) {
        dynUnitHome = System.getenv("DYNUNIT_HOME");
        if (StringUtils.isEmpty(dynUnitHome)) {
            logger.error("Can't find DynUnit home directory. Please set the {} property.",
                    DYNUNIT_HOME_PROPERTY);
        }
    }
    return logger.exit(StringUtils.defaultString(dynUnitHome));
}

From source file:com.netsteadfast.greenstep.bsc.command.LoadBscMixDataCommand.java

@SuppressWarnings("unchecked")
@Override//w  w  w.  ja v a 2s  .com
public boolean execute(Context context) throws Exception {
    kpiService = (IKpiService<KpiVO, BbKpi, String>) AppContext.getBean("bsc.service.KpiService");
    String orgId = (String) context.get("orgId");
    String empId = (String) context.get("empId");
    List<String> kpiIds = (List<String>) context.get("kpiIds");
    if (BscConstants.MEASURE_DATA_ORGANIZATION_FULL.equals(orgId)) {
        orgId = "";
    }
    if (BscConstants.MEASURE_DATA_EMPLOYEE_FULL.equals(empId)) {
        empId = "";
    }
    DefaultResult<List<BscMixDataVO>> result = kpiService.findForMixData((String) context.get("visionOid"),
            orgId, empId, StringUtils.defaultString((String) context.get("nextType")),
            StringUtils.defaultString((String) context.get("nextId")), kpiIds);
    if (result.getValue() != null) {
        this.setResult(context, result.getValue());
    } else {
        this.setMessage(context, result.getSystemMessage().getValue());
    }
    return false;
}