List of usage examples for com.google.common.collect ImmutableList size
int size();
From source file:com.facebook.buck.apple.MultiarchFileInfos.java
/** * Inspect the given build target and return information about it if its a fat binary. * * @return non-empty when the target represents a fat binary. * @throws com.facebook.buck.util.HumanReadableException * when the target is a fat binary but has incompatible flavors. *///from www .j av a 2 s. co m public static Optional<MultiarchFileInfo> create(final FlavorDomain<AppleCxxPlatform> appleCxxPlatforms, BuildTarget target) { ImmutableList<ImmutableSortedSet<Flavor>> thinFlavorSets = generateThinFlavors( appleCxxPlatforms.getFlavors(), target.getFlavors()); if (thinFlavorSets.size() <= 1) { // Actually a thin binary return Optional.empty(); } if (!Sets.intersection(target.getFlavors(), FORBIDDEN_BUILD_ACTIONS).isEmpty()) { throw new HumanReadableException("%s: Fat binaries is only supported when building an actual binary.", target); } AppleCxxPlatform representativePlatform = null; AppleSdk sdk = null; for (SortedSet<Flavor> flavorSet : thinFlavorSets) { AppleCxxPlatform platform = Preconditions .checkNotNull(appleCxxPlatforms.getValue(flavorSet).orElse(null)); if (sdk == null) { sdk = platform.getAppleSdk(); representativePlatform = platform; } else if (sdk != platform.getAppleSdk()) { throw new HumanReadableException( "%s: Fat binaries can only be generated from binaries compiled for the same SDK.", target); } } MultiarchFileInfo.Builder builder = MultiarchFileInfo.builder().setFatTarget(target) .setRepresentativePlatform(Preconditions.checkNotNull(representativePlatform)); BuildTarget platformFreeTarget = target.withoutFlavors(appleCxxPlatforms.getFlavors()); for (SortedSet<Flavor> flavorSet : thinFlavorSets) { builder.addThinTargets(platformFreeTarget.withFlavors(flavorSet)); } return Optional.of(builder.build()); }
From source file:org.apache.kylin.query.util.ConvertToComputedColumn.java
private static String getTableAlias(SqlNode node) { if (node instanceof SqlCall) { SqlCall call = (SqlCall) node;/*from w w w. ja v a 2s. c o m*/ return getTableAlias(call.getOperandList()); } if (node instanceof SqlIdentifier) { StringBuilder alias = new StringBuilder(""); ImmutableList<String> names = ((SqlIdentifier) node).names; if (names.size() >= 2) { for (int i = 0; i < names.size() - 1; i++) { alias.append(names.get(i)).append("."); } } return alias.toString(); } if (node instanceof SqlNodeList) { return ""; } if (node instanceof SqlLiteral) { return ""; } return ""; }
From source file:org.apache.cloudstack.utils.CloudStackVersion.java
private static ImmutableList<Integer> normalizeVersionValues(final ImmutableList<Integer> values) { checkArgument(values != null);//www . j a v a 2 s . c o m checkArgument(values.size() == 3 || values.size() == 4); if (values.size() == 3) { return ImmutableList.<Integer>builder().addAll(values).add(0).build(); } return values; }
From source file:org.eclipse.buildship.core.configuration.GradleProjectBuilder.java
/** * Configures the builder on the target project if it was not added previously. * <p/>//from ww w . j a v a2 s . c om * This method requires the {@link org.eclipse.core.resources.IWorkspaceRoot} scheduling rule. * * @param project the target project */ public static void configureOnProject(IProject project) { try { Preconditions.checkState(project.isOpen()); // check if the builder is already registered with the project IProjectDescription description = project.getDescription(); List<ICommand> buildSpecs = Arrays.asList(description.getBuildSpec()); boolean exists = FluentIterable.from(buildSpecs).anyMatch(new Predicate<ICommand>() { @Override public boolean apply(ICommand command) { return command.getBuilderName().equals(ID); } }); // register the builder with the project if it is not already registered if (!exists) { ICommand buildSpec = description.newCommand(); buildSpec.setBuilderName(ID); ImmutableList<ICommand> newBuildSpecs = ImmutableList.<ICommand>builder().addAll(buildSpecs) .add(buildSpec).build(); description.setBuildSpec(newBuildSpecs.toArray(new ICommand[newBuildSpecs.size()])); project.setDescription(description, new NullProgressMonitor()); } } catch (CoreException e) { CorePlugin.logger() .error(String.format("Failed to add Gradle Project Builder to project %s.", project.getName())); } }
From source file:com.facebook.buck.rules.Manifest.java
@VisibleForTesting protected static HashCode hashSourcePathGroup(FileHashCache fileHashCache, SourcePathResolver resolver, ImmutableList<SourcePath> paths) throws IOException { if (paths.size() == 1) { return hashSourcePath(paths.asList().get(0), fileHashCache, resolver); }// w w w.j a v a2 s .co m Hasher hasher = Hashing.md5().newHasher(); for (SourcePath path : paths) { hasher.putBytes(hashSourcePath(path, fileHashCache, resolver).asBytes()); } return hasher.hash(); }
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. j a v a 2s.c om*/ } 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.github.rinde.logistics.pdptw.solver.CheapestInsertionHeuristic.java
static <T> ImmutableList<ImmutableList<T>> modifySchedule(ImmutableList<ImmutableList<T>> originalSchedule, ImmutableList<T> vehicleSchedule, int vehicleIndex) { checkArgument(vehicleIndex >= 0 && vehicleIndex < originalSchedule.size(), "Vehicle index must be >= 0 && < %s, it is %s.", originalSchedule.size(), vehicleIndex); final ImmutableList.Builder<ImmutableList<T>> builder = ImmutableList.builder(); builder.addAll(originalSchedule.subList(0, vehicleIndex)); builder.add(vehicleSchedule);//from w w w . j a v a2s . c om builder.addAll(originalSchedule.subList(vehicleIndex + 1, originalSchedule.size())); return builder.build(); }
From source file:com.facebook.buck.features.apple.project.ProjectGeneratorTestUtils.java
public static <T extends PBXBuildPhase> void assertHasSingletonPhaseWithEntries(PBXTarget target, Class<T> cls, ImmutableList<String> entries) { PBXBuildPhase buildPhase = getSingletonPhaseByType(target, cls); assertThat("Phase should have right number of entries", buildPhase.getFiles(), hasSize(entries.size())); for (PBXBuildFile file : buildPhase.getFiles()) { PBXReference.SourceTree sourceTree = file.getFileRef().getSourceTree(); switch (sourceTree) { case GROUP: fail("Should not emit entries with sourceTree <group>"); break; case ABSOLUTE: fail("Should not emit entries with sourceTree <absolute>"); break; // $CASES-OMITTED$ default:/*from w w w.j ava 2 s.co m*/ String serialized = "$" + sourceTree + "/" + file.getFileRef().getPath(); assertThat("Source tree prefixed file references should exist in list of expected entries.", entries, hasItem(serialized)); break; } } }
From source file:org.apache.druid.segment.incremental.SpatialDimensionRowTransformer.java
/** * Decodes encodedCoordinate.// ww w .j a v a 2 s .c o m * * @param encodedCoordinate encoded coordinate * * @return decoded coordinate, or null if it could not be decoded */ public static float[] decode(final String encodedCoordinate) { if (encodedCoordinate == null) { return null; } final ImmutableList<String> parts = ImmutableList.copyOf(SPLITTER.split(encodedCoordinate)); final float[] coordinate = new float[parts.size()]; for (int i = 0; i < coordinate.length; i++) { final Float floatPart = tryParseFloat(parts.get(i)); if (floatPart == null) { return null; } else { coordinate[i] = floatPart; } } return coordinate; }
From source file:com.github.rinde.logistics.pdptw.solver.CheapestInsertionHeuristic.java
static ImmutableList<Double> decomposedCost(GlobalStateObject state, ImmutableList<ImmutableList<Parcel>> schedule, ObjectiveFunction objFunc) { final ImmutableList.Builder<Double> builder = ImmutableList.builder(); for (int i = 0; i < schedule.size(); i++) { builder.add(objFunc.computeCost( Solvers.computeStats(state.withSingleVehicle(i), ImmutableList.of(schedule.get(i))))); }/*from w ww . j ava2 s. c o m*/ return builder.build(); }