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


Java ImmutableSet.size方法代码示例

本文整理汇总了Java中com.google.common.collect.ImmutableSet.size方法的典型用法代码示例。如果您正苦于以下问题:Java ImmutableSet.size方法的具体用法?Java ImmutableSet.size怎么用?Java ImmutableSet.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.collect.ImmutableSet的用法示例。


在下文中一共展示了ImmutableSet.size方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleUnresolvedClasses

import com.google.common.collect.ImmutableSet; //导入方法依赖的package包/类
/**
 * Identifies and logs all unresolved class names. Then computes the percentage of unresolved
 * classes. If more than a certain threshold are unresolved, then it will throw an
 * IllegalStateException.
 */
private void handleUnresolvedClasses(
    ImmutableSet<String> projectClasses, Set<String> resolvedClasses) {
  Set<String> unresolvedClasses = Sets.difference(projectClasses, resolvedClasses);
  if (unresolvedClasses.isEmpty() || projectClasses.isEmpty()) {
    return;
  }

  logger.severe(
      String.format(
          "Unresolved class names = {\n\t%s\n}", Joiner.on("\n\t").join(unresolvedClasses)));

  if (UNRESOLVED_THRESHOLD * projectClasses.size() < unresolvedClasses.size()) {
    throw new IllegalStateException(
        String.format(
            "BUILD File Generator failed to map over %.0f percent of class names. "
                + "Check your white list and content roots",
            UNRESOLVED_THRESHOLD * 100));
  }
}
 
开发者ID:bazelbuild,项目名称:BUILD_file_generator,代码行数:25,代码来源:ProjectClassToRuleResolver.java

示例2: includedTypes

import com.google.common.collect.ImmutableSet; //导入方法依赖的package包/类
@Value.Lazy
List<TypeElement> includedTypes() {
  Optional<IncludeMirror> includes = include();

  ImmutableList<TypeMirror> typeMirrors = includes.isPresent()
      ? ImmutableList.copyOf(includes.get().valueMirror())
      : ImmutableList.<TypeMirror>of();

  FluentIterable<TypeElement> typeElements = FluentIterable.from(typeMirrors)
      .filter(DeclaredType.class)
      .transform(DeclatedTypeToElement.FUNCTION);

  ImmutableSet<String> uniqueTypeNames = typeElements
      .filter(IsPublic.PREDICATE)
      .transform(ElementToName.FUNCTION)
      .toSet();

  if (uniqueTypeNames.size() != typeMirrors.size()) {
    report().annotationNamed(IncludeMirror.simpleName())
        .warning("Some types were ignored, non-supported for inclusion: duplicates,"
            + " non declared reference types, non-public");
  }

  return typeElements.toList();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:Proto.java

示例3: builderIncludedTypes

import com.google.common.collect.ImmutableSet; //导入方法依赖的package包/类
@Value.Lazy
List<TypeElement> builderIncludedTypes() {
  Optional<FIncludeMirror> includes = builderInclude();

  ImmutableList<TypeMirror> typeMirrors = includes.isPresent()
      ? ImmutableList.copyOf(includes.get().valueMirror())
      : ImmutableList.<TypeMirror>of();

  FluentIterable<TypeElement> typeElements = FluentIterable.from(typeMirrors)
      .filter(DeclaredType.class)
      .transform(DeclatedTypeToElement.FUNCTION);

  ImmutableSet<String> uniqueTypeNames = typeElements
      .filter(IsPublic.PREDICATE)
      .transform(ElementToName.FUNCTION)
      .toSet();

  if (uniqueTypeNames.size() != typeMirrors.size()) {
    report().annotationNamed(IncludeMirror.simpleName())
        .warning("Some types were ignored, non-supported for inclusion: duplicates,"
            + " non declared reference types, non-public");
  }

  return typeElements.toList();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:Proto.java

示例4: apply

import com.google.common.collect.ImmutableSet; //导入方法依赖的package包/类
public static CorpusEventLinking apply(CorpusEventLinking corpusEventLinking,
    final SystemOutputStore2016 transformedStore) throws IOException {
  final ImmutableSet.Builder<DocEventFrameReference> retainedHoppersB = ImmutableSet.builder();
  for (final Symbol docid : transformedStore.docIDs()) {
    for (final String hopperID : transformedStore.read(docid).linking().responseSetIds().get()
        .keySet()) {
      retainedHoppersB.add(DocEventFrameReference.of(docid, hopperID));
    }
  }
  final ImmutableSet<DocEventFrameReference> retainedHoppers = retainedHoppersB.build();
  final CorpusEventLinking.Builder ret = CorpusEventLinking.builder();
  for (final CorpusEventFrame ref : corpusEventLinking.corpusEventFrames()) {
    final ImmutableSet<DocEventFrameReference> retainedComponents =
        Sets.intersection(ref.docEventFrames(), retainedHoppers).immutableCopy();
    if (retainedComponents.size() > 0) {
      ret.addCorpusEventFrames(CorpusEventFrame.of(ref.id(), retainedComponents));
      if(retainedComponents.size() != ref.docEventFrames().size()) {
        log.debug("Deleting from {} doc event frame refs", ref.id(),
            Sets.difference(ref.docEventFrames(), retainedHoppers));
      }
    } else {
      log.info("Deleting corpus event frame {}", ref.id());
    }
  }
  return ret.build();
}
 
开发者ID:isi-nlp,项目名称:tac-kbp-eal,代码行数:27,代码来源:ResponseMapping.java

示例5: encodeLabelDescriptors

import com.google.common.collect.ImmutableSet; //导入方法依赖的package包/类
@VisibleForTesting
static ImmutableList<LabelDescriptor> encodeLabelDescriptors(
    ImmutableSet<com.google.monitoring.metrics.LabelDescriptor> labelDescriptors) {
  List<LabelDescriptor> stackDriverLabelDescriptors = new ArrayList<>(labelDescriptors.size());

  for (com.google.monitoring.metrics.LabelDescriptor labelDescriptor : labelDescriptors) {
    stackDriverLabelDescriptors.add(
        new LabelDescriptor()
            .setKey(labelDescriptor.name())
            .setDescription(labelDescriptor.description())
            .setValueType(LABEL_VALUE_TYPE));
  }

  return ImmutableList.copyOf(stackDriverLabelDescriptors);
}
 
开发者ID:google,项目名称:java-monitoring-client-library,代码行数:16,代码来源:StackdriverWriter.java

示例6: handleResponseSetIDs

import com.google.common.collect.ImmutableSet; //导入方法依赖的package包/类
@Override
protected void handleResponseSetIDs(final ResponseLinking.Builder responseLinking,
    final ImmutableSet<ResponseSet> responseSets,
    final ImmutableMap<String, ResponseSet> responseIDs,
    final Optional<ImmutableMap.Builder<String, String>> foreignLinkingIdToLocal)
    throws IOException {
  if (responseSets.size() == responseIDs.size()) {
    responseLinking.responseSetIds(ImmutableBiMap.copyOf(responseIDs));
    responseLinking.build();
  } else if (responseSets.size() > responseIDs.size() || !foreignLinkingIdToLocal.isPresent()) {
    throw new IOException("Read " + responseSets.size() + " response sets but "
        + responseIDs.size() + " ID assignments");
  } else {
    log.warn(
        "Warning - converting ResponseSet IDs and saving them, this is almost definitely an error!");
    final ImmutableMultimap<ResponseSet, String> responseSetToIds =
        responseIDs.asMultimap().inverse();
    final LaxImmutableMapBuilder<String, ResponseSet> idsMapB =
        MapUtils.immutableMapBuilderAllowingSameEntryTwice();

    for (final Map.Entry<ResponseSet, Collection<String>> setAndIds : responseSetToIds.asMap()
        .entrySet()) {

      final Collection<String> ids = setAndIds.getValue();
      final String selectedID =
          checkNotNull(getFirst(usingToString().immutableSortedCopy(ids), null));
      for (final String oldId : ids) {
        log.debug("Selecting id {} for cluster {}", selectedID, oldId);
        foreignLinkingIdToLocal.get().put(oldId, selectedID);
        idsMapB.put(selectedID, responseIDs.get(oldId));
      }
    }
    responseLinking.responseSetIds(ImmutableBiMap.copyOf(idsMapB.build()));
  }
}
 
开发者ID:isi-nlp,项目名称:tac-kbp-eal,代码行数:36,代码来源:LinkingStoreSource.java

示例7: getEventFrameID

import com.google.common.collect.ImmutableSet; //导入方法依赖的package包/类
private String getEventFrameID(final ResponseSet responseSet,
    final ResponseLinking responseLinking) throws IOException {
  checkArgument(responseLinking.responseSetIds().isPresent(), "Linking does not assign frame "
      + "IDs. These are required for writing in 2016 format.");
  final ImmutableSet<String> ids =
      responseLinking.responseSetIds().get().asMultimap().inverse().get(responseSet);
  if (ids.size() == 1) {
    return ids.asList().get(0);
  } else if (ids.isEmpty()) {
    throw new IOException("No ID found for event frame " + responseSet);
  } else {
    throw new IOException("Multiple IDs found for event frame, should be impossible: "
        + responseSet);
  }
}
 
开发者ID:isi-nlp,项目名称:tac-kbp-eal,代码行数:16,代码来源:LinkingStoreSource.java

示例8: build

import com.google.common.collect.ImmutableSet; //导入方法依赖的package包/类
/**
 * Builds a classifier based on previous allow/match decisions.
 * This may be reused after a call to build and subsequent calls to
 * allow/match methods will not affect previously built classifiers.
 */
public AuthorityClassifier build() {
  ImmutableSet<Inet4Address> ipv4Set = ipv4s.build();
  ImmutableSet<Inet6Address> ipv6Set = ipv6s.build();
  ImmutableSet<InternetDomainName> domainNameSet = domainNames.build();
  HostGlobMatcher hostGlobMatcher = new HostGlobMatcher(hostGlobs.build());
  int[] allowedPortsSorted;
  {
    ImmutableSet<Integer> allowedPortIntSet = allowedPorts.build();
    int n = allowedPortIntSet.size();
    allowedPortsSorted = new int[n];
    Iterator<Integer> allowedPortIt = allowedPortIntSet.iterator();
    for (int i = 0; i < n; ++i) {
      allowedPortsSorted[i] = allowedPortIt.next();
    }
    Arrays.sort(allowedPortsSorted);
  }
  Predicate<? super Integer> portClassifier =
      allowedPortsSorted.length == 0  // No exclusion specified
      ? Predicates.alwaysTrue()
      : Predicates.alwaysFalse();
  if (this.allowedPortClassifier != null) {
    portClassifier = this.allowedPortClassifier;
  }
  UserInfoClassifier userInfoClassifier =
      this.allowedUserInfoClassifier != null
      ? this.allowedUserInfoClassifier
      : UserInfoClassifiers.NO_PASSWORD_BUT_USERNAME_IF_ALLOWED_BY_SCHEME;
  return new AuthorityClassifierImpl(
      ipv4Set,
      ipv6Set,
      domainNameSet,
      hostGlobMatcher,
      matchesAnyHost,
      allowedPortsSorted,
      portClassifier,
      userInfoClassifier);
}
 
开发者ID:OWASP,项目名称:url-classifier,代码行数:43,代码来源:AuthorityClassifierBuilder.java

示例9: getAllTestClasses

import com.google.common.collect.ImmutableSet; //导入方法依赖的package包/类
/**
 * Finds all tests to run for the TCK.
 *
 * @return A list of test classes to run.
 */
List<Class<?>> getAllTestClasses() {
  try {
    ClassPath cp = ClassPath.from(getClass().getClassLoader());
    ImmutableSet<ClassInfo> classes =
        cp.getTopLevelClasses("org.apache.calcite.avatica.tck.tests");

    List<Class<?>> testClasses = new ArrayList<>(classes.size());
    for (ClassInfo classInfo : classes) {
      if (classInfo.getSimpleName().equals("package-info")) {
        continue;
      }
      Class<?> clz = Class.forName(classInfo.getName());
      if (Modifier.isAbstract(clz.getModifiers())) {
        // Ignore abstract classes
        continue;
      }
      testClasses.add(clz);
    }

    return testClasses;
  } catch (Exception e) {
    LOG.error("Failed to instantiate test classes", e);
    Unsafe.systemExit(TestRunnerExitCodes.TEST_CASE_INSTANTIATION.ordinal());
    // Unreachable..
    return null;
  }
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:33,代码来源:TestRunner.java

示例10: charset

import com.google.common.collect.ImmutableSet; //导入方法依赖的package包/类
/**
 * Returns an optional charset for the value of the charset parameter if it is specified.
 *
 * @throws IllegalStateException if multiple charset values have been set for this media type
 * @throws IllegalCharsetNameException if a charset value is present, but illegal
 * @throws UnsupportedCharsetException if a charset value is present, but no support is available
 *     in this instance of the Java virtual machine
 */
public Optional<Charset> charset() {
  ImmutableSet<String> charsetValues = ImmutableSet.copyOf(parameters.get(CHARSET_ATTRIBUTE));
  switch (charsetValues.size()) {
    case 0:
      return Optional.absent();
    case 1:
      return Optional.of(Charset.forName(Iterables.getOnlyElement(charsetValues)));
    default:
      throw new IllegalStateException("Multiple charset values defined: " + charsetValues);
  }
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:20,代码来源:MediaType.java

示例11: trueMain

import com.google.common.collect.ImmutableSet; //导入方法依赖的package包/类
private static void trueMain(String[] argv) throws IOException {
  final Parameters params = Parameters.loadSerifStyle(new File(argv[0]));
  final File inputStore = params.getExistingDirectory("inputStore");
  final File outputStore = params.getCreatableDirectory("outputStore");

  final SystemOutputStore2016 input = SystemOutputStore2016.open(inputStore);
  final SystemOutputStore2016 output = SystemOutputStore2016.openOrCreate(outputStore);
  final ImmutableSet<KBPRealis> linkableRealises =
      ImmutableSet.of(KBPRealis.Actual, KBPRealis.Other);

  final Predicate<Response> realisIsLinkable =
      compose(in(linkableRealises), ResponseFunctions.realis());

  // collect all the surviving filtering
  final ImmutableSet.Builder<DocEventFrameReference> survivingIDsB = ImmutableSet.builder();
  for (final Symbol docID : input.docIDs()) {
    final DocumentSystemOutput2015 oldOutput = input.read(docID);
    final ResponseLinking filtered =
        oldOutput.linking().copyWithFilteredResponses(realisIsLinkable);
    for (final String surviving : filtered.responseSetIds().get().keySet()) {
      survivingIDsB.add(DocEventFrameReference.of(docID, surviving));
    }
    final DocumentSystemOutput2015 newOutput =
        DocumentSystemOutput2015.from(oldOutput.arguments(), filtered);
    output.write(newOutput);
  }
  final ImmutableSet<DocEventFrameReference> survivingFrames = survivingIDsB.build();

  // remove those from the CorpusEventLinking
  final CorpusEventLinking.Builder newCorpusLinkingB = CorpusEventLinking.builder();
  final ImmutableMultimap<CorpusEventFrame, DocEventFrameReference> corpusEventToDocEvent =
      input.readCorpusEventFrames().docEventsToCorpusEvents().inverse();
  for (final CorpusEventFrame cef : corpusEventToDocEvent.keySet()) {
    final ImmutableSet<DocEventFrameReference> survivingDocEvents =
        FluentIterable.from(corpusEventToDocEvent.get(cef)).filter(in(survivingFrames)).toSet();
    if (survivingDocEvents.size() > 0) {
      final CorpusEventFrame res = CorpusEventFrame.of(cef.id(), survivingDocEvents);
      newCorpusLinkingB.addCorpusEventFrames(res);
    }
  }

  output.writeCorpusEventFrames(newCorpusLinkingB.build());
}
 
开发者ID:isi-nlp,项目名称:tac-kbp-eal,代码行数:44,代码来源:FilterLinkingStore.java

示例12: load

import com.google.common.collect.ImmutableSet; //导入方法依赖的package包/类
/**
 * Load jar from specific path
 *
 * @param loader specific class loader
 * @param packageName scan package name
 * @param classNameFilter nullable, class name filter, simplelly using contains
 * @param annotationFilter nullable, annotation type filter
 * @return set of classes or null when get error
 */
public static Set<Class<?>> load(
    final ClassLoader loader,
    final String packageName,
    final Set<String> classNameFilter,
    final Set<Class<? extends Annotation>> annotationFilter) {

    ClassPath classPath;
    try {
        classPath = ClassPath.from(loader);
    } catch (IOException e) {
        return null;
    }

    ImmutableSet<ClassInfo> classSet = classPath.getTopLevelClassesRecursive(packageName);
    Set<Class<?>> classes = new HashSet<>(classSet.size());

    for (ClassInfo classInfo : classSet) {
        try {
            Class<?> aClass = classInfo.load();

            // check class name by filter
            if (classNameFilter != null) {
                for (String filter : classNameFilter) {
                    if (aClass.toString().contains(filter)) {
                        classes.add(aClass);
                    }
                }
            }

            // check annotation type by filter
            if (annotationFilter != null) {
                Annotation[] annotations = aClass.getAnnotations();
                for (Annotation annotation : annotations) {
                    for (Class<?> targetType : annotationFilter) {
                        if (annotation.annotationType().equals(targetType)) {
                            classes.add(aClass);
                        }
                    }
                }
            }

            // add class if not filter defined
            if (classNameFilter == null && annotationFilter == null) {
                classes.add(aClass);
            }

        } catch (NoClassDefFoundError ignore) {
            // no class found
        }
    }

    return classes;
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:63,代码来源:ClassUtil.java


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