/** * Removes all values associated with the specified key. * <p> * A subsequent <code>get(Object)</code> would return an empty collection. * * @param key the key to remove values from * @return the <code>Collection</code> of values removed, will return an * empty, unmodifiable collection for no mapping found */ @Override public Collection<V> remove(final Object key) { return CollectionUtils.emptyIfNull(getMap().remove(key)); }
@Override public Integer calculateNumShippableFulfillmentGroups(Order order) { Integer numShippableFulfillmentGroups = 0; List<FulfillmentGroup> fulfillmentGroups = order.getFulfillmentGroups(); for (FulfillmentGroup fulfillmentGroup : CollectionUtils.emptyIfNull(fulfillmentGroups)) { if (isShippable(fulfillmentGroup.getType())) { numShippableFulfillmentGroups++; } } return numShippableFulfillmentGroups; }
@Override public boolean cartHasCreditCardPayment() { Order cart = CartState.getCart(); List<OrderPayment> orderPayments = orderPaymentService.readPaymentsForOrder(cart); for (OrderPayment payment : CollectionUtils.emptyIfNull(orderPayments)) { boolean isCreditCartPayment = PaymentType.CREDIT_CARD.equals(payment.getType()); if (payment.isActive() && isCreditCartPayment) { return true; } } return false; }
@Override public boolean cartHasThirdPartyPayment() { Order cart = CartState.getCart(); List<OrderPayment> orderPayments = orderPaymentService.readPaymentsForOrder(cart); for (OrderPayment payment : CollectionUtils.emptyIfNull(orderPayments)) { if (payment.isActive() && PaymentType.THIRD_PARTY_ACCOUNT.equals(payment.getType())) { return true; } } return false; }
protected Address getAddressFromCCOrderPayment(Order cart) { List<OrderPayment> orderPayments = orderPaymentService.readPaymentsForOrder(cart); for (OrderPayment payment : CollectionUtils.emptyIfNull(orderPayments)) { boolean isCreditCardPaymentType = PaymentType.CREDIT_CARD.equals(payment.getType()); boolean paymentHasBillingAddress = (payment.getBillingAddress() != null); if (payment.isActive() && isCreditCardPaymentType && paymentHasBillingAddress) { return payment.getBillingAddress(); } } return null; }
@Override public boolean cartHasPopulatedShippingAddress() { Order cart = CartState.getCart(); for (FulfillmentGroup fulfillmentGroup : CollectionUtils.emptyIfNull(cart.getFulfillmentGroups())) { if (fulfillmentGroupService.isShippable(fulfillmentGroup.getType())) { if (fulfillmentGroup.getAddress() != null && fulfillmentGroup.getFulfillmentOption() != null) { return true; } } } return false; }
@Override public boolean cartHasPopulatedBillingAddress() { Order cart = CartState.getCart(); List<OrderPayment> orderPayments = orderPaymentService.readPaymentsForOrder(cart); for (OrderPayment payment : CollectionUtils.emptyIfNull(orderPayments)) { boolean isCreditCardPayment = PaymentType.CREDIT_CARD.equals(payment.getType()); boolean paymentHasBillingAddress = (payment.getBillingAddress() != null); if (payment.isActive() && isCreditCardPayment && paymentHasBillingAddress) { return true; } } return false; }
@Override public boolean cartHasTemporaryCreditCard() { Order cart = CartState.getCart(); List<OrderPayment> orderPayments = orderPaymentService.readPaymentsForOrder(cart); for (OrderPayment payment : CollectionUtils.emptyIfNull(orderPayments)) { boolean isCreditCartPayment = PaymentType.CREDIT_CARD.equals(payment.getType()); boolean isTemporaryPaymentGateway = PaymentGatewayType.TEMPORARY.equals(payment.getGatewayType()); if (payment.isActive() && isCreditCartPayment && isTemporaryPaymentGateway) { return true; } } return false; }
protected OrderPayment getUnconfirmedCCFromCart() { OrderPayment unconfirmedCC = null; Order cart = CartState.getCart(); List<OrderPayment> orderPayments = orderPaymentService.readPaymentsForOrder(cart); for (OrderPayment payment : CollectionUtils.emptyIfNull(orderPayments)) { boolean isCreditCartPayment = PaymentType.CREDIT_CARD.equals(payment.getType()); boolean isTemporaryPaymentGateway = PaymentGatewayType.TEMPORARY.equals(payment.getGatewayType()); if (payment.isActive() && isCreditCartPayment && !isTemporaryPaymentGateway) { unconfirmedCC = payment; } } return unconfirmedCC; }
public void setOrdering(Collection<? extends ObjectOrdering> orderings) { this.ordering.clear(); for (ObjectOrdering ordering : CollectionUtils.emptyIfNull(orderings)) { this.ordering.add((ObjectOrderingImpl) ordering); } }
public void setGrouping(Collection<ObjectGrouping> groupings) { this.grouping.clear(); for (ObjectGrouping grouping : CollectionUtils.emptyIfNull(groupings)) { this.grouping.add((ObjectGroupingImpl) grouping); } }
public DiscoverySearchFilter getSearchFilter(String name) { for (DiscoverySearchFilter filter : CollectionUtils.emptyIfNull(searchFilters)) { if (StringUtils.equals(name, filter.getIndexFieldName())) { return filter; } } return null; }
@Override protected Set<String> findConnectionHeaders(final HttpServletRequest clientRequest) { final Set<String> ignoreRequestHeader = new HashSet<>(); ignoreRequestHeader.addAll(CollectionUtils.emptyIfNull(super.findConnectionHeaders(clientRequest))); // Drop cookie headers forward from FRONT to BACK by default, only filtered ones will be added ignoreRequestHeader.add(HEADER_COOKIE); return ignoreRequestHeader; } }
/** * Convert the given user UIDs to a the corresponding DN. The users must exists. * * @param uids * The UIDs to convert. * @return The corresponding DN. */ private List<String> toDn(final List<String> uids) { return CollectionUtils.emptyIfNull(uids).stream().map(getUser()::findByIdExpected).map(UserOrg::getDn) .collect(Collectors.toList()); } }
void trimItemsDefinitionsTrees(Collection<? extends ItemPath> alwaysKeep) { // to play safe, we won't touch PCV-specific complexTypeDefinition for (Item<?, ?> item : CollectionUtils.emptyIfNull(items)) { if (item instanceof PrismContainer) { Collection<ItemPath> alwaysKeepInSub = ItemPathCollectionsUtil.remainder(CollectionUtils.emptyIfNull(alwaysKeep), item.getElementName(), false); ((PrismContainer<?>) item).trimDefinitionTree(alwaysKeepInSub); } } }
@NotNull private List<? extends ItemPath> getPathsToResolve(Collection<SelectorOptions<GetOperationOptions>> options) { final UniformItemPath EMPTY_PATH = prismContext.emptyPath(); List<UniformItemPath> rv = new ArrayList<>(); for (SelectorOptions<GetOperationOptions> option : CollectionUtils.emptyIfNull(options)) { if (GetOperationOptions.isResolveNames(option.getOptions())) { rv.add(option.getItemPath(EMPTY_PATH)); } } return rv; } }
public static void displayObjectTypeCollection(String message, Collection<? extends ObjectType> collection) { System.out.println(OBJECT_TITLE_OUT_PREFIX + message); LOGGER.debug(OBJECT_TITLE_LOG_PREFIX + message); for (ObjectType o : CollectionUtils.emptyIfNull(collection)) { System.out.println(ObjectTypeUtil.dump(o)); LOGGER.debug(ObjectTypeUtil.dump(o)); System.out.println(OBJECT_LIST_SEPARATOR); LOGGER.debug(OBJECT_LIST_SEPARATOR); } }
private <T> void assertUnsortedListsEquals(String message, Collection<String> expected, Collection<T> real, Function<T, String> nameExtractor) { Bag<String> expectedAsBag = new TreeBag<>(CollectionUtils.emptyIfNull(expected)); Bag<String> realAsBag = new TreeBag<>(real.stream().map(nameExtractor).collect(Collectors.toList())); assertEquals(message, expectedAsBag, realAsBag); }
private void assertTargetPolicyRules(EvaluatedAssignmentImpl<? extends FocusType> evaluatedAssignment, Collection<String> expectedThisTargetItems, Collection<String> expectedOtherTargetsItems) { expectedOtherTargetsItems = CollectionUtils.emptyIfNull(expectedOtherTargetsItems); expectedThisTargetItems = CollectionUtils.emptyIfNull(expectedThisTargetItems); assertUnsortedListsEquals("Wrong other targets policy rules", expectedOtherTargetsItems, evaluatedAssignment.getOtherTargetsPolicyRules(), r -> r.getName()); assertUnsortedListsEquals("Wrong this target policy rules", expectedThisTargetItems, evaluatedAssignment.getThisTargetPolicyRules(), r -> r.getName()); }
private <AH extends AssignmentHolderType> boolean pathMatches(ObjectDelta<?> delta, PrismObject<AH> objectOld, ItemPath path, boolean exactPathMatch) throws SchemaException { if (delta.isAdd()) { return delta.getObjectToAdd().containsItem(path, false); } else if (delta.isDelete()) { return objectOld != null && objectOld.containsItem(path, false); } else { return ItemDeltaCollectionsUtil.pathMatches(emptyIfNull(delta.getModifications()), path, 0, exactPathMatch); } }