private static void addValue(
     Trace.DetailEntry.Builder builder, @Nullable Object possiblyOptionalValue) {
   Object value = stripOptional(possiblyOptionalValue);
   if (value == null) {
     // add nothing (as a corollary, this will strip null/Optional.absent() items from lists)
   } else if (value instanceof String) {
     builder.addValueBuilder().setString((String) value).build();
   } else if (value instanceof Boolean) {
     builder.addValueBuilder().setBoolean((Boolean) value).build();
   } else if (value instanceof Long) {
     builder.addValueBuilder().setLong((Long) value).build();
   } else if (value instanceof Number) {
     builder.addValueBuilder().setDouble(((Number) value).doubleValue()).build();
   } else {
     logger.warn("detail map has unexpected value type: {}", value.getClass().getName());
     builder.addValueBuilder().setString(Strings.nullToEmpty(value.toString())).build();
   }
 }