public String getSubjectTemplate(QuotaThreshold quotaThreshold) { return OptionalUtils.or( Optional.ofNullable( toRenderingInformation.get(quotaThreshold)) .flatMap(RenderingInformation::getSubjectTemplate), subjectTemplate) .orElse(DEFAULT_SUBJECT_TEMPLATE); }
public String getBodyTemplate(QuotaThreshold quotaThreshold) { return OptionalUtils.or( Optional.ofNullable( toRenderingInformation.get(quotaThreshold)) .flatMap(RenderingInformation::getBodyTemplate), bodyTemplate) .orElse(DEFAULT_BODY_TEMPLATE); }
public Keywords computeKeywords(Optional<Keywords> keywords, Optional<OldKeyword> oldKeywords) { Preconditions.checkArgument(!(keywords.isPresent() && oldKeywords.isPresent()), "Does not support keyword and is* at the same time"); return OptionalUtils .or(keywords, oldKeywords.map(OldKeyword::asKeywords)) .orElse(Keywords.DEFAULT_VALUE); }
private AddressHeader(String fullAddress) { this.fullAddress = fullAddress; Optional<InternetAddress> internetAddress = parseFullAddress(); this.address = internetAddress.map(InternetAddress::getAddress); this.personal = OptionalUtils.or( internetAddress.map(InternetAddress::getPersonal), address, Optional.of(fullAddress)); }
public Properties getOverrides() { Properties properties = new Properties(); properties.setProperty(KeystoneProperties.KEYSTONE_VERSION, "3"); OptionalUtils.or( project.map(project -> setScope(project)), domainId.map(domain -> setScope(domain)) ).ifPresent(scopeProps -> properties.putAll(scopeProps) ); return properties; }
@Override public Optional<QuotaSize> getMaxStorage(QuotaRoot quotaRoot) { return OptionalUtils.or( Optional.ofNullable(userMaxStorage.get(quotaRoot.getValue())), quotaRoot.getDomain().flatMap(this::getDomainMaxStorage), maxStorage); }
private MailboxPath getMailboxPath(Map<MailboxCreationId, MailboxId> creationIdsToCreatedMailboxId, MailboxSession mailboxSession, MailboxCreationId parentId) throws MailboxException { Optional<MailboxId> mailboxId = OptionalUtils.or( readCreationIdAsMailboxId(parentId), Optional.ofNullable(creationIdsToCreatedMailboxId.get(parentId))); return getMailboxPathFromId(mailboxId, mailboxSession) .orElseThrow(() -> new MailboxParentNotFoundException(parentId)); }
@Test void orShouldReturnEmptyWhenBothEmpty() { assertThat( OptionalUtils.or( Optional.empty(), Optional.empty())) .isEmpty(); }
@Test void orShouldReturnFirstValueWhenBothValues() { assertThat( OptionalUtils.or( Optional.of(1), Optional.of(2))) .contains(1); }
@Test public void orShouldReturnFirstValueWhenBothValues() { assertThat( OptionalUtils.or( Optional.of(1), Optional.of(2))) .contains(1); }
@Test void orShouldReturnSecondValueWhenOnlySecondValue() { assertThat( OptionalUtils.or( Optional.empty(), Optional.of(18))) .contains(18); }
@Test public void orShouldReturnEmptyWhenBothEmpty() { assertThat( OptionalUtils.or( Optional.empty(), Optional.empty())) .isEmpty(); }
@Test void orShouldReturnFirstValueWhenOnlyFirstValue() { assertThat( OptionalUtils.or( Optional.of(18), Optional.empty())) .contains(18); }
@Test public void orShouldReturnFirstValueWhenOnlyFirstValue() { assertThat( OptionalUtils.or( Optional.of(18), Optional.empty())) .contains(18); }
@Test void orShouldReturnEmptyWhenEmpty() { assertThat( OptionalUtils.or( Optional.empty())) .isEmpty(); }
@Test void orShouldReturnValueWhenValue() { assertThat( OptionalUtils.or( Optional.of(1))) .contains(1); }
@Test public void orShouldReturnValueWhenValue() { assertThat( OptionalUtils.or( Optional.of(1))) .contains(1); }
@Test public void orSuppliersShouldReturnEmptyWhenNoParameter() { assertThat(OptionalUtils.or()) .isEmpty(); }
@Test void orShouldReturnEmptyWhenNoParameter() { assertThat(OptionalUtils.or()) .isEmpty(); }
@Test void orSuppliersShouldReturnEmptyWhenNoParameter() { assertThat(OptionalUtils.or()) .isEmpty(); }