Example usage for com.google.common.collect ImmutableList get

List of usage examples for com.google.common.collect ImmutableList get

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableList get.

Prototype

E get(int index);

Source Link

Document

Returns the element at the specified position in this list.

Usage

From source file:org.waveprotocol.box.server.persistence.blocks.impl.SegmentOperationImpl.java

public SegmentOperationImpl(WaveletOperation... operations) {
    ImmutableList.Builder<WaveletOperation> operationsListBuilder = ImmutableList.builder();
    Preconditions.checkArgument(operations.length != 0, "No operations");
    for (WaveletOperation operation : operations) {
        operationsListBuilder.add(operation);
    }/*from w w w .j a v a2 s . c o  m*/
    ImmutableList<WaveletOperation> operationsList = operationsListBuilder.build();
    rawOperation = new RawOperation(GsonSerializer.OPERATION_SERIALIZER, operationsList,
            operationsList.get(operationsList.size() - 1).getContext());
}

From source file:com.todoroo.astrid.service.StartupService.java

private void removeDuplicateTagMetadata(String uuid) {
    Criterion fullCriterion = Criterion.and(Metadata.KEY.eq(TaskToTagMetadata.KEY),
            TaskToTagMetadata.TAG_UUID.eq(uuid), Metadata.DELETION_DATE.eq(0));
    List<Metadata> metadatas = metadataDao.toList(fullCriterion);
    ImmutableListMultimap<Long, Metadata> metadataByTask = Multimaps.index(metadatas, Metadata::getTask);
    for (Long key : metadataByTask.keySet()) {
        ImmutableList<Metadata> tagData = metadataByTask.get(key);
        for (int i = 1; i < tagData.size(); i++) {
            metadataDao.delete(tagData.get(i).getId());
        }//from   w  ww.jav a  2  s  .c  om
    }
}

From source file:edu.mit.streamjit.impl.compiler2.SubsetAllocationStrategy.java

@Override
public void allocateGroup(ActorGroup group, Range<Integer> iterations, List<Core> cores, Configuration config) {
    int id = group.id();
    int numCores = config.getParameter("Group" + id + "CoreCount", Configuration.IntParameter.class).getValue();
    Configuration.PermutationParameter<Integer> coreOrderParam = config.getParameter("Group" + id + "CoreOrder",
            Configuration.PermutationParameter.class, Integer.class);
    ImmutableList<? extends Integer> coreOrder = coreOrderParam.getUniverse();

    List<Core> subset = new ArrayList<Core>(numCores);
    for (int i = 0; i < coreOrder.size() && subset.size() < numCores; ++i)
        if (coreOrder.get(i) < cores.size())
            subset.add(cores.get(coreOrder.get(i)));
    //We pass a null config to ensure it doesn't depend on the config.
    new FullDataParallelAllocationStrategy(numCores).allocateGroup(group, iterations, cores, null);
}

From source file:com.google.javascript.refactoring.FixingErrorManager.java

@Override
public void report(CheckLevel level, JSError error) {
    super.report(level, error);
    if (!unfixableErrors.contains(error.getType())) {
        ImmutableList<SuggestedFix> fixes = ErrorToFixMapper.getFixesForJsError(error, compiler);
        if (fixes.size() == 1) {
            sureFixes.put(error, fixes.get(0));
        } else {//  w  w w  .  java 2  s. co m
            multiFixes.putAll(error, fixes);
        }
    }
}

From source file:com.facebook.buck.rules.coercer.OutputMacroTypeCoercer.java

@Override
public OutputMacro coerce(CellPathResolver cellRoots, ProjectFilesystem filesystem,
        Path pathRelativeToProjectRoot, TargetConfiguration targetConfiguration, ImmutableList<String> args)
        throws CoerceFailedException {
    if (args.size() != 1) {
        throw new CoerceFailedException(String.format("expected exactly one argument (found %d)", args.size()));
    }//  w  ww.  j a v a2s . c  o  m
    return OutputMacro.of(args.get(0));
}

From source file:com.google.devtools.build.skyframe.CycleDeduper.java

/**
 * Returns true iff/*from ww w . j a  va  2 s  . c  om*/
 *   listA[0], listA[1], ..., listA[listA.size()]
 * is the same as
 *   listB[start], listB[start+1], ..., listB[listB.size()-1], listB[0], ..., listB[start-1]
 */
private boolean equalsWithSingleLoopFrom(ImmutableList<T> listA, ImmutableList<T> listB, int start) {
    if (listA.size() != listB.size()) {
        return false;
    }
    int length = listA.size();
    for (int i = 0; i < length; i++) {
        if (!listA.get(i).equals(listB.get((i + start) % length))) {
            return false;
        }
    }
    return true;
}

From source file:org.eclipse.xtext.ui.generator.trace.ExtensibleTraceURIConverter.java

private ITraceURIConverterContribution getContribution(
        ImmutableList<? extends ITraceURIConverterContribution> allContributions) {
    switch (allContributions.size()) {
    case 0://from   w ww .j  a va 2s  .  c o  m
        return new NullContribution();
    case 1:
        return allContributions.get(0);
    default:
        return new CompositeContribution(allContributions);
    }
}

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 ww  .  j  a va  2  s.co  m*/
    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");
    }/*w  ww .j av  a 2  s  .c  o  m*/
    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.github.hilcode.versionator.impl.DefaultReleaseExtractor.java

@Override
public final Result<String, ImmutableList<GroupArtifact>> extract(final ImmutableList<String> arguments) {
    Preconditions.checkNotNull(arguments, "Missing 'arguments'.");
    if (arguments.isEmpty()) {
        return Result.success(ImmutableList.<GroupArtifact>of());
    }//  w w w . j a  v  a  2 s . co m
    final String firstArgument = arguments.get(0);
    if (firstArgument.equals("-x") || firstArgument.equals("--exclude")) {
        final ImmutableList<String> exclusions = arguments.subList(1, arguments.size());
        return extractExclusions(exclusions);
    } else {
        return Result.failure(String.format(
                "Expected '-x' or '--exclude' but found '%s' instead.\n\nPerhaps try --help?", firstArgument));
    }
}