Source:
private Optional<RingTime> getRingTimeFromAttributes(final String deviceId, final long accountId, final Map<String, AttributeValue> item){ final HashSet<String> requiredAttributes = new HashSet<String>(); Collections.addAll(requiredAttributes, ACTUAL_RING_TIME_ATTRIBUTE_NAME, EXPECTED_RING_TIME_ATTRIBUTE_NAME, SOUND_IDS_ATTRIBUTE_NAME); if(!item.keySet().containsAll(requiredAttributes)){ return Optional.absent(); } final long expected = Long.valueOf(item.get(EXPECTED_RING_TIME_ATTRIBUTE_NAME).getN()); final long actual = Long.valueOf(item.get(ACTUAL_RING_TIME_ATTRIBUTE_NAME).getN()); final String soundArrayJSON = item.get(SOUND_IDS_ATTRIBUTE_NAME).getS(); try { final long[] soundIds = this.objectMapper.readValue(soundArrayJSON, long[].class); boolean isSmart = false; if(item.containsKey(IS_SMART_ALARM_ATTRIBUTE_NAME)){ isSmart = item.get(IS_SMART_ALARM_ATTRIBUTE_NAME).getBOOL(); } final Optional<DateTimeZone> dateTimeZoneOptional = getTimeZoneFromAttributes(deviceId, accountId, item); List<AlarmExpansion> expansions = Lists.newArrayList(); if(!dateTimeZoneOptional.isPresent()) { return Optional.of(new RingTime(actual, expected, soundIds, isSmart, expansions)); } final DateTime expectedRingTime = new DateTime(expected, dateTimeZoneOptional.get()); final String alarmListJSON = item.get(ALARM_TEMPLATES_ATTRIBUTE_NAME).getS(); final List<Alarm> alarmList = this.objectMapper.readValue(alarmListJSON, new TypeReference<List<Alarm>>(){}); expansions = Alarm.Utils.getExpansionsAtExpectedTime(expectedRingTime, alarmList); return Optional.of(new RingTime(actual, expected, soundIds, isSmart, expansions)); } catch (IOException e) { LOGGER.error("Deserialize JSON for ring time failed {}, device {}, account id {}.", e.getMessage(), deviceId, accountId); } return Optional.absent(); }

Target:
private Optional<RingTime> getRingTimeFromAttributes(final String deviceId, final long accountId, final Map<String, AttributeValue> item){ final HashSet<String> requiredAttributes = new HashSet<String>(); Collections.addAll(requiredAttributes, ACTUAL_RING_TIME_ATTRIBUTE_NAME, EXPECTED_RING_TIME_ATTRIBUTE_NAME, SOUND_IDS_ATTRIBUTE_NAME); if(!item.keySet().containsAll(requiredAttributes)){ return Optional.absent(); } final long expected = Long.valueOf(item.get(EXPECTED_RING_TIME_ATTRIBUTE_NAME).getN()); final long actual = Long.valueOf(item.get(ACTUAL_RING_TIME_ATTRIBUTE_NAME).getN()); final String soundArrayJSON = item.get(SOUND_IDS_ATTRIBUTE_NAME).getS(); try { final long[] soundIds = this.objectMapper.readValue(soundArrayJSON, long[].class); boolean isSmart = false; if(item.containsKey(IS_SMART_ALARM_ATTRIBUTE_NAME)){ isSmart = item.get(IS_SMART_ALARM_ATTRIBUTE_NAME).getBOOL(); } final Optional<DateTimeZone> dateTimeZoneOptional = getTimeZoneFromAttributes(deviceId, accountId, item); if(!dateTimeZoneOptional.isPresent()) { return Optional.of(new RingTime(actual, expected, soundIds, isSmart)); } final DateTime expectedRingTime = new DateTime(expected, dateTimeZoneOptional.get()); final String alarmListJSON = item.get(ALARM_TEMPLATES_ATTRIBUTE_NAME).getS(); final List<Alarm> alarmList = this.objectMapper.readValue(alarmListJSON, new TypeReference<List<Alarm>>(){}); final List<AlarmExpansion> expansions = Alarm.Utils.getExpansionsAtExpectedTime(expectedRingTime, alarmList); return Optional.of(new RingTime(actual, expected, soundIds, isSmart, expansions)); } catch (IOException e) { LOGGER.error("Deserialize JSON for ring time failed {}, device {}, account id {}.", e.getMessage(), deviceId, accountId); } return Optional.absent(); }