Source:
<code>public void validate(List<AccountTag> accountTags) { for (AccountTagResponse defaultTag : getDefaults().getResponses()) { Optional<AccountTag> requestContainsUnmodifiableTag = accountTags .stream() .filter(e -> e.getTagKey().equals(defaultTag.getKey())) .findFirst(); if (requestContainsUnmodifiableTag.isPresent()) { throw new BadRequestException(String.format("Tag with %s key exist as an unmodifiable tag.", defaultTag.getKey())); } } for (AccountTag accountTag : accountTags) { Pattern pattern = Pattern.compile(ACCOUNT_TAG_PATTERN); Matcher keyMatcher = pattern.matcher(accountTag.getTagKey()); Matcher valueMatcher = pattern.matcher(accountTag.getTagValue()); if (!keyMatcher.matches()) { throw new BadRequestException( String.format("The key '%s' can only can not start with microsoft or azure or aws or windows or space", accountTag.getTagKey())); } if (!valueMatcher.matches()) { throw new BadRequestException( String.format("The value '%s' can only can not start with microsoft or azure or aws or windows or space", accountTag.getTagValue())); } if (isAccountTagContainsTemplate(accountTag.getTagKey())) { <START> if (isAccountTagInvalid(accountTag.getTagKey())) { <END> throw new BadRequestException( String.format("The key '%s' of the tag contains invalid templates", accountTag.getTagKey())); } } if (isAccountTagContainsTemplate(accountTag.getTagValue())) { if (isAccountTagInvalid(accountTag.getTagValue())) { throw new BadRequestException( String.format("The value '%s' of the tag contains invalid templates", accountTag.getTagValue())); } } } }</code><technical_language>isAccountTagContainsTemplate(accountTag.getTagKey()) && isAccountTagInvalid(accountTag.getTagKey()) is</technical_language>

Target:
public void validate(List<AccountTag> accountTags) { for (AccountTagResponse defaultTag : getDefaults().getResponses()) { Optional<AccountTag> requestContainsUnmodifiableTag = accountTags .stream() .filter(e -> e.getTagKey().equals(defaultTag.getKey())) .findFirst(); if (requestContainsUnmodifiableTag.isPresent()) { throw new BadRequestException(String.format("Tag with %s key exist as an unmodifiable tag.", defaultTag.getKey())); } } for (AccountTag accountTag : accountTags) { Pattern pattern = Pattern.compile(ACCOUNT_TAG_PATTERN); Matcher keyMatcher = pattern.matcher(accountTag.getTagKey()); Matcher valueMatcher = pattern.matcher(accountTag.getTagValue()); if (!keyMatcher.matches()) { throw new BadRequestException( String.format("The key '%s' can only can not start with microsoft or azure or aws or windows or space", accountTag.getTagKey())); } if (!valueMatcher.matches()) { throw new BadRequestException( String.format("The value '%s' can only can not start with microsoft or azure or aws or windows or space", accountTag.getTagValue())); } if (isAccountTagContainsTemplate(accountTag.getTagKey()) && isAccountTagInvalid(accountTag.getTagKey())) { throw new BadRequestException( String.format("The key '%s' of the tag contains invalid templates", accountTag.getTagKey())); } if (isAccountTagContainsTemplate(accountTag.getTagValue()) && isAccountTagInvalid(accountTag.getTagValue())) { throw new BadRequestException( String.format("The value '%s' of the tag contains invalid templates", accountTag.getTagValue())); } } }