Example usage for java.util Objects toString

List of usage examples for java.util Objects toString

Introduction

In this page you can find the example usage for java.util Objects toString.

Prototype

public static String toString(Object o, String nullDefault) 

Source Link

Document

Returns the result of calling toString on the first argument if the first argument is not null and returns the second argument otherwise.

Usage

From source file:org.apache.struts2.spring.config.entities.SpringConstantConfig.java

@Override
public Map<String, String> getAllAsStringsMap() {
    Map<String, String> map = super.getAllAsStringsMap();

    map.put(SpringConstants.SPRING_CLASS_RELOADING_WATCH_LIST, StringUtils.join(classReloadingWatchList, ','));
    map.put(SpringConstants.SPRING_CLASS_RELOADING_ACCEPT_CLASSES,
            StringUtils.join(classReloadingAcceptClasses, ','));
    map.put(SpringConstants.SPRING_CLASS_RELOADING_RELOAD_CONFIG,
            Objects.toString(classReloadingReloadConfig, null));

    return map;//  w  w w.j  ava  2 s.c o  m
}

From source file:info.naiv.lab.java.tool.sqlite.exporter.component.ValueHandlerImpl.java

/**
 *
 * @param field//w w w.  j  a va 2 s  .co m
 * @param rowSet
 * @return
 * @throws SQLException
 */
@Override
public Object handleValue(Field field, ResultSet rowSet) throws SQLException {
    String name = field.getOriginalName();
    switch (field.getTypeInfo()) {
    case CHAR:
    case NCHAR:
        return StringUtils.trimTrailingWhitespace(rowSet.getString(name));
    case DATE:
        return Objects.toString(rowSet.getDate(name), null);
    case TIME:
        return Objects.toString(rowSet.getTime(name), null);
    case TIMESTAMP:
        return Objects.toString(rowSet.getTimestamp(name), null);
    default:
        return rowSet.getObject(name);
    }
}

From source file:com.hubspot.jinjava.lib.filter.CutFilter.java

@Override
public Object filter(Object object, JinjavaInterpreter interpreter, String... arg) {
    if (arg.length != 1) {
        throw new InterpretException("filter cut expects 1 arg >>> " + arg.length);
    }//from   ww  w.  ja  va2  s.  c om
    String cutee = arg[0];
    String origin = Objects.toString(object, "");
    return StringUtils.replace(origin, cutee, "");
}

From source file:de.micromata.genome.logging.DocLogEntries.java

/**
 * Load.//from w ww . j  a va 2 s. c o  m
 *
 * @param properties the properties
 * @return the doc log entries
 */
@SuppressWarnings("unchecked")
public static DocLogEntries load(Map properties) {
    Map<String, Object> props = properties;
    DocLogEntries dle = new DocLogEntries();
    int i;
    for (i = 0; props.get("" + i + ".level") != null; ++i) {
        DocLogEntry dl = new DocLogEntry();
        dl.setLevel(Objects.toString(props.get("" + i + ".level"), StringUtils.EMPTY));
        dl.setDomain(Objects.toString(props.get("" + i + ".domain"), StringUtils.EMPTY));
        dl.setCategory(Objects.toString(props.get("" + i + ".category"), StringUtils.EMPTY));
        dl.setConstMessage(Objects.toString(props.get("" + i + ".message"), StringUtils.EMPTY));
        dl.setReason(Objects.toString(props.get("" + i + ".reason"), StringUtils.EMPTY));
        dl.setAction(Objects.toString(props.get("" + i + ".action"), StringUtils.EMPTY));
        // log4jlog.debug("dl: " + dl.hashCode() + ": " + dl.toString());
        DocLogEntryKey dlek = new DocLogEntryKey(dl);
        List<DocLogEntry> ldel = dle.entries.get(dlek);
        if (ldel == null) {
            ldel = new ArrayList<DocLogEntry>();
            dle.entries.put(dlek, ldel);
        } else {
            /**
             * @nologging
             * @reason Conflict with duplicated DocLogs
             * @action Concact Developer
             */
            //GLog.note(GenomeLogCategory.Configuration, "Duplicated doclog: " + dl.hashCode() + ": " + dl.toString());
            // log4jlog.debug("fdl: x" + dl.hashCode() + ": " + dl.toString());
            // ldel.add(dl);
        }

        ldel.add(dl);
    }
    return dle;
}

From source file:jp.pigumer.security.ExampleAuthenticationProvider.java

@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
    PreAuthenticatedAuthenticationToken auth = (PreAuthenticatedAuthenticationToken) authentication;
    String username = (String) auth.getPrincipal();

    LOG.debug("authenticate: " + Objects.toString(auth, ""));

    User user = userDetailsService.loadUser(username);

    ExampleAuthentication result = new ExampleAuthentication(user, user.getAuthorities());
    result.setDetails(auth.getDetails());

    LOG.debug("authenticate: " + Objects.toString(result, ""));

    return result;
}

From source file:eu.itesla_project.commons.tools.Main.java

private static void printCommandUsage(Command command) {
    HelpFormatter formatter = new HelpFormatter();
    formatter.printHelp(80, TOOL_NAME + " " + command.getName(), "", getOptionsWithHelp(command.getOptions()),
            "\n" + Objects.toString(command.getUsageFooter(), ""), true);
}

From source file:org.wso2.appserver.integration.common.artifacts.spring3.restful.jndi.service.controller.StudentController.java

@RequestMapping(method = RequestMethod.GET, value = "deployedtime")
@ResponseBody/*from   w  w  w .  j a  v  a 2 s.  c  o  m*/
public String getDeployedtime() {
    return "{\"deployedTime\":\"" + Objects.toString(deployedTime, "") + "\"}";
}

From source file:com.opentable.exception.OTApiException.java

protected String getValue(String field) {
    return Objects.toString(fields.get(field), null);
}

From source file:com.hubspot.jinjava.lib.filter.Filter.java

default Object filter(Object var, JinjavaInterpreter interpreter, Object[] args, Map<String, Object> kwargs) {
    // We append the named arguments at the end of the positional ones
    Object[] allArgs = ArrayUtils.addAll(args, kwargs.values().toArray());
    String[] stringArgs = Arrays.stream(allArgs).map(arg -> Objects.toString(arg, null)).toArray(String[]::new);

    return filter(var, interpreter, stringArgs);
}

From source file:edu.umich.flowfence.testapp.TestQM.java

private static void logCommon(String name, Object result) {
    String resultString = Objects.toString(result, "<null>");
    if (name == null) {
        Log.i(TAG, String.format("log: [%s]", resultString));
    } else {/*from   ww  w  . j  ava2  s . c  o m*/
        Log.i(TAG, String.format("log: %s = [%s]", name, resultString));
    }
}