List of usage examples for java.util Objects toString
public static String toString(Object o, String nullDefault)
From source file:de.micromata.genome.util.types.CoerceUtils.java
/** * To double./*from w ww.j a v a 2 s. c o m*/ * * @param o the o * @return the double */ public static double toDouble(Object o) { if (o instanceof Number) { return ((Number) o).doubleValue(); } if (o instanceof String) { return Double.parseDouble((String) o); } throw new RuntimeException("Cannot coerce value to double: " + Objects.toString(o, StringUtils.EMPTY)); }
From source file:jp.furplag.spring.booster.validation.tuple.PairIntegers.java
public PairIntegers(Object left, Object right) { this((Long) (isInteger(left) ? NumberUtils.createLong(Objects.toString(left, null)) : null), (Long) (isInteger(right) ? NumberUtils.createLong(Objects.toString(right, null)) : null)); }
From source file:jp.furplag.spring.booster.validation.tuple.PairFractions.java
public PairFractions(Object left, Object right) { this((BigDecimal) (isCollectable(left) ? NumberUtils.createBigDecimal(Objects.toString(left, null)) : null), (BigDecimal) (isCollectable(right) ? NumberUtils.createBigDecimal(Objects.toString(right, null)) : null));/*from w ww.ja v a 2 s .c om*/ }
From source file:de.micromata.genome.util.i18n.I18NTranslationProvider.java
default String translate(String key) { Object ores = getTranslationForKey(key); if (ores == null) { return null; }/* w w w. j av a 2 s . c om*/ return Objects.toString(ores, StringUtils.EMPTY); }
From source file:com.github.lothar.security.acl.named.NamedBean.java
public String name() { return Objects.toString(name, getClass().getSimpleName()); }
From source file:jp.pigumer.app.UserDetailsServiceImpl.java
@Override public UserDetails loadUserDetails(PreAuthenticatedAuthenticationToken token) throws UsernameNotFoundException { LOG.info(Objects.toString(token, "null")); return new User(token.getName(), "<abc123>", token.getAuthorities()); }
From source file:org.wso2.appserver.integration.common.artifacts.spring3.restful.simple.service.controller.StudentController.java
@RequestMapping(method = RequestMethod.GET, value = "/deployedtime") @ResponseBody/*from www. j av a 2 s. com*/ public String getDeployedtime() { return "{\"deployedTime\":\"" + Objects.toString(deployedTime, "") + "\"}"; }
From source file:io.wcm.config.core.management.impl.PersistenceTypeConversion.java
/** * Convert object to be persisted.//from w w w. ja v a 2 s .c o m * @param value Configured value * @param parameterType Parameter type * @return value that can be persisted */ public static Object toPersistenceType(Object value, Class<?> parameterType) { if (!isTypeConversionRequired(parameterType)) { return value; } if (Map.class.isAssignableFrom(parameterType) && (value instanceof Map)) { Map<?, ?> map = (Map<?, ?>) value; Map.Entry<?, ?>[] entries = Iterators.toArray(map.entrySet().iterator(), Map.Entry.class); String[] stringArray = new String[entries.length]; for (int i = 0; i < entries.length; i++) { Map.Entry<?, ?> entry = entries[i]; String entryKey = Objects.toString(entry.getKey(), ""); String entryValue = Objects.toString(entry.getValue(), ""); stringArray[i] = entryKey + KEY_VALUE_DELIMITER + entryValue; } return stringArray; } throw new IllegalArgumentException("Type conversion not supported: " + parameterType.getName()); }
From source file:com.opentable.exception.OTApiException.java
private static void checkNotBlank(Map<String, ? extends Object> fields, String fieldName) { final String field = Objects.toString(fields.get(fieldName), null); Preconditions.checkArgument(field != null && !field.trim().equals(""), "Field %s may not be missing", fieldName);/*ww w. j a v a 2 s . co m*/ }
From source file:jp.furplag.spring.booster.validation.tuple.PairNumbers.java
/** * Checks whether the stringified object a valid Java number. * * @param o the object to try parsing to a number. * @return returns true if the object parsable to a number. *//*ww w . j a v a 2s . c om*/ protected static boolean isCollectable(Object o) { return NumberUtils.isCreatable(Objects.toString(o, null)); }