List of usage examples for com.google.common.collect ImmutableList isEmpty
boolean isEmpty();
From source file:com.facebook.buck.cxx.CxxLibraryFactory.java
/** * Create all build rules needed to generate the static library. * * @return build rule that builds the static library version of this C/C++ library. *//* w w w . j av a2s.co m*/ private static BuildRule createStaticLibraryBuildRule(BuildTarget buildTarget, ProjectFilesystem projectFilesystem, ActionGraphBuilder graphBuilder, CellPathResolver cellRoots, CxxBuckConfig cxxBuckConfig, CxxPlatform cxxPlatform, CxxLibraryDescriptionArg args, ImmutableSet<BuildRule> deps, PicType pic, CxxLibraryDescription.TransitiveCxxPreprocessorInputFunction transitiveCxxPreprocessorInputFunction, Optional<CxxLibraryDescriptionDelegate> delegate) { SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(graphBuilder); SourcePathResolver sourcePathResolver = DefaultSourcePathResolver.from(ruleFinder); // Create rules for compiling the object files. ImmutableList<SourcePath> objects = requireObjects(buildTarget, projectFilesystem, graphBuilder, sourcePathResolver, ruleFinder, cellRoots, cxxBuckConfig, cxxPlatform, pic, args, deps, transitiveCxxPreprocessorInputFunction, delegate); // Write a build rule to create the archive for this C/C++ library. BuildTarget staticTarget = CxxDescriptionEnhancer.createStaticLibraryBuildTarget(buildTarget, cxxPlatform.getFlavor(), pic); if (objects.isEmpty()) { return new NoopBuildRule(staticTarget, projectFilesystem); } Path staticLibraryPath = CxxDescriptionEnhancer.getStaticLibraryPath(projectFilesystem, buildTarget, cxxPlatform.getFlavor(), pic, args.getStaticLibraryBasename(), cxxPlatform.getStaticLibraryExtension(), cxxBuckConfig.isUniqueLibraryNameEnabled()); return Archive.from(staticTarget, projectFilesystem, graphBuilder, ruleFinder, cxxPlatform, staticLibraryPath, ImmutableList.copyOf(objects), /* cacheable */ true); }
From source file:org.jclouds.compute.functions.NodeAndTemplateOptionsToStatementWithoutPublicKey.java
@Override public Statement apply(NodeMetadata node, TemplateOptions options) { ImmutableList.Builder<Statement> builder = ImmutableList.builder(); if (options.getRunScript() != null) { builder.add(options.getRunScript()); }/*from w w w . ja v a2 s. c om*/ if (options.getPrivateKey() != null) { builder.add(new InstallRSAPrivateKey(options.getPrivateKey())); } ImmutableList<Statement> bootstrap = builder.build(); if (!bootstrap.isEmpty()) { if (options.getTaskName() == null && !(options.getRunScript() instanceof InitScript)) { options.nameTask("bootstrap"); } return bootstrap.size() == 1 ? bootstrap.get(0) : new StatementList(bootstrap); } return null; }
From source file:org.jclouds.digitalocean.compute.functions.TemplateOptionsToStatementWithoutPublicKey.java
@Override public Statement apply(TemplateOptions options) { ImmutableList.Builder<Statement> builder = ImmutableList.builder(); if (options.getRunScript() != null) { builder.add(options.getRunScript()); }/* w ww . j a va 2 s. c o m*/ if (options.getPrivateKey() != null) { builder.add(new InstallRSAPrivateKey(options.getPrivateKey())); } ImmutableList<Statement> bootstrap = builder.build(); if (!bootstrap.isEmpty()) { if (options.getTaskName() == null && !(options.getRunScript() instanceof InitScript)) { options.nameTask("bootstrap"); } return bootstrap.size() == 1 ? bootstrap.get(0) : new StatementList(bootstrap); } return null; }
From source file:com.google.devtools.build.lib.rules.AliasProvider.java
public AliasProvider(ImmutableList<Label> aliasChain) { Preconditions.checkState(!aliasChain.isEmpty()); this.aliasChain = aliasChain; }
From source file:com.google.template.soy.conformance.RuleWithWhitelists.java
/** A file should be checked against a rule unless it contains one of the whitelisted paths. */ boolean shouldCheckConformanceFor(String filePath) { for (String whitelistedPath : getWhitelistedPaths()) { if (filePath.contains(whitelistedPath)) { return false; }// w w w .j av a 2 s.co m } ImmutableList<String> onlyApplyToPaths = getOnlyApplyToPaths(); if (onlyApplyToPaths.isEmpty()) { return true; } // If only_apply_to field is presented in the configuration, check it. for (String onlyApplyToPath : onlyApplyToPaths) { if (filePath.contains(onlyApplyToPath)) { return true; } } return false; }
From source file:monasca.common.util.config.ConfigurationFactory.java
private void validate(String file, T config) throws ConfigurationException { final ImmutableList<String> errors = new Validator().validate(config); if (!errors.isEmpty()) { throw new ConfigurationException(file, errors); }//from w w w . j a v a2 s .c o m }
From source file:com.google.template.soy.jssrc.dsl.SwitchBuilder.java
/** * Adds a case clause (one or more {@code case} labels followed by a body) to this switch * statement./*www. j ava 2 s . c o m*/ */ public SwitchBuilder case_(ImmutableList<CodeChunk.WithValue> caseLabels, CodeChunk body) { Preconditions.checkState(!caseLabels.isEmpty(), "at least one case required"); clauses.add(new Switch.CaseClause(caseLabels, body)); return this; }
From source file:com.facebook.buck.rules.macros.QueryTargetsMacroExpander.java
@Override public Object extractRuleKeyAppendables(BuildTarget target, CellPathResolver cellNames, final BuildRuleResolver resolver, ImmutableList<String> input) throws MacroException { if (input.isEmpty()) { throw new MacroException("One quoted query expression is expected"); }/*from w w w. j a v a2 s . c om*/ String queryExpression = CharMatcher.anyOf("\"'").trimFrom(input.get(0)); // Return the set of targets which matched the query return resolveQuery(target, cellNames, resolver, queryExpression).map(QueryTarget::toString) .collect(MoreCollectors.toImmutableSortedSet(Ordering.natural())); }
From source file:com.facebook.buck.rules.macros.QueryTargetsMacroExpander.java
@Override public String expand(BuildTarget target, CellPathResolver cellNames, BuildRuleResolver resolver, ImmutableList<String> input) throws MacroException { if (input.isEmpty()) { throw new MacroException("One quoted query expression is expected"); }/*from www. j a v a 2 s . com*/ String queryExpression = CharMatcher.anyOf("\"'").trimFrom(input.get(0)); return resolveQuery(target, cellNames, resolver, queryExpression).map(queryTarget -> { Preconditions.checkState(queryTarget instanceof QueryBuildTarget); BuildRule rule = resolver.getRule(((QueryBuildTarget) queryTarget).getBuildTarget()); return rule.getBuildTarget().toString(); }).sorted().collect(Collectors.joining(" ")); }
From source file:com.google.security.zynamics.binnavi.Gui.GraphWindows.types.DeleteTypeAction.java
@Override public void actionPerformed(ActionEvent event) { final ImmutableList<BaseType> types = typeEditor.getSelectedTypes(); if (types.isEmpty() || CMessageBox.showYesNoQuestion(owner, "Do you really want to delete these type(s)?") != JOptionPane.YES_OPTION) { return;//from ww w.ja va 2 s . c o m } try { for (final BaseType baseType : types) { typeManager.deleteType(baseType); } } catch (final CouldntDeleteException exception) { CUtilityFunctions.logException(exception); } }