List of usage examples for com.google.common.collect ImmutableList isEmpty
boolean isEmpty();
From source file:google.registry.flows.TlsCredentials.java
/** * Verifies {@link #clientInetAddr} is in CIDR whitelist associated with {@code registrar}. * * @throws BadRegistrarIpAddressException If IP address is not in the whitelist provided *//* w ww .ja v a 2 s .co m*/ private void validateIp(Registrar registrar) throws AuthenticationErrorException { ImmutableList<CidrAddressBlock> ipWhitelist = registrar.getIpAddressWhitelist(); if (ipWhitelist.isEmpty()) { logger.infofmt("Skipping IP whitelist check because %s doesn't have an IP whitelist", registrar.getClientId()); return; } for (CidrAddressBlock cidrAddressBlock : ipWhitelist) { if (cidrAddressBlock.contains(clientInetAddr)) { // IP address is in whitelist; return early. return; } } logger.infofmt("%s not in %s's CIDR whitelist: %s", clientInetAddr, registrar.getClientId(), ipWhitelist); throw new BadRegistrarIpAddressException(); }
From source file:com.google.devtools.build.importdeps.ImportDepsChecker.java
public String computeResultOutput(String ruleLabel) { StringBuilder builder = new StringBuilder(); ImmutableList<String> missingClasses = resultCollector.getSortedMissingClassInternalNames(); for (String missing : missingClasses) { builder.append("Missing ").append(missing.replace('/', '.')).append('\n'); }// w w w . j ava 2 s . co m ImmutableList<IncompleteState> incompleteClasses = resultCollector.getSortedIncompleteClasses(); for (IncompleteState incomplete : incompleteClasses) { builder.append("Incomplete ancestor classpath for ") .append(incomplete.classInfo().get().internalName().replace('/', '.')).append('\n'); ImmutableList<String> failurePath = incomplete.getResolutionFailurePath(); checkState(!failurePath.isEmpty(), "The resolution failure path is empty. %s", failurePath); builder.append(INDENT).append("missing ancestor: ") .append(failurePath.get(failurePath.size() - 1).replace('/', '.')).append('\n'); builder.append(INDENT).append("resolution failure path: ").append(failurePath.stream() .map(internalName -> internalName.replace('/', '.')).collect(Collectors.joining(" -> "))) .append('\n'); } ImmutableList<MissingMember> missingMembers = resultCollector.getSortedMissingMembers(); for (MissingMember missing : missingMembers) { builder.append("Missing member '").append(missing.memberName()).append("' in class ") .append(missing.owner().replace('/', '.')).append(" : name=").append(missing.memberName()) .append(", descriptor=").append(missing.descriptor()).append('\n'); } if (missingClasses.size() + incompleteClasses.size() + missingMembers.size() != 0) { builder.append("===Total===\n").append("missing=").append(missingClasses.size()).append('\n') .append("incomplete=").append(incompleteClasses.size()).append('\n').append("missing_members=") .append(missingMembers.size()).append('\n'); } ImmutableList<Path> indirectJars = resultCollector.getSortedIndirectDeps(); if (!indirectJars.isEmpty()) { ImmutableList<String> labels = extractLabels(indirectJars); if (ruleLabel.isEmpty() || labels.isEmpty()) { builder.append("*** Missing strict dependencies on the following Jars which don't carry " + "rule labels.\nPlease determine the originating rules, e.g., using Bazel's " + "'query' command, and add them to the dependencies of ") .append(ruleLabel.isEmpty() ? inputJars : ruleLabel).append('\n'); for (Path jar : indirectJars) { builder.append(jar).append('\n'); } } else { builder.append("*** Missing strict dependencies. Run the following command to fix ***\n\n"); builder.append(" add_dep "); for (String indirectLabel : labels) { builder.append(indirectLabel).append(" "); } builder.append(ruleLabel).append('\n'); } } return builder.toString(); }
From source file:org.immutables.metainf.processor.Metaservices.java
private Set<String> extractServiceInterfaceNames(TypeElement typeElement) { ImmutableList<TypeMirror> typesMirrors = AnnotationMirrors.getTypesFromMirrors( Metainf.Service.class.getCanonicalName(), "value", typeElement.getAnnotationMirrors()); if (typesMirrors.isEmpty()) { return useIntrospectedInterfacesForServices(typeElement); }//from ww w . ja v a 2s .com return useProvidedTypesForServices(typeElement, typesMirrors); }
From source file:com.hmaimi.jodis.RoundRobinJedisPool.java
/** * Get a jedis instance from pool.// w w w . jav a2s.c o m * <p> * We do not have a returnResource method, just close the jedis instance * returned directly. * * @return */ public Jedis getResource() { ImmutableList<PooledObject> pools = this.pools; if (pools.isEmpty()) { throw new JedisException("Proxy list empty"); } for (;;) { int current = nextIdx.get(); int next = current >= pools.size() - 1 ? 0 : current + 1; if (nextIdx.compareAndSet(current, next)) { return pools.get(next).pool.getResource(); } } }
From source file:org.terasology.math.geom.Polygon.java
private Polygon(ImmutableList<ImmutableVector2f> vertices) { Preconditions.checkArgument(!vertices.isEmpty(), "vertices must not be empty"); this.vertices = vertices; }
From source file:de.metas.ui.web.quickinput.QuickInputDescriptorFactoryService.java
private IQuickInputDescriptorFactory getQuickInputDescriptorFactory( final IQuickInputDescriptorFactory.MatchingKey matchingKey) { final ImmutableList<IQuickInputDescriptorFactory> matchingFactories = factories.get(matchingKey); if (matchingFactories.isEmpty()) { return null; }//from w w w . ja v a2 s .co m if (matchingFactories.size() > 1) { logger.warn("More than one factory found for {}. Using the first one: {}", matchingFactories); } return matchingFactories.get(0); }
From source file:org.graylog2.restclient.lib.ServerNodes.java
public List<Node> all(boolean allowInactive) { final Iterator<Node> nodeIterator; if (allowInactive) { nodeIterator = serverNodes.iterator(); } else {/* w w w . jav a2 s. c om*/ nodeIterator = skipInactive(serverNodes); } final ImmutableList<Node> nodes = ImmutableList.copyOf(nodeIterator); if (!allowInactive && nodes.isEmpty()) { throw new Graylog2ServerUnavailableException(); } return nodes; }
From source file:org.eclipse.xtext.builder.impl.RegistryBuilderParticipant.java
@Override public void build(IBuildContext buildContext, IProgressMonitor monitor) throws CoreException { ImmutableList<IXtextBuilderParticipant> participants = getParticipants(); if (participants.isEmpty()) return;/*from w w w .j ava2 s .c o m*/ SubMonitor progress = SubMonitor.convert(monitor, participants.size()); progress.subTask(Messages.RegistryBuilderParticipant_InvokingBuildParticipants); for (IXtextBuilderParticipant participant : participants) { if (progress.isCanceled()) throw new OperationCanceledException(); participant.build(buildContext, progress.newChild(1)); } }
From source file:com.arpnetworking.tsdcore.sinks.TimeThresholdSink.java
/** * {@inheritDoc}/*from ww w. j a va2 s. co m*/ */ @Override public void recordAggregateData(final PeriodicData periodicData) { LOGGER.debug().setMessage("Writing aggregated data").addData("sink", getName()) .addData("dataSize", periodicData.getData().size()) .addData("conditionsSize", periodicData.getConditions().size()).log(); if (_logOnly) { // Apply the filter but ignore the result _filter.filter(periodicData); _sink.recordAggregateData(periodicData); } else { // Apply the filter and rebuild the periodic data final ImmutableList<AggregatedData> filteredData = _filter.filter(periodicData); if (!filteredData.isEmpty() || !periodicData.getConditions().isEmpty()) { _sink.recordAggregateData(PeriodicData.Builder.clone(periodicData, new PeriodicData.Builder()) .setData(filteredData).build()); } } }
From source file:com.google.devtools.build.lib.bazel.coverage.CoverageReportActionBuilder.java
/** * Returns the coverage report action. May return null in case of an error. *///from w ww . j a v a 2 s . c om public CoverageReportActionsWrapper createCoverageActionsWrapper(EventHandler reporter, BlazeDirectories directories, Collection<ConfiguredTarget> targetsToTest, Iterable<Artifact> baselineCoverageArtifacts, ArtifactFactory factory, ArtifactOwner artifactOwner, String workspaceName, ArgsFunc argsFunction, LocationFunc locationFunc, boolean htmlReport) { if (targetsToTest == null || targetsToTest.isEmpty()) { return null; } ImmutableList.Builder<Artifact> builder = ImmutableList.<Artifact>builder(); FilesToRunProvider reportGenerator = null; for (ConfiguredTarget target : targetsToTest) { TestParams testParams = target.getProvider(TestProvider.class).getTestParams(); builder.addAll(testParams.getCoverageArtifacts()); if (reportGenerator == null) { reportGenerator = testParams.getCoverageReportGenerator(); } } builder.addAll(baselineCoverageArtifacts); ImmutableList<Artifact> coverageArtifacts = builder.build(); if (!coverageArtifacts.isEmpty()) { PathFragment coverageDir = TestRunnerAction.COVERAGE_TMP_ROOT; Artifact lcovArtifact = factory.getDerivedArtifact(coverageDir.getRelative("lcov_files.tmp"), directories.getBuildDataDirectory(workspaceName), artifactOwner); Action lcovFileAction = generateLcovFileWriteAction(lcovArtifact, coverageArtifacts); Action coverageReportAction = generateCoverageReportAction( CoverageArgs.create(directories, coverageArtifacts, lcovArtifact, factory, artifactOwner, reportGenerator, workspaceName, htmlReport), argsFunction, locationFunc); return new CoverageReportActionsWrapper(lcovFileAction, coverageReportAction); } else { reporter.handle(Event.error("Cannot generate coverage report - no coverage information was collected")); return null; } }