本文整理匯總了Java中com.google.common.primitives.Booleans.countTrue方法的典型用法代碼示例。如果您正苦於以下問題:Java Booleans.countTrue方法的具體用法?Java Booleans.countTrue怎麽用?Java Booleans.countTrue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.primitives.Booleans
的用法示例。
在下文中一共展示了Booleans.countTrue方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: controleerVerzoekparameters
import com.google.common.primitives.Booleans; //導入方法依賴的package包/類
@Bedrijfsregel(Regel.R1274)
@Bedrijfsregel(Regel.R2377)
@Bedrijfsregel(Regel.R2295)
private void controleerVerzoekparameters(final GeefMedebewonersVerzoek verzoek) throws StapMeldingException {
//Persoonsidentificatie OF Identificatiecode nummeraanduiding OF Adrescriteria moet zijn ingevuld
final int booleanCount = Booleans.countTrue(
verzoek.geefMedebewonersGelijkeBAG(),
verzoek.geefMedebewonersGelijkAdres(),
verzoek.geefMedebewonersVanPersoon(),
verzoek.geefMedebewonersGelijkeIDcodeAdresseerbaarObject());
if (booleanCount != 1) {
throw new StapMeldingException(Regel.R2377);
}
//valideer peilmoment
if (verzoek.getParameters() != null && (verzoek.getParameters().getPeilmomentMaterieel() != null)) {
peilmomentValidatieService.valideerMaterieel(verzoek.getParameters().getPeilmomentMaterieel());
}
}
示例2: getExtraArgs
import com.google.common.primitives.Booleans; //導入方法依賴的package包/類
/** Extract additional signature information for BuiltinFunction-s */
public static ExtraArgKind[] getExtraArgs(SkylarkSignature annotation) {
final int numExtraArgs =
Booleans.countTrue(
annotation.useLocation(), annotation.useAst(), annotation.useEnvironment());
if (numExtraArgs == 0) {
return null;
}
final ExtraArgKind[] extraArgs = new ExtraArgKind[numExtraArgs];
int i = 0;
if (annotation.useLocation()) {
extraArgs[i++] = ExtraArgKind.LOCATION;
}
if (annotation.useAst()) {
extraArgs[i++] = ExtraArgKind.SYNTAX_TREE;
}
if (annotation.useEnvironment()) {
extraArgs[i++] = ExtraArgKind.ENVIRONMENT;
}
return extraArgs;
}
示例3: controleerCorrectGevuld
import com.google.common.primitives.Booleans; //導入方法依賴的package包/類
private boolean controleerCorrectGevuld(final String bsn, final String anummer, final String persoonId) {
final int booleanCount = Booleans.countTrue(bsn != null, anummer != null, persoonId != null);
return booleanCount == 1;
}
示例4: createContextBuilder
import com.google.common.primitives.Booleans; //導入方法依賴的package包/類
private static ContextBuilder createContextBuilder(ObjectProperties objectProperties) {
Properties contextProperties = new Properties();
String allNodeNames = Objects.requireNonNull(objectProperties.getProperty(Config.CloudProvider.BareMetal.NODES),
"The Bare Metal provider requires that all nodes are identified upfront, using the "
+ Config.CloudProvider.BareMetal.NODES + " property");
Iterable<String> nodeNames = Splitter
.on(",")
.omitEmptyStrings()
.trimResults()
.split(allNodeNames);
StringBuilder nodesYaml = new StringBuilder();
nodesYaml.append("nodes:\n");
for (String node : nodeNames) {
ObjectProperties nodeProperties = new ObjectProperties(ObjectType.NODE, node);
String host = Objects.requireNonNull(nodeProperties.getProperty(Config.Node.BareMetal.HOST),
"Host name or IP address must be set for node '" + node + "'");
String sshUser = Objects.requireNonNull(nodeProperties.getProperty(Config.Node.BareMetal.SSH_USER),
"SSH user name must be set for node '" + node + "'");
String sshPassword = nodeProperties.getProperty(Config.Node.BareMetal.SSH_PASSWORD);
String sshPrivateKey = nodeProperties.getProperty(Config.Node.BareMetal.SSH_PRIVATE_KEY);
Path sshPrivateKeyFile = nodeProperties.getPropertyAsPath(Config.Node.BareMetal.SSH_PRIVATE_KEY_FILE, null);
int sshPort = nodeProperties.getPropertyAsInt(Config.Node.BareMetal.SSH_PORT, 22);
if (Booleans.countTrue(sshPassword != null, sshPrivateKey != null, sshPrivateKeyFile != null) != 1) {
throw new IllegalArgumentException("Exactly one of SSH password or private key or private key file must be set for node '" + node + "'");
}
String nodeGroup = NodeGroupUtil.nodeGroupName(nodeProperties, objectProperties);
nodesYaml.append(" - id: ").append(node).append("\n");
nodesYaml.append(" name: ").append(node).append("\n");
nodesYaml.append(" hostname: ").append(host).append("\n");
nodesYaml.append(" os_family: immaterial\n"); // required by JClouds, but immaterial
nodesYaml.append(" os_description: immaterial\n"); // required by JClouds, but immaterial
nodesYaml.append(" group: ").append(nodeGroup).append("\n");
nodesYaml.append(" login_port: ").append(sshPort).append("\n");
nodesYaml.append(" username: ").append(sshUser).append("\n");
if (sshPassword != null) {
nodesYaml.append(" credential: ").append(sshPassword).append("\n");
} else if (sshPrivateKey != null) {
nodesYaml.append(" credential: ").append(sshPrivateKey).append("\n");
} else {
nodesYaml.append(" credential_url: file://").append(sshPrivateKeyFile).append("\n");
}
}
contextProperties.setProperty("byon.nodes", nodesYaml.toString());
return ContextBuilder.newBuilder("byon")
.overrides(contextProperties)
.modules(ImmutableSet.of(
new SLF4JLoggingModule(),
new DynamicSshClientModule(),
new SocketFinderOnlyPublicInterfacesModule()
));
}
示例5: getHiddenCountUpTo
import com.google.common.primitives.Booleans; //導入方法依賴的package包/類
/**
* Get the number of elements that are hidden until a given position
* @param position
* @return number of elements hidden (true in elementInvisibility Map)
*/
private static int getHiddenCountUpTo(int position, LinkedHashMap<BaseModel, Boolean> elementInvisibility) {
boolean [] upper = Arrays.copyOfRange(Booleans.toArray(elementInvisibility.values()), 0, position + 1);
int hiddens = Booleans.countTrue(upper);
return hiddens;
}
示例6: countInvisible
import com.google.common.primitives.Booleans; //導入方法依賴的package包/類
public int countInvisible(){
return Booleans.countTrue(Booleans.toArray(elementInvisibility.values()));
}
示例7: getJsonObjectForResource
import com.google.common.primitives.Booleans; //導入方法依賴的package包/類
/**
* Parses the parameters and calls the appropriate search function.
*
* <p>The RDAP spec allows nameserver search by either name or IP address.
*/
@Override
public ImmutableMap<String, Object> getJsonObjectForResource(
String pathSearchString, boolean isHeadRequest) {
DateTime now = clock.nowUtc();
// RDAP syntax example: /rdap/nameservers?name=ns*.example.com.
// The pathSearchString is not used by search commands.
if (pathSearchString.length() > 0) {
throw new BadRequestException("Unexpected path");
}
if (Booleans.countTrue(nameParam.isPresent(), ipParam.isPresent()) != 1) {
throw new BadRequestException("You must specify either name=XXXX or ip=YYYY");
}
decodeCursorToken();
RdapSearchResults results;
if (nameParam.isPresent()) {
// syntax: /rdap/nameservers?name=exam*.com
metricInformationBuilder.setSearchType(SearchType.BY_NAMESERVER_NAME);
if (!LDH_PATTERN.matcher(nameParam.get()).matches()) {
throw new BadRequestException(
"Name parameter must contain only letters, dots"
+ " and hyphens, and an optional single wildcard");
}
results =
searchByName(
recordWildcardType(RdapSearchPattern.create(Idn.toASCII(nameParam.get()), true)),
now);
} else {
// syntax: /rdap/nameservers?ip=1.2.3.4
metricInformationBuilder.setSearchType(SearchType.BY_NAMESERVER_ADDRESS);
InetAddress inetAddress;
try {
inetAddress = InetAddresses.forString(ipParam.get());
} catch (IllegalArgumentException e) {
throw new BadRequestException("Invalid value of ip parameter");
}
results = searchByIp(inetAddress, now);
}
if (results.jsonList().isEmpty()) {
throw new NotFoundException("No nameservers found");
}
ImmutableMap.Builder<String, Object> jsonBuilder = new ImmutableMap.Builder<>();
jsonBuilder.put("nameserverSearchResults", results.jsonList());
rdapJsonFormatter.addTopLevelEntries(
jsonBuilder,
BoilerplateType.NAMESERVER,
getNotices(results),
ImmutableList.of(),
fullServletPath);
return jsonBuilder.build();
}
示例8: getJsonObjectForResource
import com.google.common.primitives.Booleans; //導入方法依賴的package包/類
/** Parses the parameters and calls the appropriate search function. */
@Override
public ImmutableMap<String, Object> getJsonObjectForResource(
String pathSearchString, boolean isHeadRequest) {
DateTime now = clock.nowUtc();
// RDAP syntax example: /rdap/entities?fn=Bobby%20Joe*.
// The pathSearchString is not used by search commands.
if (pathSearchString.length() > 0) {
throw new BadRequestException("Unexpected path");
}
if (Booleans.countTrue(fnParam.isPresent(), handleParam.isPresent()) != 1) {
throw new BadRequestException("You must specify either fn=XXXX or handle=YYYY");
}
// Decode the cursor token and extract the prefix and string portions.
decodeCursorToken();
CursorType cursorType;
Optional<String> cursorQueryString;
if (!cursorString.isPresent()) {
cursorType = CursorType.NONE;
cursorQueryString = Optional.empty();
} else {
if (cursorString.get().startsWith(CONTACT_CURSOR_PREFIX)) {
cursorType = CursorType.CONTACT;
cursorQueryString =
Optional.of(cursorString.get().substring(CONTACT_CURSOR_PREFIX.length()));
} else if (cursorString.get().startsWith(REGISTRAR_CURSOR_PREFIX)) {
cursorType = CursorType.REGISTRAR;
cursorQueryString =
Optional.of(cursorString.get().substring(REGISTRAR_CURSOR_PREFIX.length()));
} else {
throw new BadRequestException(String.format("invalid cursor: %s", cursorTokenParam));
}
}
// Search by name.
RdapSearchResults results;
if (fnParam.isPresent()) {
metricInformationBuilder.setSearchType(SearchType.BY_FULL_NAME);
// syntax: /rdap/entities?fn=Bobby%20Joe*
// The name is the contact name or registrar name (not registrar contact name).
results =
searchByName(
recordWildcardType(RdapSearchPattern.create(fnParam.get(), false)),
cursorType,
cursorQueryString,
now);
// Search by handle.
} else {
metricInformationBuilder.setSearchType(SearchType.BY_HANDLE);
// syntax: /rdap/entities?handle=12345-*
// The handle is either the contact roid or the registrar clientId.
results =
searchByHandle(
recordWildcardType(RdapSearchPattern.create(handleParam.get(), false)),
cursorQueryString,
now);
}
// Build the result object and return it.
if (results.jsonList().isEmpty()) {
throw new NotFoundException("No entities found");
}
ImmutableMap.Builder<String, Object> jsonBuilder = new ImmutableMap.Builder<>();
jsonBuilder.put("entitySearchResults", results.jsonList());
rdapJsonFormatter.addTopLevelEntries(
jsonBuilder,
BoilerplateType.ENTITY,
getNotices(results),
ImmutableList.of(),
fullServletPath);
return jsonBuilder.build();
}
示例9: visit
import com.google.common.primitives.Booleans; //導入方法依賴的package包/類
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
JSDocInfo doc = n.getJSDocInfo();
if (doc == null) {
return;
}
int numGeneratorAnnotations =
Booleans.countTrue(
doc.isConsistentIdGenerator(),
doc.isIdGenerator(),
doc.isStableIdGenerator(),
doc.isXidGenerator(),
doc.isMappedIdGenerator());
if (numGeneratorAnnotations == 0) {
return;
} else if (numGeneratorAnnotations > 1) {
compiler.report(t.makeError(n, CONFLICTING_GENERATOR_TYPE));
}
String name = null;
if (n.isAssign()) {
name = n.getFirstChild().getQualifiedName();
} else if (NodeUtil.isNameDeclaration(n)) {
name = n.getFirstChild().getString();
} else if (n.isFunction()){
name = n.getFirstChild().getString();
if (name.isEmpty()) {
return;
}
}
if (doc.isConsistentIdGenerator()) {
consistNameMap.put(name, new LinkedHashMap<String, String>());
nameGenerators.put(
name, createNameSupplier(
RenameStrategy.CONSISTENT, previousMap.get(name)));
} else if (doc.isStableIdGenerator()) {
nameGenerators.put(
name, createNameSupplier(
RenameStrategy.STABLE, previousMap.get(name)));
} else if (doc.isXidGenerator()) {
nameGenerators.put(
name, createNameSupplier(
RenameStrategy.XID, previousMap.get(name)));
} else if (doc.isIdGenerator()) {
nameGenerators.put(
name, createNameSupplier(
RenameStrategy.INCONSISTENT, previousMap.get(name)));
} else if (doc.isMappedIdGenerator()) {
NameSupplier supplier = nameGenerators.get(name);
if (supplier == null
|| supplier.getRenameStrategy() != RenameStrategy.MAPPED) {
compiler.report(t.makeError(n, MISSING_NAME_MAP_FOR_GENERATOR));
// skip registering the name in the list of Generators if there no
// mapping.
return;
}
} else {
throw new IllegalStateException("unexpected");
}
idGeneratorMaps.put(name, new LinkedHashMap<String, String>());
}
示例10: count_total_number_of_booleans
import com.google.common.primitives.Booleans; //導入方法依賴的package包/類
@Test
public void count_total_number_of_booleans () {
boolean [] values = {true, true, false, true, false};
int count = Booleans.countTrue(values);
assertEquals(3, count);
}
示例11: count_booleans_arraylist_guava
import com.google.common.primitives.Booleans; //導入方法依賴的package包/類
@Test
public void count_booleans_arraylist_guava () {
List<Boolean> values = Lists.newArrayList(true, true, false, true, false);
int count = Booleans.countTrue(Booleans.toArray(values));
assertEquals(3, count);
}
示例12: getHiddenCountUpTo
import com.google.common.primitives.Booleans; //導入方法依賴的package包/類
/**
* Get the number of elements that are hidden until a given position
* @param position
* @return number of elements hidden (true in elementInvisibility Map)
*/
private int getHiddenCountUpTo(int position) {
boolean [] upper = Arrays.copyOfRange(Booleans.toArray(elementInvisibility.values()), 0, position + 1);
return Booleans.countTrue(upper);
}