List of usage examples for com.google.common.collect ImmutableList isEmpty
boolean isEmpty();
From source file:com.google.security.zynamics.binnavi.Gui.GraphWindows.types.TypeEditorSearchPanel.java
private static void selectMatches(final ImmutableList<Integer> matchedRows, final TypesTree tree) { if (matchedRows.isEmpty()) { tree.clearSelection();// w w w . ja va 2 s.c o m } else { final int[] selectRows = new int[matchedRows.size()]; for (int i = 0; i < matchedRows.size(); i++) { selectRows[i] = matchedRows.get(i); } tree.setSelectionRows(selectRows); } }
From source file:com.torodb.torod.db.backends.query.processors.InProcessor.java
@Nullable private static ProcessedQueryCriteria getNumericQuery(InQueryCriteria criteria, Multimap<ScalarType, ScalarValue<?>> byTypeValues) { ImmutableList.Builder<ScalarValue<?>> newInBuilder = ImmutableList.builder(); for (ScalarValue<?> value : byTypeValues.values()) { newInBuilder.add(value);/* w w w . j ava2 s . co m*/ } ImmutableList<ScalarValue<?>> newIn = newInBuilder.build(); if (newIn.isEmpty()) { return null; } DisjunctionBuilder structureBuilder = new DisjunctionBuilder(); structureBuilder.add(new TypeIsQueryCriteria(criteria.getAttributeReference(), ScalarType.DOUBLE)); structureBuilder.add(new TypeIsQueryCriteria(criteria.getAttributeReference(), ScalarType.INTEGER)); structureBuilder.add(new TypeIsQueryCriteria(criteria.getAttributeReference(), ScalarType.LONG)); newInBuilder.addAll(byTypeValues.get(ScalarType.DOUBLE)); newInBuilder.addAll(byTypeValues.get(ScalarType.INTEGER)); newInBuilder.addAll(byTypeValues.get(ScalarType.LONG)); return new ProcessedQueryCriteria(structureBuilder.build(), new InQueryCriteria(criteria.getAttributeReference(), newIn)); }
From source file:com.facebook.buck.apple.CodeSignIdentityStore.java
/** * Construct a store by asking the system keychain for all stored code sign identities. * * The loading process is deferred till first access. *//*from w ww . j a va2s .co m*/ public static CodeSignIdentityStore fromSystem(final ProcessExecutor processExecutor, ImmutableList<String> command) { return new CodeSignIdentityStore(Suppliers.memoize(() -> { ProcessExecutorParams processExecutorParams = ProcessExecutorParams.builder().addAllCommand(command) .build(); // Specify that stdout is expected, or else output may be wrapped in Ansi escape chars. Set<ProcessExecutor.Option> options = EnumSet.of(ProcessExecutor.Option.EXPECTING_STD_OUT); ProcessExecutor.Result result; try { result = processExecutor.launchAndExecute(processExecutorParams, options, /* stdin */ Optional.empty(), /* timeOutMs */ Optional.empty(), /* timeOutHandler */ Optional.empty()); } catch (InterruptedException | IOException e) { LOG.warn("Could not execute security, continuing without codesign identity."); return ImmutableList.of(); } if (result.getExitCode() != 0) { throw new RuntimeException(result.getMessageForUnexpectedResult("security -v -p codesigning")); } Matcher matcher = CODE_SIGN_IDENTITY_PATTERN.matcher(result.getStdout().get()); ImmutableList.Builder<CodeSignIdentity> builder = ImmutableList.builder(); while (matcher.find()) { Optional<HashCode> fingerprint = CodeSignIdentity.toFingerprint(matcher.group(1)); if (!fingerprint.isPresent()) { // security should always output a valid fingerprint string. LOG.warn("Code sign identity fingerprint is invalid, ignored: " + matcher.group(1)); break; } String subjectCommonName = matcher.group(2); CodeSignIdentity identity = CodeSignIdentity.builder().setFingerprint(fingerprint) .setSubjectCommonName(subjectCommonName).build(); builder.add(identity); LOG.debug("Found code signing identity: " + identity.toString()); } ImmutableList<CodeSignIdentity> allValidIdentities = builder.build(); if (allValidIdentities.isEmpty()) { LOG.warn("No valid code signing identities found. Device build/install won't work."); } else if (allValidIdentities.size() > 1) { LOG.info("Multiple valid identity found. This could potentially cause the wrong one to" + " be used unless explicitly specified via CODE_SIGN_IDENTITY."); } return allValidIdentities; })); }
From source file:com.google.devtools.build.lib.actions.CommandLine.java
/** * Returns a {@link CommandLine} that is constructed by prepending the {@code executableArgs} to * {@code commandLine}./*w ww . j a v a 2 s.com*/ */ public static CommandLine concat(final ImmutableList<String> executableArgs, final CommandLine commandLine) { if (executableArgs.isEmpty()) { return commandLine; } return new PrefixedCommandLine(executableArgs, commandLine); }
From source file:ch.acanda.eclipse.pmd.v07tov08.V07ToV08Converter.java
/** * Loads the settings from the preference store, converts them to the version 0.8 domain model, stores them as files * in the project and deletes the old settings in the preference store. *///from w w w . j a v a2 s.c o m public static void moveSettings(final IPreferenceStore preferenceStore, final ProjectModelRepository repository) { final PMDWorkspaceSettings workspaceSettings = new PMDWorkspaceSettings(preferenceStore); final ImmutableList<RuleSetConfiguration> configs = workspaceSettings.getRuleSetsConfigurations(); if (!configs.isEmpty()) { boolean allSettingsMoved = true; for (final IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) { if (project.isAccessible()) { moveProjectSettings(project, configs, repository); } else { allSettingsMoved = false; } } if (allSettingsMoved) { workspaceSettings.deleteSettings(); } } }
From source file:org.glowroot.plugin.servlet.DetailCapture.java
static ImmutableMap<String, Object> captureRequestHeaders(HttpServletShim request) { ImmutableList<Pattern> capturePatterns = ServletPluginProperties.captureRequestHeaders(); if (capturePatterns.isEmpty()) { return ImmutableMap.of(); }//from w ww .j a v a 2 s . co m Map<String, Object> requestHeaders = Maps.newHashMap(); Enumeration<String> headerNames = request.getHeaderNames(); if (headerNames == null) { return ImmutableMap.of(); } for (Enumeration<String> e = headerNames; e.hasMoreElements();) { String name = e.nextElement(); if (name == null) { // null check just to be safe in case this is a very strange servlet container continue; } // converted to lower case for case-insensitive matching (patterns are lower case) String keyLowerCase = name.toLowerCase(Locale.ENGLISH); if (!matchesOneOf(keyLowerCase, capturePatterns)) { continue; } Enumeration<String> values = request.getHeaders(name); if (values != null) { captureRequestHeader(name, values, requestHeaders); } } return ImmutableMap.copyOf(requestHeaders); }
From source file:com.google.template.soy.jssrc.dsl.Conditional.java
static Conditional create(ImmutableList<IfThenPair> conditions, @Nullable CodeChunk trailingElse) { Preconditions.checkArgument(!conditions.isEmpty()); return new AutoValue_Conditional(conditions, trailingElse); }
From source file:org.apache.calcite.plan.RelOptPredicateList.java
/** Creates a RelOptPredicateList with only pulled-up predicates, no inferred * predicates.//from w w w .ja v a 2 s. c om * * <p>Use this for relational expressions other than joins. * * @param pulledUpPredicates Predicates that apply to the rows returned by the * relational expression */ public static RelOptPredicateList of(RexBuilder rexBuilder, Iterable<RexNode> pulledUpPredicates) { ImmutableList<RexNode> pulledUpPredicatesList = ImmutableList.copyOf(pulledUpPredicates); if (pulledUpPredicatesList.isEmpty()) { return EMPTY; } return of(rexBuilder, pulledUpPredicatesList, EMPTY_LIST, EMPTY_LIST); }
From source file:com.google.devtools.build.lib.syntax.ParamDescriptor.java
private static SkylarkType getType(Class<?> type, Class<?> generic, ImmutableList<ParamTypeDescriptor> allowedTypes, boolean noneable) { SkylarkType result = SkylarkType.BOTTOM; if (!allowedTypes.isEmpty()) { Preconditions.checkState(Object.class.equals(type)); for (ParamTypeDescriptor paramType : allowedTypes) { SkylarkType t = paramType.getGeneric1() != Object.class ? SkylarkType.of(paramType.getType(), paramType.getGeneric1()) : SkylarkType.of(paramType.getType()); result = SkylarkType.Union.of(result, t); }/*from w w w. j av a 2 s. co m*/ } else { result = generic != Object.class ? SkylarkType.of(type, generic) : SkylarkType.of(type); } if (noneable) { result = SkylarkType.Union.of(result, SkylarkType.NONE); } return result; }
From source file:com.google.devtools.build.lib.rules.proto.ProtoCommon.java
/** * Gets the direct sources of a proto library. If protoSources is not empty, the value is just * protoSources. Otherwise, it's the combined sources of all direct dependencies of the given * RuleContext.// w ww . ja va 2 s . c o m * * @param ruleContext the proto library rule context. * @param protoSources the direct proto sources. * @return the direct sources of a proto library. */ public static NestedSet<Artifact> getCheckDepsProtoSources(RuleContext ruleContext, ImmutableList<Artifact> protoSources) { if (protoSources.isEmpty()) { /* a proxy/alias library, return the sources of the direct deps */ NestedSetBuilder<Artifact> builder = NestedSetBuilder.stableOrder(); for (TransitiveInfoCollection provider : ruleContext.getPrerequisites("deps", Mode.TARGET)) { ProtoSourcesProvider sources = provider.getProvider(ProtoSourcesProvider.class); if (sources != null) { builder.addTransitive(sources.getCheckDepsProtoSources()); } } return builder.build(); } else { return NestedSetBuilder.wrap(STABLE_ORDER, protoSources); } }