当前位置: 首页>>代码示例>>Java>>正文


Java Iterables.getLast方法代码示例

本文整理汇总了Java中com.google.common.collect.Iterables.getLast方法的典型用法代码示例。如果您正苦于以下问题:Java Iterables.getLast方法的具体用法?Java Iterables.getLast怎么用?Java Iterables.getLast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.collect.Iterables的用法示例。


在下文中一共展示了Iterables.getLast方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addBodyIfNecessary

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private void addBodyIfNecessary(
    ForStatement.Builder builder,
    List<Trees.Expression> params,
    Iterable<? extends Trees.TemplatePart> bodyParts) {
  // body goes as one special parameter, don't handle other mismatches
  if (Iterables.isEmpty(bodyParts)) {
    return;
  }

  Preconditions.checkState(inlinable.declaration().parameters().size() == params.size() + 1);

  Trees.Parameter lastParameter = Iterables.getLast(inlinable.declaration().parameters());

  LetStatement.Builder letBuilder = LetStatement.builder()
      .addAllParts(bodyParts)
      .declaration(InvokableDeclaration.builder()
          .name(remappedIdentifier(lastParameter.name()))
          .build());

  remapped.add(lastParameter.name());
  builder.addParts(letBuilder.build());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:Inliner.java

示例2: extractOutputTypes

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
protected static List<DataType> extractOutputTypes(List<Symbol> outputs, List<Projection> projections) {
    Projection lastProjection = Iterables.getLast(projections, null);
    if (lastProjection == null) {
        return Symbols.extractTypes(outputs);
    } else {
        return Symbols.extractTypes(lastProjection.outputs());
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:9,代码来源:AbstractProjectionsPhase.java

示例3: name

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Default
Optional<String> name() {
	if (signature().isEmpty()) {
		return Optional.absent();
	}
	Term last = Iterables.getLast(signature());
	if (last.isWordOrNumber() && !last.is("static")) {
		return Optional.of(last.toString());
	}
	return Optional.absent();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:Structurizer.java

示例4: getCompletions

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Override
public Iterator<String> getCompletions(ArgumentContext context) {
    String textSoFar = context.text;
    List<String> sections = COMMA_SPLITTER.splitToList(textSoFar);
    String lastSection = Iterables.getLast(sections);
    String prependText = String.join(",", sections.subList(0, sections.size() - 1));
    Iterator<String> integer = Iterators.transform(delegate.getCompletions(context.withText(lastSection)), prependText::concat);
    if (textSoFar.isEmpty() || textSoFar.endsWith(",") || textSoFar.codePoints().filter(cp -> cp == ',').count() >= (dimensions - 1)) {
        return integer;
    }
    return Iterators.concat(integer, Iterators.transform(COMMA.iterator(), textSoFar::concat));
}
 
开发者ID:kenzierocks,项目名称:HardVox,代码行数:13,代码来源:VecArg.java

示例5: toString

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
/**
 * Generates a "name"=value string; the total number of retrieved datapoints will be printed
 * <p/>  if a datapoint map is defined, and it is not empty, the last value will also be printed
 */
@Override
public String toString() {
    StringBuilder sb = new StringBuilder().append('"').append(metric()).append('"');

    // print information about the datapoints (if data is available)
    if (!datapoints().isEmpty()) {
        String lastValue = Iterables.getLast(datapoints().values());
        sb.append('=').append(lastValue);
    }

    sb.append(" (").append(datapoints().size()).append(" data points)");

    return sb.toString();
}
 
开发者ID:salesforce,项目名称:pyplyn,代码行数:19,代码来源:MetricResponse.java

示例6: apply

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Override
@SuppressFBWarnings(value = "DE_MIGHT_IGNORE", justification = "Any exceptions are to be ignored")
public T apply(final Iterable<T> input) {
    if (null == input) {
        throw new IllegalArgumentException("Input cannot be null");
    }
    try {
        return Iterables.getLast(input, null);
    } finally {
        CloseableUtil.close(input);
    }
}
 
开发者ID:gchq,项目名称:koryphe,代码行数:13,代码来源:LastItem.java

示例7: onFailure

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Override
public void onFailure(Throwable t) {
	if (t instanceof UserRecordFailedException) {
		Attempt last = Iterables.getLast(((UserRecordFailedException) t).getResult().getAttempts());
		throw new DataException("Kinesis Producer was not able to publish data - " + last.getErrorCode() + "-"
				+ last.getErrorMessage());

	}
	throw new DataException("Exception during Kinesis put", t);
}
 
开发者ID:awslabs,项目名称:kinesis-kafka-connector,代码行数:11,代码来源:AmazonKinesisSinkTask.java

示例8: answer

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Override
public HealthResponse answer(InvocationOnMock invocation) {
    URI uri = invocation.getArgumentAt(0, URI.class);
    List<String> pathSegments = UriComponentsBuilder.fromUri(uri).build().getPathSegments();
    String status = Iterables.getLast(pathSegments);
    if ("EXCEPTION".equals(status)) {
        throw new RestClientException("simulated exception");
    }
    return HealthResponse.builder().status(new Status(status)).build();
}
 
开发者ID:ePages-de,项目名称:spring-boot-readiness,代码行数:11,代码来源:MockRestTemplateAnswer.java

示例9: getLastSnapshot

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
public Optional<ConfigSnapshot> getLastSnapshot() {
    ConfigSnapshot last = Iterables.getLast(snapshots, null);
    return last == null ? Optional.<ConfigSnapshot>absent() : Optional.of(last);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:5,代码来源:Config.java

示例10: newOwner

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Override
public String newOwner(String currentOwner, Collection<String> viableCandidates) {
    return Iterables.getLast(viableCandidates);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:5,代码来源:LastCandidateSelectionStrategy.java

示例11: getModState

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
public ModState getModState(ModContainer selectedMod)
{
    return Iterables.getLast(modStates.get(selectedMod.getModId()), ModState.AVAILABLE);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:5,代码来源:LoadController.java

示例12: simpleName

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
String simpleName() {
  return Iterables.getLast(Splitter.on('.').splitToList(qualifiedName));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:4,代码来源:Mirrors.java

示例13: parse

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
public static Stream<Pair<String, String>> parse(String[] args)
{
    String full = String.join(" ", args);
    StringReader reader = new StringReader(full);

    StreamTokenizer tokenizer = new StreamTokenizer(reader);
    tokenizer.resetSyntax();
    tokenizer.wordChars(0, Integer.MAX_VALUE);
    tokenizer.whitespaceChars(0, ' ');
    tokenizer.quoteChar('"');

    List<String> parsed = new ArrayList<>();
    List<String> raw = new ArrayList<>();
    int last_tt = StreamTokenizer.TT_EOF;
    int lastIndex = 0;
    try
    {
        while (tokenizer.nextToken() != StreamTokenizer.TT_EOF)
        {
            int idx = Math.min(index(reader), full.length());

            String arg = tokenizer.sval;
            String argRaw = full.substring(lastIndex, idx);

            parsed.add(arg);
            raw.add(tokenizer.ttype != '\"' ? argRaw.trim() : argRaw);

            lastIndex = idx;
            last_tt = tokenizer.ttype;
        }
    }
    catch (IOException e)
    {
        // Should never happen
        MCOpts.logger.error("Error reading string", e);
    }

    reader.close();

    if (args.length > 0 && args[args.length - 1].length() == 0)
    {
        String lastRaw = raw.size() > 0 ? Iterables.getLast(raw) : null;
        // Are we in an open quote?
        if (!(last_tt == '\"' && (lastRaw == null || lastRaw.charAt(lastRaw.length() - 1) != '\"')))
        {
            // We are currently writing a new param
            parsed.add("");
            raw.add("");
        }
    }

    return IntStream.range(0, parsed.size())
            .mapToObj(i -> Pair.of(raw.get(i), parsed.get(i)));
}
 
开发者ID:Ivorforce,项目名称:MCOpts,代码行数:55,代码来源:Parameters.java

示例14: applyThreshold

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
/**
 * Check for the input points, compare each with threshold, if it continue
 *   to pass the threshold for the critical/warn/info duration time period, change
 *   its the value to be critical/warn/info, otherwise, it's ok
 */
List<Transmutation> applyThreshold(List<Transmutation> points) {
    // nothing to do
    if (points.isEmpty()) {
        return null;
    }

    Transmutation lastPoint = Iterables.getLast(points);
    ZonedDateTime lastPointTS = lastPoint.time();

    // get the timestamp for the critical, warning, info durations
    //   if the millisecond unit is not supported, it will throw UnsupportedTemporalTypeException
    ZonedDateTime infoDurationTS = lastPointTS.minus(infoDurationMillis(), ChronoUnit.MILLIS);
    ZonedDateTime warnDurationTS = lastPointTS.minus(warnDurationMillis(), ChronoUnit.MILLIS);
    ZonedDateTime criticalDurationTS = lastPointTS.minus(criticalDurationMillis(), ChronoUnit.MILLIS);

    ListIterator<Transmutation> iter = points.listIterator(points.size());
    boolean matchThreshold = true;
    boolean atWarningLevel = false;
    boolean atInfoLevel = false;

    while (iter.hasPrevious() && matchThreshold) {
        Transmutation result = iter.previous();
        ZonedDateTime pointTS = result.time();

        Number value = result.value();
        matchThreshold = type().matches(value, threshold());

        if (matchThreshold) {
            if (pointTS.compareTo(criticalDurationTS) <= 0) {
                return Collections.singletonList(appendMessage(changeValue(result, CRIT.value()), CRIT.code(), threshold(), criticalDurationMillis()));

            } else if (pointTS.compareTo(warnDurationTS) <= 0) {
                atWarningLevel = true;

            } else if (pointTS.compareTo(infoDurationTS) <= 0) {
                atInfoLevel = true;
            }

        } else {
            if (pointTS.compareTo(warnDurationTS) <= 0) {
                return Collections.singletonList(appendMessage(changeValue(result, WARN.value()), WARN.code(), threshold(), warnDurationMillis()));

            } else if (pointTS.compareTo(infoDurationTS) <= 0) {
                return Collections.singletonList(appendMessage(changeValue(result, INFO.value()), INFO.code(), threshold(), warnDurationMillis()));

            } else {
                return Collections.singletonList(changeValue(result, OK.value())); // OK status
            }
        }
    }

    // critical, warning or info duration value is longer than available input time series
    return atWarningLevel
            ? Collections.singletonList(appendMessage(changeValue(lastPoint, WARN.value()), WARN.code(), threshold(), warnDurationMillis()))
            : (atInfoLevel
                    ? Collections.singletonList(appendMessage(changeValue(lastPoint, INFO.value()), INFO.code(), threshold(), warnDurationMillis()))
                    : Collections.singletonList(changeValue(lastPoint, OK.value())));
}
 
开发者ID:salesforce,项目名称:pyplyn,代码行数:64,代码来源:ThresholdMetForDuration.java

示例15: getSuffix

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
public String getSuffix()
{
    return Iterables.getLast(parts);
}
 
开发者ID:dbiir,项目名称:rainbow,代码行数:5,代码来源:QualifiedName.java


注:本文中的com.google.common.collect.Iterables.getLast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。