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


Java ImmutableCollection.isEmpty方法代码示例

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


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

示例1: InsertQueryImpl

import com.google.common.collect.ImmutableCollection; //导入方法依赖的package包/类
/**
 * At least one of {@code tx} and {@code match} must be absent.
 *
 * @param vars a collection of Vars to insert
 * @param match the {@link Match} to insert for each result
 * @param tx the graph to execute on
 */
InsertQueryImpl(ImmutableCollection<VarPatternAdmin> vars, Optional<MatchAdmin> match, Optional<GraknTx> tx) {
    // match and graph should never both be present (should get graph from inner match)
    assert(!match.isPresent() || !tx.isPresent());

    if (vars.isEmpty()) {
        throw GraqlQueryException.noPatterns();
    }

    this.match = match;
    this.tx = tx;

    this.originalVars = vars;

    // Get all variables, including ones nested in other variables
    this.vars = vars.stream().flatMap(v -> v.innerVarPatterns().stream()).collect(toImmutableList());

    for (VarPatternAdmin var : this.vars) {
        var.getProperties().forEach(property -> ((VarPropertyInternal) property).checkInsertable(var));
    }
}
 
开发者ID:graknlabs,项目名称:grakn,代码行数:28,代码来源:InsertQueryImpl.java

示例2: transform

import com.google.common.collect.ImmutableCollection; //导入方法依赖的package包/类
@Override
public void transform(TransformWork work)
    throws IOException, ValidationException {
  Author author = null;
  // If multiple commits are included (for example on a squash for skipping a bad change),
  // last author wins.
  for (Change<?> change : work.getChanges().getCurrent()) {
    ImmutableCollection<String> labelValue = change.getLabels().get(label);
    if (!labelValue.isEmpty()) {
      try {
        author = Author.parse(/*location=*/null, Iterables.getLast(labelValue));
      } catch (EvalException e) {
        // Don't fail the migration because the label is wrong since it is very
        // difficult for a user to recover from this.
        work.getConsole().warn("Cannot restore original author: " + e.getMessage());
      }
    }
    if (!searchAllChanges) {
      break;
    }
  }
  if (author != null) {
    work.setAuthor(author);
    work.removeLabel(label, /*wholeMessage=*/true);
  }
}
 
开发者ID:google,项目名称:copybara,代码行数:27,代码来源:RestoreOriginalAuthor.java

示例3: getConfigurationForFile

import com.google.common.collect.ImmutableCollection; //导入方法依赖的package包/类
@Nullable
OCResolveConfiguration getConfigurationForFile(VirtualFile sourceFile) {
  SourceToTargetMap sourceToTargetMap = SourceToTargetMap.getInstance(project);
  ImmutableCollection<TargetKey> targetsForSourceFile =
      sourceToTargetMap.getRulesForSourceFile(VfsUtilCore.virtualToIoFile(sourceFile));
  if (targetsForSourceFile.isEmpty()) {
    return null;
  }

  // If a source file is in two different targets, we can't possibly show how it will be
  // interpreted in both contexts at the same time in the IDE, so just pick the "first" target.
  TargetKey targetKey = targetsForSourceFile.stream().min(TargetKey::compareTo).orElse(null);
  Preconditions.checkNotNull(targetKey);

  return configurationMap.get(targetKey);
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:17,代码来源:BlazeConfigurationResolverResult.java

示例4: CollectionFutureRunningState

import com.google.common.collect.ImmutableCollection; //导入方法依赖的package包/类
CollectionFutureRunningState(
    ImmutableCollection<? extends ListenableFuture<? extends V>> futures,
    boolean allMustSucceed) {
  super(futures, allMustSucceed, true);

  this.values =
      futures.isEmpty()
          ? ImmutableList.<Optional<V>>of()
          : Lists.<Optional<V>>newArrayListWithCapacity(futures.size());

  // Populate the results list with null initially.
  for (int i = 0; i < futures.size(); ++i) {
    values.add(null);
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:16,代码来源:CollectionFuture.java

示例5: characterRangeToTokenRange

import com.google.common.collect.ImmutableCollection; //导入方法依赖的package包/类
/**
 * Convert from an offset and length flag pair to a token range.
 *
 * @param offset the {@code 0}-based offset in characters
 * @param length the length in characters
 * @return the {@code 0}-based {@link Range} of tokens
 * @throws FormatterException
 */
Range<Integer> characterRangeToTokenRange(int offset, int length) throws FormatterException {
    int requiredLength = offset + length;
    if (requiredLength > text.length()) {
        throw new FormatterException(
                String.format(
                        "error: invalid length %d, offset + length (%d) is outside the file",
                        length, requiredLength));
    }
    if (length < 0) {
        return EMPTY_RANGE;
    }
    if (length == 0) {
        // 0 stands for "format the line under the cursor"
        length = 1;
    }
    ImmutableCollection<Token> enclosed =
            getPositionTokenMap()
                    .subRangeMap(Range.closedOpen(offset, offset + length))
                    .asMapOfRanges()
                    .values();
    if (enclosed.isEmpty()) {
        return EMPTY_RANGE;
    }
    return Range.closedOpen(
            enclosed.iterator().next().getTok().getIndex(), getLast(enclosed).getTok().getIndex() + 1);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:35,代码来源:JavaInput.java

示例6: filterBy

import com.google.common.collect.ImmutableCollection; //导入方法依赖的package包/类
@Override
public Maybe<LinkFactories.OneBlob> filterBy(Blob blob) {
	ImmutableCollection<ImmutableMap<String, Object>> keys = grouped.keysOf(blob);
	if (!keys.isEmpty()) {
		return Maybe.of(new DefaultBlobLinkFactory(pathRenderer, propertyFormatter, grouped.currentPath(), keys));
	}
	return Maybe.absent();
}
 
开发者ID:flapdoodle-oss,项目名称:de.flapdoodle.solid,代码行数:9,代码来源:DefaultLinkFactory.java

示例7: getPartTransform

import com.google.common.collect.ImmutableCollection; //导入方法依赖的package包/类
public TRSRTransformation getPartTransform(IModelState state, BlockPart part, int i)
{
    ImmutableCollection<MBJointWeight> infos = getJoint(i);
    if(!infos.isEmpty())
    {
        Matrix4f m = new Matrix4f(), tmp;
        float weight = 0;
        for(MBJointWeight info : infos)
        {
            if(info.getWeights().containsKey(i))
            {
                ModelBlockAnimation.MBJoint joint = new ModelBlockAnimation.MBJoint(info.getName(), part);
                Optional<TRSRTransformation> trOp = state.apply(Optional.of(joint));
                if(trOp.isPresent() && trOp.get() != TRSRTransformation.identity())
                {
                    float w = info.getWeights().get(i)[0];
                    tmp = trOp.get().getMatrix();
                    tmp.mul(w);
                    m.add(tmp);
                    weight += w;
                }
            }
        }
        if(weight > 1e-5)
        {
            m.mul(1f / weight);
            return new TRSRTransformation(m);
        }
    }
    return null;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:32,代码来源:ModelBlockAnimation.java

示例8: CollectionFutureRunningState

import com.google.common.collect.ImmutableCollection; //导入方法依赖的package包/类
CollectionFutureRunningState(
  ImmutableCollection<? extends ListenableFuture<? extends V>> futures,
  boolean allMustSucceed) {
  super(futures, allMustSucceed, true);
  this.values =
    futures.isEmpty()
      ? ImmutableList.<Optional<V>>of()
      : Lists.<Optional<V>>newArrayListWithCapacity(futures.size());

  // Populate the results list with null initially.
  for (int i = 0; i < futures.size(); ++i) {
    values.add(null);
  }
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:15,代码来源:CollectionFuture.java

示例9: CollectionFutureRunningState

import com.google.common.collect.ImmutableCollection; //导入方法依赖的package包/类
CollectionFutureRunningState(
  ImmutableCollection<? extends ListenableFuture<? extends V>> futures,
  boolean allMustSucceed) {
  super(futures, allMustSucceed, true);
  this.values = futures.isEmpty()
    ? ImmutableList.<Optional<V>>of()
    : Lists.<Optional<V>>newArrayListWithCapacity(futures.size());

  // Populate the results list with null initially.
  for (int i = 0; i < futures.size(); ++i) {
    values.add(null);
  }
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:14,代码来源:CollectionFuture.java

示例10: align

import com.google.common.collect.ImmutableCollection; //导入方法依赖的package包/类
@Override
public EventArgScoringAlignment<EquivClassType> align(final AnswerKey answerKey,
    final ArgumentOutput argumentOutput) {
  checkArgument(answerKey.docId() == argumentOutput.docId());
  final ImmutableMultimap<EquivClassType, Response> equivClassToSystemResponses = Multimaps.index(
      argumentOutput.responses(), equivClassFunction);
  final ImmutableMultimap<EquivClassType, AssessedResponse> equivClassToAnswerKeyResponses =
      Multimaps.index(
          answerKey.annotatedResponses(),
          Functions.compose(equivClassFunction, AssessedResponseFunctions.response()));

  final ImmutableSet<EquivClassType> allEquivClasses =
      Sets.union(equivClassToSystemResponses.keySet(),
          equivClassToAnswerKeyResponses.keySet()).immutableCopy();

  final ImmutableSet.Builder<EquivClassType> truePositives = ImmutableSet.builder();
  final ImmutableSet.Builder<EquivClassType> falsePositives = ImmutableSet.builder();
  final ImmutableSet.Builder<EquivClassType> falseNegatives = ImmutableSet.builder();
  final ImmutableSet.Builder<EquivClassType> unassessed = ImmutableSet.builder();

  for (final EquivClassType eqivClass : allEquivClasses) {
    // a key equivalence class is correct if anyone found a correct response in that class
    final ImmutableCollection<AssessedResponse> answerKeyResponsesForEC =
        equivClassToAnswerKeyResponses.get(eqivClass);
    final boolean isCorrectEquivClass = !FluentIterable.
        from(answerKeyResponsesForEC)
        .filter(AssessedResponse.IsCorrectUpToInexactJustifications)
        .isEmpty();

    final ImmutableCollection<Response> systemResponsesForEC = equivClassToSystemResponses.get(
        eqivClass);

    if (isCorrectEquivClass) {
      // only the top-scoring system response for an equivalence class counts
      final Optional<Response> selectedSystemResponse =
          argumentOutput.selectFromMultipleSystemResponses(
              equivClassToSystemResponses.get(eqivClass));

      if (selectedSystemResponse.isPresent()) {
        final Optional<AssessedResponse> assessmentOfSelectedResponse =
            AssessedResponse.findAnnotationForArgument(
                selectedSystemResponse.get(), answerKeyResponsesForEC);
        if (assessmentOfSelectedResponse.isPresent()) {
          if (assessmentOfSelectedResponse.get().isCorrectUpToInexactJustifications()) {
            truePositives.add(eqivClass);
          } else {
            // it was a correct equivalence class, but we the system response for that
            // equivalence class was incorrect (e.g. due to bad justifications).
            // This counts as both a false positive and a false negative. Note that there
            // could be a correct system response for the equivalence class which has a lower
            // confidence, but it won't count.
            falseNegatives.add(eqivClass);
            falsePositives.add(eqivClass);
          }
        } else {
          // the best system response for this equivalence class is unassessed
          unassessed.add(eqivClass);
        }
      } else {
        // it was a correct equivalence class, but we didn't find any responses
        falseNegatives.add(eqivClass);
      }
    } else {
      // if the equivalence class is incorrect, the system is wrong if it returned *any* response
      if (!systemResponsesForEC.isEmpty()) {
        falsePositives.add(eqivClass);
      } else {
        // do nothing - it was a true negative
      }
    }
  }

  return EventArgScoringAlignment
      .create(argumentOutput.docId(), argumentOutput, answerKey, truePositives.build(),
          falsePositives.build(),
          falseNegatives.build(), unassessed.build(), equivClassToAnswerKeyResponses,
          equivClassToSystemResponses);
}
 
开发者ID:isi-nlp,项目名称:tac-kbp-eal,代码行数:79,代码来源:StandardScoringAligner.java


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