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

EC2InstanceMetadataProvider.java 文件源码 项目:conqueso-client-java 阅读 26 收藏 0 点赞 0 评论 0
private Map<String, String> readMetadataFromService() {
    ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();

    for (MetadataLookup lookup : metadataLookups) {
        try {
            String value = readResource(lookup.getResourcePath());
            if (!Strings.isNullOrEmpty(value)) {
                builder.put(lookup.getConfiglyKey(), value);
            }
        } catch (IOException e) {
            LOGGER.warn("Failed to read EC2 metadata from path " + lookup.getResourcePath(), e);
        }
    }

    return builder.build();
}
StandardMessenger.java 文件源码 项目:Spigot-API 阅读 25 收藏 0 点赞 0 评论 0
public Set<String> getIncomingChannels(Plugin plugin) {
    if (plugin == null) {
        throw new IllegalArgumentException("Plugin cannot be null");
    }

    synchronized (incomingLock) {
        Set<PluginMessageListenerRegistration> registrations = incomingByPlugin.get(plugin);

        if (registrations != null) {
            Builder<String> builder = ImmutableSet.builder();

            for (PluginMessageListenerRegistration registration : registrations) {
                builder.add(registration.getChannel());
            }

            return builder.build();
        } else {
            return ImmutableSet.of();
        }
    }
}
StandardMessenger.java 文件源码 项目:Spigot-API 阅读 30 收藏 0 点赞 0 评论 0
public Set<PluginMessageListenerRegistration> getIncomingChannelRegistrations(Plugin plugin, String channel) {
    if (plugin == null) {
        throw new IllegalArgumentException("Plugin cannot be null");
    }
    validateChannel(channel);

    synchronized (incomingLock) {
        Set<PluginMessageListenerRegistration> registrations = incomingByPlugin.get(plugin);

        if (registrations != null) {
            Builder<PluginMessageListenerRegistration> builder = ImmutableSet.builder();

            for (PluginMessageListenerRegistration registration : registrations) {
                if (registration.getChannel().equals(channel)) {
                    builder.add(registration);
                }
            }

            return builder.build();
        } else {
            return ImmutableSet.of();
        }
    }
}
Query.java 文件源码 项目:android-db-commons 阅读 32 收藏 0 点赞 0 评论 0
public void getTables(ImmutableSet.Builder<String> builder) {
  addTableOrSubquery(builder, mPendingTable);
  for (TableOrSubquery tableOrSubquery : mTables.keySet()) {
    addTableOrSubquery(builder, tableOrSubquery);
  }

  if (mPendingJoin != null) {
    addTableOrSubquery(builder, mPendingJoin.mJoinSource);
  }

  for (JoinSpec join : mJoins) {
    addTableOrSubquery(builder, join.mJoinSource);
  }

  builder.addAll(mTablesUsedInExpressions);
}
CoursesResources.java 文件源码 项目:devhub-prototype 阅读 29 收藏 0 点赞 0 评论 0
@GET
@Path("{id}/download")
@RequiresRoles(UserRole.ROLE_ADMIN)
@Produces(MediaType.TEXT_PLAIN)
public Response download(@PathParam("id") long id) {
    Course course = courseDao.findById(id);
    Builder<String> setBuilder = ImmutableSet.builder();
    if (course.getProjects().isEmpty()) {
        return Response.status(Status.NO_CONTENT).entity("This course doesn't have any projects").build();
    } else {
        for (Project project : course.getProjects()) {
            if (project.getSourceCodeUrl() == null) {
                LOG.warn("This project doesnt have a source code URL: {}", project);
            } else {
                setBuilder.add(project.getSourceCodeUrl());
            }
        }
        Set<String> sourceCodeurls = setBuilder.build();
        return Response.ok(repoDownloader.prepareDownload(sourceCodeurls)).build();
    }
}
STVElectionCalculationStep.java 文件源码 项目:singleTransferableVoteElections 阅读 26 收藏 0 点赞 0 评论 0
private ImmutableSet<CANDIDATE> allCandidatesThatReachedTheQuorum(BigFraction quorum,
                                                                  ImmutableCollection<VoteState<CANDIDATE>> voteStates,
                                                                  CandidateStates<CANDIDATE> candidateStates) {
    VoteDistribution<CANDIDATE> voteDistribution = new VoteDistribution<>(candidateStates.getHopefulCandidates(),
                                                                          voteStates);

    // We use a sorted set here, to provide Unit tests a predictable execution order.
    Builder<CANDIDATE> candidatesThatReachedTheQuorum = ImmutableSortedSet.orderedBy(comparing(o -> o.name));

       voteDistribution.votesByCandidate.entrySet().stream()
               .filter(votesForCandidate -> quorumIsReached(quorum, votesForCandidate))
               .forEach(votesForCandidate -> candidatesThatReachedTheQuorum.add(votesForCandidate.getKey()));


    return candidatesThatReachedTheQuorum.build();
}
ReflectiveDaoAdapter.java 文件源码 项目:microorm 阅读 23 收藏 0 点赞 0 评论 0
ReflectiveDaoAdapter(Class<T> klass, ImmutableList<FieldAdapter> fieldAdapters, ImmutableList<EmbeddedFieldInitializer> fieldInitializers) {
  mClassFactory = ClassFactory.get(klass);
  mFieldAdapters = fieldAdapters;
  mFieldInitializers = fieldInitializers;

  ImmutableList.Builder<String> projectionBuilder = ImmutableList.builder();
  ImmutableList.Builder<String> writableColumnsBuilder = ImmutableList.builder();

  for (FieldAdapter fieldAdapter : fieldAdapters) {
    projectionBuilder.add(fieldAdapter.getColumnNames());
    writableColumnsBuilder.add(fieldAdapter.getWritableColumnNames());
  }
  mProjection = array(projectionBuilder.build());
  mWritableColumns = array(writableColumnsBuilder.build());
  mWritableDuplicates = findDuplicates(mWritableColumns);
}
StandardMessenger.java 文件源码 项目:Bukkit-JavaDoc 阅读 33 收藏 0 点赞 0 评论 0
public Set<String> getIncomingChannels(Plugin plugin) {
    if (plugin == null) {
        throw new IllegalArgumentException("Plugin cannot be null");
    }

    synchronized (incomingLock) {
        Set<PluginMessageListenerRegistration> registrations = incomingByPlugin.get(plugin);

        if (registrations != null) {
            Builder<String> builder = ImmutableSet.builder();

            for (PluginMessageListenerRegistration registration : registrations) {
                builder.add(registration.getChannel());
            }

            return builder.build();
        } else {
            return ImmutableSet.of();
        }
    }
}
StandardMessenger.java 文件源码 项目:Bukkit-JavaDoc 阅读 40 收藏 0 点赞 0 评论 0
public Set<PluginMessageListenerRegistration> getIncomingChannelRegistrations(Plugin plugin, String channel) {
    if (plugin == null) {
        throw new IllegalArgumentException("Plugin cannot be null");
    }
    validateChannel(channel);

    synchronized (incomingLock) {
        Set<PluginMessageListenerRegistration> registrations = incomingByPlugin.get(plugin);

        if (registrations != null) {
            Builder<PluginMessageListenerRegistration> builder = ImmutableSet.builder();

            for (PluginMessageListenerRegistration registration : registrations) {
                if (registration.getChannel().equals(channel)) {
                    builder.add(registration);
                }
            }

            return builder.build();
        } else {
            return ImmutableSet.of();
        }
    }
}
AbstractReport.java 文件源码 项目:buck 阅读 36 收藏 0 点赞 0 评论 0
/**
 * It returns a list of trace files that corresponds to builds while respecting the maximum size
 * of the final zip file.
 *
 * @param entries the highlighted builds
 * @return a set of paths that points to the corresponding traces.
 */
private ImmutableSet<Path> getTracePathsOfBuilds(ImmutableSet<BuildLogEntry> entries) {
  ImmutableSet.Builder<Path> tracePaths = new ImmutableSet.Builder<>();
  long reportSizeBytes = 0;
  for (BuildLogEntry entry : entries) {
    reportSizeBytes += entry.getSize();
    if (entry.getTraceFile().isPresent()) {
      try {
        Path traceFile = filesystem.getPathForRelativeExistingPath(entry.getTraceFile().get());
        long traceFileSizeBytes = Files.size(traceFile);
        if (doctorConfig.getReportMaxSizeBytes().isPresent()) {
          if (reportSizeBytes + traceFileSizeBytes < doctorConfig.getReportMaxSizeBytes().get()) {
            tracePaths.add(entry.getTraceFile().get());
            reportSizeBytes += traceFileSizeBytes;
          }
        } else {
          tracePaths.add(entry.getTraceFile().get());
          reportSizeBytes += traceFileSizeBytes;
        }
      } catch (IOException e) {
        LOG.info("Trace path %s wasn't valid, skipping it.", entry.getTraceFile().get());
      }
    }
  }
  return tracePaths.build();
}


问题


面经


文章

微信
公众号

扫码关注公众号