java类com.google.common.collect.ImmutableSet的实例源码

PceManagerTest.java 文件源码 项目:athena 阅读 41 收藏 0 点赞 0 评论 0
@Override
public Collection<Tunnel> queryTunnel(TunnelEndPoint src, TunnelEndPoint dst) {
    Collection<Tunnel> result = new HashSet<Tunnel>();
    Tunnel tunnel = null;
    for (TunnelId tunnelId : tunnelIdAsKeyStore.keySet()) {
        tunnel = tunnelIdAsKeyStore.get(tunnelId);

        if ((null != tunnel) && (src.equals(tunnel.src())) && (dst.equals(tunnel.dst()))) {
            result.add(tunnel);
        }
    }

    return result.size() == 0 ? Collections.emptySet() : ImmutableSet.copyOf(result);
}
Utils.java 文件源码 项目:reflect 阅读 40 收藏 0 点赞 0 评论 0
public static ImmutableSet<Method> toMethods(Iterable<Class<?>> classes) {
  return FluentIterable.from(classes)
      .transformAndConcat(
          new Function<Class<?>, ImmutableSet<Method>>() {
            @Override
            public ImmutableSet<Method> apply(Class<?> c) {
              return Reflect.methods(c);
            }
          })
      .toSet();
}
Methods.java 文件源码 项目:ProjectAres 阅读 50 收藏 0 点赞 0 评论 0
public static Set<Method> ancestors(Method method) {
    if(Members.isPrivate(method)) return Collections.emptySet();

    final ImmutableSet.Builder<Method> builder = ImmutableSet.builder();
    for(Class<?> ancestor : Types.ancestors(method.getDeclaringClass())) {
        final Method sup = overrideIn(ancestor, method);
        if(sup != null) builder.add(sup);
    }
    return builder.build();
}
Configuration.java 文件源码 项目:json2java4idea 阅读 37 收藏 0 点赞 0 评论 0
private Configuration(@Nonnull Builder builder) {
    style = builder.style;
    classNamePolicy = builder.classNamePolicy;
    fieldNamePolicy = builder.fieldNamePolicy;
    methodNamePolicy = builder.methodNamePolicy;
    parameterNamePolicy = builder.parameterNamePolicy;
    annotationPolicies = ImmutableSet.copyOf(builder.annotationPolicies);
    jsonParser = builder.jsonParser;
    javaBuilder = builder.javaBuilder;
}
FileToArchiveEntrySetTransformer.java 文件源码 项目:Reer 阅读 28 收藏 0 点赞 0 评论 0
public Set<ArchiveEntry> transform(File archiveFile) {
    FileInputStream fileInputStream;
    try {
        fileInputStream = new FileInputStream(archiveFile);
    } catch (FileNotFoundException e) {
        throw new UncheckedIOException(e);
    }

    ImmutableSet.Builder<ArchiveEntry> allEntries = ImmutableSet.builder();
    walk(fileInputStream, allEntries, ImmutableList.<String>of());
    return allEntries.build();
}
OnlyMostSpecificTemporal.java 文件源码 项目:tac-kbp-eal 阅读 22 收藏 0 点赞 0 评论 0
private static ImmutableSet<TypeRoleFillerRealis> computeBannedResponseSignatures(
    final AnswerKey key) {
  final ImmutableSet.Builder<TypeRoleFillerRealis> bannedResponseSignatures =
      ImmutableSet.builder();

  for (final AssessedResponse response : key.annotatedResponses()) {
    if (response.assessment().entityCorrectFiller().isPresent()
        && response.assessment().entityCorrectFiller().get().isAcceptable()
        && response.response().isTemporal()) {
      try {
        final KBPTIMEXExpression time = KBPTIMEXExpression.parseTIMEX(
            response.response().canonicalArgument().string());

        final TypeRoleFillerRealis responseSignature = responseSignature(response.response());

        for (final KBPTIMEXExpression lessSpecificTimex : time.lessSpecificCompatibleTimes()) {
          bannedResponseSignatures.add(responseSignature.withArgumentCanonicalString(
              KBPString.from(lessSpecificTimex.toString(), DUMMY_OFFSETS)));
        }
      } catch (KBPTIMEXExpression.KBPTIMEXException timexException) {
        log.warn(
            "While applying only-most-specific-temporal rule, encountered an illegal temporal "
                + "expression " + response.response().canonicalArgument().string()
                + " which was evaluated as "
                + "correct. Such responses should have incorrect CAS assessments.");
      }

    }
  }
  return bannedResponseSignatures.build();
}
ConfigurationUpdateManager.java 文件源码 项目:pyplyn 阅读 31 收藏 0 点赞 0 评论 0
/**
 * Ensures only tasks that should be running are running
 */
private void updateTasksAfterClusterEvent() {
    logger.info("Synchronizing tasks on local node...");

    // compute the difference between currently executing tasks and locally managed configurations
    Set<Configuration> localConfigurations = get();
    Set<Configuration> localTasks = taskManager.allTasks();
    ImmutableSet.copyOf(Sets.difference(localTasks, localConfigurations))
            // and delete all the tasks that should not run on the local node
            .forEach(new DeleteTaskConsumer((always) -> true));

    // upsert all local configurations, to ensure all that should be running are running
    localConfigurations.forEach(new UpsertTaskConsumer((always) -> true));
}
ShardedDOMDataWriteTransaction.java 文件源码 项目:hashsdn-controller 阅读 34 收藏 0 点赞 0 评论 0
@Override
public synchronized boolean cancel() {
    if (closed) {
        return false;
    }

    LOG.debug("Cancelling transaction {}", identifier);
    for (DOMStoreWriteTransaction tx : ImmutableSet.copyOf(idToTransaction.values())) {
        tx.close();
    }

    closed = true;
    producer.cancelTransaction(this);
    return true;
}
HostHandler.java 文件源码 项目:athena 阅读 19 收藏 0 点赞 0 评论 0
/**
 * Add per host route to subnet list and populate the flow rule if the host
 * does not belong to the configured subnet.
 *
 * @param location location of the host being added
 * @param ip IP address of the host being added
 */
private void addPerHostRoute(ConnectPoint location, Ip4Address ip) {
    Ip4Prefix portSubnet = srManager.deviceConfiguration.getPortSubnet(
            location.deviceId(), location.port());
    if (portSubnet != null && !portSubnet.contains(ip)) {
        Ip4Prefix ip4Prefix = ip.toIpPrefix().getIp4Prefix();
        srManager.deviceConfiguration.addSubnet(location, ip4Prefix);
        srManager.defaultRoutingHandler.populateSubnet(location,
                ImmutableSet.of(ip4Prefix));
    }
}
KBPEATestUtils.java 文件源码 项目:tac-kbp-eal 阅读 26 收藏 0 点赞 0 评论 0
public static AnswerKey minimalAnswerKeyFor(CorefAnnotation coref) {
  final DummyResponseGenerator responseGenerator = new DummyResponseGenerator();
  final ImmutableSet.Builder<Response> responses = ImmutableSet.builder();
  for (final KBPString s : coref.allCASes()) {
    responses.add(responseGenerator.responseFor(dummyTRFR(coref.docId(), s)));
  }

  final ImmutableSet<AssessedResponse> assessedResponses = FluentIterable
      .from(responses.build())
      .transform(dummyAnnotationFunction)
      .toSet();

  return AnswerKey.from(coref.docId(), assessedResponses,
      ImmutableSet.<Response>of(), coref);
}


问题


面经


文章

微信
公众号

扫码关注公众号