List of usage examples for java.util Objects toString
public static String toString(Object o, String nullDefault)
From source file:de.micromata.genome.util.i18n.PlaceholderTranslationProvider.java
@Override public Object getTranslationForKey(String key) { Object value = super.getTranslationForKey(key); if ((value instanceof String) == false) { return value; }/*from www .j av a 2 s . com*/ String svalue = (String) value; String resolved = PlaceHolderReplacer.resolveReplace(svalue, "I{", "}", new StringResolver() { @Override public String resolve(String placeholder) { return Objects.toString(getTranslationForKey(placeholder), StringUtils.EMPTY); } }); return resolved; }
From source file:jp.pigumer.security.ExampleAuthenticationProvider.java
@Autowired public void setUserDetailsService(ExampleUserDetailsService userDetailsService) { LOG.debug("serUserDetailsService: " + Objects.toString(userDetailsService, "")); this.userDetailsService = userDetailsService; }
From source file:com.hubspot.jinjava.tree.ExpressionNode.java
@Override public OutputNode render(JinjavaInterpreter interpreter) { Object var = interpreter.resolveELExpression(master.getExpr(), getLineNumber()); String result = Objects.toString(var, ""); if (!StringUtils.equals(result, master.getImage()) && StringUtils.contains(result, "{{")) { try {/*from w w w . ja va 2 s . c o m*/ result = interpreter.renderFlat(result); } catch (Exception e) { Logging.ENGINE_LOG.warn("Error rendering variable node result", e); } } if (interpreter.getContext().isAutoEscape()) { result = EscapeFilter.escapeHtmlEntities(result); } return new RenderedOutputNode(result); }
From source file:com.norconex.commons.wicket.util.SortablePropertyComparator.java
public int compare(final T o1, final T o2) { PropertyModel<Comparable<T>> model1 = new PropertyModel<Comparable<T>>(o1, Objects.toString(sortParam.getProperty(), null)); PropertyModel<Comparable<T>> model2 = new PropertyModel<Comparable<T>>(o2, Objects.toString(sortParam.getProperty(), null)); int result = new CompareToBuilder().append(model1.getObject(), model2.getObject()).toComparison(); if (!sortParam.isAscending()) { result = -result;/*from ww w .ja v a 2s . c om*/ } return result; }
From source file:ru.mystamps.web.validation.jsr303.FieldsMatchValidator.java
@Override public boolean isValid(Object value, ConstraintValidatorContext ctx) { if (value == null) { return true; }/*from w w w . j a v a 2 s.c om*/ PropertyAccessor bean = new BeanWrapperImpl(value); Object firstField = bean.getPropertyValue(firstFieldName); String firstFieldValue = Objects.toString(firstField, ""); if (StringUtils.isEmpty(firstFieldValue)) { return true; } Object secondField = bean.getPropertyValue(secondFieldName); String secondFieldValue = Objects.toString(secondField, ""); if (StringUtils.isEmpty(secondFieldValue)) { return true; } // TODO: check fields only when both fields are equals if (!firstFieldValue.equals(secondFieldValue)) { // bind error message to 2nd field ConstraintViolationUtils.recreate(ctx, secondFieldName, ctx.getDefaultConstraintMessageTemplate()); return false; } return true; }
From source file:ru.mystamps.web.validation.jsr303.FieldsMismatchValidator.java
@Override public boolean isValid(Object value, ConstraintValidatorContext ctx) { if (value == null) { return true; }//from w w w . j ava2 s . c om PropertyAccessor bean = new BeanWrapperImpl(value); Object firstField = bean.getPropertyValue(firstFieldName); String firstFieldValue = Objects.toString(firstField, ""); if (StringUtils.isEmpty(firstFieldValue)) { return true; } Object secondField = bean.getPropertyValue(secondFieldName); String secondFieldValue = Objects.toString(secondField, ""); if (StringUtils.isEmpty(secondFieldValue)) { return true; } // TODO: check fields only when both fields are equals if (firstFieldValue.equals(secondFieldValue)) { // bind error message to 2nd field ConstraintViolationUtils.recreate(ctx, secondFieldName, ctx.getDefaultConstraintMessageTemplate()); return false; } return true; }
From source file:ru.mystamps.web.validation.jsr303.NotNullIfFirstFieldValidator.java
@Override public boolean isValid(Object value, ConstraintValidatorContext ctx) { if (value == null) { return true; }//from w ww .j ava2s . co m PropertyAccessor bean = new BeanWrapperImpl(value); Object firstField = bean.getPropertyValue(firstFieldName); String firstFieldValue = Objects.toString(firstField, ""); if (StringUtils.isEmpty(firstFieldValue)) { return true; } Object secondField = bean.getPropertyValue(secondFieldName); String secondFieldValue = Objects.toString(secondField, ""); if (StringUtils.isNotEmpty(secondFieldValue)) { return true; } // bind error message to 2nd field ConstraintViolationUtils.recreate(ctx, secondFieldName, ctx.getDefaultConstraintMessageTemplate()); return false; }
From source file:de.micromata.genome.logging.LogRequestParameterAttribute.java
/** * Gets the request for logging./*from w ww . j a v a 2 s.com*/ * * @param request the request * @param excludingKeys the excluding keys * @return the request for logging */ public static String getRequestForLogging(Map<String, Object> request, String... excludingKeys) { if (request == null || request.isEmpty() == true) { return "<no params>"; } StringBuilder sb = new StringBuilder(); for (Map.Entry<String, Object> me : request.entrySet()) { final String key = me.getKey(); String value = Objects.toString(me.getValue(), StringUtils.EMPTY); for (String exKey : excludingKeys) { if (StringUtils.equals(key, exKey) == true) { value = "****"; break; } } // for sb.append(key).append('=').append(value).append('\n'); } return sb.toString(); }
From source file:de.micromata.genome.logging.LogSqlAttribute.java
/** * Format sql arg.// w w w.ja v a2 s . co m * * @param arg the arg * @return the string */ public static String formatSqlArg(Object arg) { if (arg == null) { return "NULL"; } if (arg instanceof String) { // TODO replace with proper SQL escaping return '\'' + StringUtils.replace((String) arg, "'", "''") + '\''; } if (arg instanceof java.util.Date) { return formatSqlDate((java.util.Date) arg); } // TODO (Rx) rrk (low) format Date, Timestamp und BigDecimal fuer sql log anzeige return Objects.toString(arg, StringUtils.EMPTY); }
From source file:io.github.robwin.swagger2markup.utils.PropertyUtils.java
public static String getDefaultValue(Property property) { Validate.notNull(property, "property must not be null!"); String defaultValue = ""; if (property instanceof BooleanProperty) { BooleanProperty booleanProperty = (BooleanProperty) property; defaultValue = Objects.toString(booleanProperty.getDefault(), ""); } else if (property instanceof StringProperty) { StringProperty stringProperty = (StringProperty) property; defaultValue = Objects.toString(stringProperty.getDefault(), ""); } else if (property instanceof DoubleProperty) { DoubleProperty doubleProperty = (DoubleProperty) property; defaultValue = Objects.toString(doubleProperty.getDefault(), ""); } else if (property instanceof FloatProperty) { FloatProperty floatProperty = (FloatProperty) property; defaultValue = Objects.toString(floatProperty.getDefault(), ""); } else if (property instanceof IntegerProperty) { IntegerProperty integerProperty = (IntegerProperty) property; defaultValue = Objects.toString(integerProperty.getDefault(), ""); } else if (property instanceof LongProperty) { LongProperty longProperty = (LongProperty) property; defaultValue = Objects.toString(longProperty.getDefault(), ""); } else if (property instanceof UUIDProperty) { UUIDProperty uuidProperty = (UUIDProperty) property; defaultValue = Objects.toString(uuidProperty.getDefault(), ""); }//from w ww .j a v a 2 s. co m return defaultValue; }