Source:
<code>public void addCustomAttributesToUser(final String userId, final Map<String, Object> customAttributes) { try { final User intercomUser = User.find(userId); final List<Class<?>> classTypes = Arrays.asList(Boolean.class, String.class, Integer.class, Double.class, Long.class, Float.class); final Optional<Entry<String, Object>> unsupportedClassType = customAttributes.entrySet().stream() .filter(entry -> !classTypes.contains(entry.getValue().getClass())).findAny(); if (unsupportedClassType.isPresent()) { logger.debug("Unsupported custom attribute class type: " + unsupportedClassType.get()); } else { customAttributes.entrySet().stream().forEach(entry -> { <START> if (entry.getValue().getClass().equals(Boolean.class)) { <END> intercomUser.addCustomAttribute(CustomAttribute.newBooleanAttribute((String) entry.getValue(), (Boolean) entry.getValue())); } else if (entry.getValue().getClass().equals(Integer.class)) { intercomUser.addCustomAttribute(CustomAttribute.newIntegerAttribute((String) entry.getValue(), (Integer) entry.getValue())); } else if (entry.getValue().getClass().equals(Double.class)) { intercomUser.addCustomAttribute(CustomAttribute.newDoubleAttribute((String) entry.getValue(), (Double) entry.getValue())); } else if (entry.getValue().getClass().equals(Long.class)) { intercomUser.addCustomAttribute( CustomAttribute.newLongAttribute((String) entry.getValue(), (Long) entry.getValue())); } else if (entry.getValue().getClass().equals(String.class)) { intercomUser.addCustomAttribute( CustomAttribute.newFloatAttribute((String) entry.getValue(), (Float) entry.getValue())); } else { intercomUser.addCustomAttribute(CustomAttribute.newStringAttribute((String) entry.getValue(), (String) entry.getValue())); } }); } } catch (final Exception e) { logger.debug( "Error adding custom attributes to Intercom user with id: " + userId + " - " + e.getMessage()); } }</code><technical_language>reduce repetitive code, local variables for key value: java customAttributes.entrySet().stream().forEach(entry -> { String key = entry.getKey(); Object = entry.getValue(); ..</technical_language>

Target:
public void addCustomAttributesToUser(final String userId, final Map<String, Object> customAttributes) { try { final User intercomUser = User.find(userId); customAttributes.entrySet().stream().forEach(entry -> { final String key = entry.getKey(); final Object value = entry.getValue(); if (value.getClass().equals(Boolean.class)) { intercomUser.addCustomAttribute(CustomAttribute.newBooleanAttribute(key, (Boolean) value)); } else if (value.getClass().equals(Integer.class)) { intercomUser.addCustomAttribute(CustomAttribute.newIntegerAttribute(key, (Integer) value)); } else if (value.getClass().equals(Double.class)) { intercomUser.addCustomAttribute(CustomAttribute.newDoubleAttribute(key, (Double) value)); } else if (value.getClass().equals(Long.class)) { intercomUser.addCustomAttribute(CustomAttribute.newLongAttribute(key, (Long) value)); } else if (value.getClass().equals(Float.class)) { intercomUser.addCustomAttribute(CustomAttribute.newFloatAttribute(key, (Float) value)); } else if (value.getClass().equals(String.class)) { intercomUser.addCustomAttribute(CustomAttribute.newStringAttribute(key, (String) value)); } else { logger.warn("Unsupported custom attribute class : " + value.getClass().getSimpleName()); } }); User.update(intercomUser); } catch (final Exception e) { logger.warn("Error adding custom attributes to Intercom user with id: " + userId + " - " + e.getMessage()); } }