Source:
<code>private InsightCard createInsightCard(Map<String, AttributeValue> item) { final InsightCard.Category category = InsightCard.Category.fromInteger(Integer.valueOf(item.get(CATEGORY_ATTRIBUTE_NAME).getN())); final InsightCard.TimePeriod timePeriod = InsightCard.TimePeriod.fromString(item.get(TIME_PERIOD_ATTRIBUTE_NAME).getS()); final String image1x = item.containsKey(IMAGE_PHONE_DENSITY_1X_ATTRIBUTE_NAME) ? item.get(IMAGE_PHONE_DENSITY_1X_ATTRIBUTE_NAME).getS() : null; final String image2x = item.containsKey(IMAGE_PHONE_DENSITY_2X_ATTRIBUTE_NAME) ? item.get(IMAGE_PHONE_DENSITY_2X_ATTRIBUTE_NAME).getS() : null; final String image3x = item.containsKey(IMAGE_PHONE_DENSITY_3X_ATTRIBUTE_NAME) ? item.get(IMAGE_PHONE_DENSITY_3X_ATTRIBUTE_NAME).getS() : null; final Optional<MultiDensityImage> image; if (image1x != null || image2x != null || image3x != null) { image = Optional.of(new MultiDensityImage(Optional.fromNullable(image1x), Optional.fromNullable(image2x), Optional.fromNullable(image3x))); } else { image = Optional.absent(); } final String insightTypeString = item.containsKey(INSIGHT_TYPE_ATTRIBUTE_NAME) ? item.get(INSIGHT_TYPE_ATTRIBUTE_NAME).getS() <START> : null; <END> final InsightCard.InsightType insightType; if (insightTypeString != null) { insightType = InsightCard.InsightType.fromString(insightTypeString); } else { insightType = InsightCard.InsightType.DEFAULT; } return new InsightCard( Long.valueOf(item.get(ACCOUNT_ID_ATTRIBUTE_NAME).getN()), item.get(TITLE_ATTRIBUTE_NAME).getS(), item.get(MESSAGE_ATTRIBUTE_NAME).getS(), category, timePeriod, new DateTime(item.get(TIMESTAMP_UTC_ATTRIBUTE_NAME).getS(), DateTimeZone.UTC), Optional.<String>absent(), image, insightType ); }</code><technical_language>Avoid null possible</technical_language>

Target:
private InsightCard createInsightCard(Map<String, AttributeValue> item) { final InsightCard.Category category = InsightCard.Category.fromInteger(Integer.valueOf(item.get(CATEGORY_ATTRIBUTE_NAME).getN())); final InsightCard.TimePeriod timePeriod = InsightCard.TimePeriod.fromString(item.get(TIME_PERIOD_ATTRIBUTE_NAME).getS()); final String image1x = item.containsKey(IMAGE_PHONE_DENSITY_1X_ATTRIBUTE_NAME) ? item.get(IMAGE_PHONE_DENSITY_1X_ATTRIBUTE_NAME).getS() : null; final String image2x = item.containsKey(IMAGE_PHONE_DENSITY_2X_ATTRIBUTE_NAME) ? item.get(IMAGE_PHONE_DENSITY_2X_ATTRIBUTE_NAME).getS() : null; final String image3x = item.containsKey(IMAGE_PHONE_DENSITY_3X_ATTRIBUTE_NAME) ? item.get(IMAGE_PHONE_DENSITY_3X_ATTRIBUTE_NAME).getS() : null; final Optional<MultiDensityImage> image; if (image1x != null || image2x != null || image3x != null) { image = Optional.of(new MultiDensityImage(Optional.fromNullable(image1x), Optional.fromNullable(image2x), Optional.fromNullable(image3x))); } else { image = Optional.absent(); } final Optional<String> optionalType = item.containsKey(INSIGHT_TYPE_ATTRIBUTE_NAME) ? Optional.of(item.get(INSIGHT_TYPE_ATTRIBUTE_NAME).getS()) : Optional.<String>absent(); final InsightCard.InsightType insightType = InsightsDAODynamoDB.generateInsightType(category, optionalType); return new InsightCard( Long.valueOf(item.get(ACCOUNT_ID_ATTRIBUTE_NAME).getN()), item.get(TITLE_ATTRIBUTE_NAME).getS(), item.get(MESSAGE_ATTRIBUTE_NAME).getS(), category, timePeriod, new DateTime(item.get(TIMESTAMP_UTC_ATTRIBUTE_NAME).getS(), DateTimeZone.UTC), Optional.<String>absent(), image, insightType ); }