Source:
<code>public GeneratedAlgorithm generate(Attribute targetAttribute, Hits<ExplainedAttribute> sourceAttributes, EntityType targetEntityType, EntityType sourceEntityType) { if (targetAttribute.hasExpression()) { throw new AlgorithmException(format("Algorithm generation for expressed attribute '%s' is not allowed", targetAttribute.getName())); } String algorithm = StringUtils.EMPTY; AlgorithmState algorithmState = null; Set<Attribute> mappedSourceAttributes = null; <START> if (sourceAttributes.getHits().size() > 0) <END> { AlgorithmTemplate algorithmTemplate = algorithmTemplateService.find(sourceAttributes) .findFirst() .orElse(null); if (algorithmTemplate != null) { algorithm = algorithmTemplate.render(); mappedSourceAttributes = AlgorithmGeneratorHelper.extractSourceAttributesFromAlgorithm(algorithm, sourceEntityType); algorithm = convertUnitForTemplateAlgorithm(algorithm, targetAttribute, targetEntityType, mappedSourceAttributes, sourceEntityType); algorithmState = GENERATED_HIGH; } else { ExplainedAttribute attributeSearchHit = sourceAttributes.getHits().iterator().next().getResult(); Attribute sourceAttribute = attributeSearchHit.getAttribute(); algorithm = generate(targetAttribute, Arrays.asList(sourceAttribute), targetEntityType, sourceEntityType); mappedSourceAttributes = AlgorithmGeneratorHelper.extractSourceAttributesFromAlgorithm(algorithm, sourceEntityType); algorithmState = attributeSearchHit.isHighQuality() ? GENERATED_HIGH : GENERATED_LOW; } } return GeneratedAlgorithm.create(algorithm, mappedSourceAttributes, algorithmState); }</code><technical_language>![MINOR](<LINK_1> 'Severity: MINOR') isEmpty() check collection is empty not. [![rule](<LINK_0>](<LINK_2></technical_language>

Target:
public GeneratedAlgorithm generate(Attribute targetAttribute, Hits<ExplainedAttribute> sourceAttributes, EntityType targetEntityType, EntityType sourceEntityType) { if (targetAttribute.hasExpression()) { throw new AlgorithmException(format("Algorithm generation for expressed attribute '%s' is not allowed", targetAttribute.getName())); } String algorithm = StringUtils.EMPTY; AlgorithmState algorithmState = null; Set<Attribute> mappedSourceAttributes = null; if (!sourceAttributes.getHits().isEmpty()) { AlgorithmTemplate algorithmTemplate = algorithmTemplateService.find(sourceAttributes) .findFirst() .orElse(null); if (algorithmTemplate != null) { algorithm = algorithmTemplate.render(); mappedSourceAttributes = AlgorithmGeneratorHelper.extractSourceAttributesFromAlgorithm(algorithm, sourceEntityType); algorithm = convertUnitForTemplateAlgorithm(algorithm, targetAttribute, targetEntityType, mappedSourceAttributes, sourceEntityType); algorithmState = GENERATED_HIGH; } else { ExplainedAttribute attributeSearchHit = sourceAttributes.getHits().iterator().next().getResult(); Attribute sourceAttribute = attributeSearchHit.getAttribute(); algorithm = generate(targetAttribute, Arrays.asList(sourceAttribute), targetEntityType, sourceEntityType); mappedSourceAttributes = AlgorithmGeneratorHelper.extractSourceAttributesFromAlgorithm(algorithm, sourceEntityType); algorithmState = attributeSearchHit.isHighQuality() ? GENERATED_HIGH : GENERATED_LOW; } } return GeneratedAlgorithm.create(algorithm, mappedSourceAttributes, algorithmState); }