当前位置: 首页>>代码示例>>Java>>正文


Java Booleans.countTrue方法代码示例

本文整理汇总了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());
    }
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:20,代码来源:GeefMedebewonersMaakBerichtServiceImpl.java

示例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;
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:22,代码来源:SkylarkSignatureProcessor.java

示例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;
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:5,代码来源:BevragingSelecteerPersoonServiceImpl.java

示例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()
            ));
}
 
开发者ID:wildfly-extras,项目名称:sunstone,代码行数:60,代码来源:BareMetalCloudProvider.java

示例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;
}
 
开发者ID:EyeSeeTea,项目名称:EDSApp,代码行数:11,代码来源:AutoTabLayoutUtils.java

示例6: countInvisible

import com.google.common.primitives.Booleans; //导入方法依赖的package包/类
public int countInvisible(){
    return Booleans.countTrue(Booleans.toArray(elementInvisibility.values()));
}
 
开发者ID:EyeSeeTea,项目名称:EDSApp,代码行数:4,代码来源:AutoTabInVisibilityState.java

示例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();
}
 
开发者ID:google,项目名称:nomulus,代码行数:57,代码来源:RdapNameserverSearchAction.java

示例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();
}
 
开发者ID:google,项目名称:nomulus,代码行数:76,代码来源:RdapEntitySearchAction.java

示例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>());
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:64,代码来源:ReplaceIdGenerators.java

示例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);
}
 
开发者ID:wq19880601,项目名称:java-util-examples,代码行数:10,代码来源:BooleansExample.java

示例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);
}
 
开发者ID:wq19880601,项目名称:java-util-examples,代码行数:10,代码来源:CountBooleansInList.java

示例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);
}
 
开发者ID:EyeSeeTea,项目名称:EDSApp,代码行数:10,代码来源:AutoTabInVisibilityState.java


注:本文中的com.google.common.primitives.Booleans.countTrue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。