@Override public List<Category> findChildren(final Identifiable<Category> category) { final String categoryId = category.getId(); return childrenByParentId.getOrDefault(categoryId, Collections.emptyList()); }
@Override public List<Category> findChildren(final Identifiable<Category> category) { final String categoryId = category.getId(); return childrenByParentId.getOrDefault(categoryId, Collections.emptyList()); }
@Override public List<Category> findChildren(final Identifiable<Category> category) { final String categoryId = category.getId(); return childrenByParentId.getOrDefault(categoryId, Collections.emptyList()); } }
static Category getCategoryOrThrow(final Identifiable<Category> category, final CategoryTree categoryTree) { return categoryTree.findById(category.getId()) .orElseThrow(() -> new IllegalArgumentException(format("%s is not part of the category tree", category))); } }
static Category getCategoryOrThrow(final Identifiable<Category> category, final CategoryTree categoryTree) { return categoryTree.findById(category.getId()) .orElseThrow(() -> new IllegalArgumentException(format("%s is not part of the category tree", category))); } }
static TaxCategoryByIdGet of(final Identifiable<TaxCategory> resource) { return of(resource.getId()); }
static MessageByIdGet of(final Identifiable<Message> resource) { return of(resource.getId()); }
static ProductByIdGet of(final Identifiable<Product> product) { return of(product.getId()); }
static ZoneByIdGet of(final Identifiable<Zone> resource) { return of(resource.getId()); }
static StateByIdGet of(final Identifiable<State> state) { return of(state.getId()); }
static MessageByIdGet of(final Identifiable<Message> message) { return of(message.getId()); }
static CustomerGroupByIdGet of(final Identifiable<CustomerGroup> customerGroup) { return of(customerGroup.getId()); }
static ShippingMethodByIdGet of(final Identifiable<ShippingMethod> shippingMethod) { return of(shippingMethod.getId()); }
static CartByCustomerIdGet of(final Identifiable<Customer> customer) { return of(customer.getId()); }
@Override public List<Category> findSiblings(final Collection<? extends Identifiable<Category>> categoryIdentifiables) { return categoryIdentifiables.stream() .flatMap(category -> getSiblings(CategoryTreeUtils.getCategoryOrThrow(category, this)).stream()) .distinct() .filter(sibling -> !categoryIdentifiables.stream().anyMatch(c -> sibling.getId().equals(c.getId()))) .collect(toList()); }
@Override public List<Category> findSiblings(final Collection<? extends Identifiable<Category>> categoryIdentifiables) { return categoryIdentifiables.stream() .flatMap(category -> getSiblings(CategoryTreeUtils.getCategoryOrThrow(category, this)).stream()) .distinct() .filter(sibling -> !categoryIdentifiables.stream().anyMatch(c -> sibling.getId().equals(c.getId()))) .collect(toList()); }
public static ExperimentalProductImageUploadCommand of(final Identifiable<Product> product, final int variantId, final Optional<String> filename, final ProductUpdateScope productUpdateScope, final String contentType, final File img) { return of(product.getId(), variantId, filename, productUpdateScope, contentType, img); } }
/** * Creates a command object to create a token to verify a customer's email. * No optimistic version control is used. * @param customer customer * @param timeToLiveInMinutes the time in minutes the token is valid, platform limitation apply * @return command */ public static CustomerCreateEmailTokenCommand of(final Identifiable<Customer> customer, final Integer timeToLiveInMinutes) { final Long version = customer != null && customer instanceof Versioned ? ((Versioned<Customer>)customer).getVersion() :null; return new CustomerCreateEmailTokenCommand(customer.getId(), version, timeToLiveInMinutes); }
@Override public QueryPredicate<T> is(final Identifiable<T> identifiable) { return id().is(identifiable.getId()); }
/** * Gets from a {@link PagedResult} the last ID if the result is not the last page. * This does only work correctly if it was sorted by ID in ascending order. * @param pagedResult the result to extract the id * @return the last ID, if present */ private <T extends Identifiable<T>> String getIdForNextQuery(final PagedResult<T> pagedResult) { final List<T> results = pagedResult.getResults(); final int indexLastElement = results.size() - 1; return results.get(indexLastElement).getId(); } }