public void testCountTrue() { assertEquals(0, Booleans.countTrue()); assertEquals(0, Booleans.countTrue(false)); assertEquals(1, Booleans.countTrue(true)); assertEquals(3, Booleans.countTrue(false, true, false, true, false, true)); assertEquals(1, Booleans.countTrue(false, false, true, false, false)); }
/** * Return the number of indexes that needs to be updated * * @return number of indexes to be updated */ public int getAffectedIndexCount() { return Booleans.countTrue(indexIssues, indexChangeHistory, indexComments, indexWorklogs); }
public static boolean hasArgumentTypes(Type[] types, Type... want) { boolean[] found = new boolean[want.length]; for (Type t : types) { for (int i = 0; i < want.length; i++) { if (!found[i] && t.equals(want[i])) { found[i] = true; } } } return Booleans.countTrue(found) == found.length; }
private Message(Builder builder) { this.data = builder.data.isEmpty() ? null : ImmutableMap.copyOf(builder.data); this.notification = builder.notification; this.androidConfig = builder.androidConfig; this.webpushConfig = builder.webpushConfig; this.apnsConfig = builder.apnsConfig; int count = Booleans.countTrue( !Strings.isNullOrEmpty(builder.token), !Strings.isNullOrEmpty(builder.topic), !Strings.isNullOrEmpty(builder.condition) ); checkArgument(count == 1, "Exactly one of token, topic or condition must be specified"); this.token = builder.token; this.topic = stripPrefix(builder.topic); this.condition = builder.condition; }
public DeleteMailsFromMailQueueTask(ManageableMailQueue queue, Optional<MailAddress> maybeSender, Optional<String> maybeName, Optional<MailAddress> maybeRecipient) { Preconditions.checkArgument( Booleans.countTrue(maybeSender.isPresent(), maybeName.isPresent(), maybeRecipient.isPresent()) == 1, "You should provide one and only one of the query parameters 'sender', 'name' or 'recipient'."); this.queue = queue; this.maybeSender = maybeSender; this.maybeName = maybeName; this.maybeRecipient = maybeRecipient; additionalInformation = new AdditionalInformation(queue.getName(), this::getRemainingSize, maybeSender, maybeName, maybeRecipient); }
public void testCountTrue() { assertEquals(0, Booleans.countTrue()); assertEquals(0, Booleans.countTrue(false)); assertEquals(1, Booleans.countTrue(true)); assertEquals(3, Booleans.countTrue(false, true, false, true, false, true)); assertEquals(1, Booleans.countTrue(false, false, true, false, false)); }
private Task deleteMailsTask(ManageableMailQueue queue, Optional<MailAddress> maybeSender, Optional<String> maybeName, Optional<MailAddress> maybeRecipient) { int paramCount = Booleans.countTrue(maybeSender.isPresent(), maybeName.isPresent(), maybeRecipient.isPresent()); switch (paramCount) { case 0: return new ClearMailQueueTask(queue); case 1: return new DeleteMailsFromMailQueueTask(queue, maybeSender, maybeName, maybeRecipient); default: throw ErrorResponder.builder() .statusCode(HttpStatus.BAD_REQUEST_400) .type(ErrorType.INVALID_ARGUMENT) .message("You should provide only one of the query parameters 'sender', 'name', 'recipient' " + "for deleting mails by condition or no parameter for deleting all mails in the mail queue.") .haltError(); } }
Booleans.countTrue( doc.isConsistentIdGenerator(), doc.isIdGenerator(),
Booleans.countTrue( doc.isConsistentIdGenerator(), doc.isIdGenerator(),
Booleans.countTrue( protoPosition.hasLatitude(), protoPosition.hasLatitude(),