Skip to content

Commit

Permalink
feat(#549): corrected sorting over immutable collection
Browse files Browse the repository at this point in the history
  • Loading branch information
novoj committed May 31, 2024
1 parent 7781489 commit d2f745e
Showing 1 changed file with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,11 @@ public EntityDecorator(
* Creates wrapper around {@link Entity} that filters existing data according passed predicates (which are constructed
* to match query that is used to retrieve the decorator).
*
* @param entity fully or partially loaded entity - it's usually wider than decorator (may be even complete), decorator
* might be obtained from shared global cache
* @param parentEntity object of the parentEntity
* @param referenceFetcher fetcher that can be used for fetching, filtering and ordering referenced
* entities / groups
* @param entity fully or partially loaded entity - it's usually wider than decorator (may be even complete), decorator
* might be obtained from shared global cache
* @param parentEntity object of the parentEntity
* @param referenceFetcher fetcher that can be used for fetching, filtering and ordering referenced
* entities / groups
*/
public EntityDecorator(
@Nonnull EntityDecorator entity,
Expand Down Expand Up @@ -1085,14 +1085,17 @@ public List<PriceContract> getAllPricesForSale(@Nonnull Currency currency, @Null
pricePredicate.checkFetched(currency, priceListPriority);
final List<PriceContract> allPricesForSale = SealedEntity.super.getAllPricesForSale(currency, atTheMoment, priceListPriority);
if (allPricesForSale.size() > 1) {
allPricesForSale.sort(
Comparator.comparing(
pricePredicate.getQueryPriceMode() == QueryPriceMode.WITH_TAX ?
PriceContract::priceWithTax : PriceContract::priceWithoutTax
)
);
return allPricesForSale
.stream()
.sorted(
Comparator.comparing(
pricePredicate.getQueryPriceMode() == QueryPriceMode.WITH_TAX ?
PriceContract::priceWithTax : PriceContract::priceWithoutTax
)
).toList();
} else {
return allPricesForSale;
}
return allPricesForSale;
}

@Nonnull
Expand Down

0 comments on commit d2f745e

Please sign in to comment.