java.util.Optional.equals()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(12.1k)|赞(0)|评价(0)|浏览(184)

本文整理了Java中java.util.Optional.equals()方法的一些代码示例,展示了Optional.equals()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Optional.equals()方法的具体详情如下:
包路径:java.util.Optional
类名称:Optional
方法名:equals

Optional.equals介绍

[英]Indicates whether some other object is "equal to" this Optional. The other object is considered equal if:

  • it is also an Optional and;
  • both instances have no value present or;
  • the present values are "equal to" each other via equals().
    [中]

代码示例

代码示例来源:origin: prestodb/presto

@Override
public boolean equals(Object other)
{
  if (other == this) {
    return true;
  }
  if (!(other instanceof ResourceGroupGlobalProperties)) {
    return false;
  }
  ResourceGroupGlobalProperties that = (ResourceGroupGlobalProperties) other;
  return cpuQuotaPeriod.equals(that.cpuQuotaPeriod);
}

代码示例来源:origin: prestodb/presto

public boolean sameConfig(ResourceGroupSpec other)
{
  if (other == null) {
    return false;
  }
  return (name.equals(other.name) &&
      softMemoryLimit.equals(other.softMemoryLimit) &&
      maxQueued == other.maxQueued &&
      softConcurrencyLimit.equals(other.softConcurrencyLimit) &&
      hardConcurrencyLimit == other.hardConcurrencyLimit &&
      schedulingPolicy.equals(other.schedulingPolicy) &&
      schedulingWeight.equals(other.schedulingWeight) &&
      jmxExport.equals(other.jmxExport) &&
      softCpuLimit.equals(other.softCpuLimit) &&
      hardCpuLimit.equals(other.hardCpuLimit));
}

代码示例来源:origin: prestodb/presto

@Override
public boolean equals(Object obj)
{
  if (this == obj) {
    return true;
  }
  if (obj == null || getClass() != obj.getClass()) {
    return false;
  }
  ArgumentProperty other = (ArgumentProperty) obj;
  return this.argumentType == other.argumentType &&
      this.nullConvention.equals(other.nullConvention) &&
      this.lambdaInterface.equals(other.lambdaInterface);
}

代码示例来源:origin: Alluxio/alluxio

@Override
public boolean equals(Object other) {
 if (other instanceof ChannelKey) {
  ChannelKey otherKey = (ChannelKey) other;
  return mAddress.equals(otherKey.mAddress)
    && mPlain == otherKey.mPlain
    && mKeepAliveTime.equals(otherKey.mKeepAliveTime)
    && mKeepAliveTimeout.equals(otherKey.mKeepAliveTimeout)
    && mFlowControlWindow.equals(otherKey.mFlowControlWindow)
    && mMaxInboundMessageSize.equals(otherKey.mMaxInboundMessageSize)
    && mChannelType.equals(otherKey.mChannelType)
    && mPoolKey == otherKey.mPoolKey
    && mEventLoopGroup.equals(otherKey.mEventLoopGroup);
 }
 return false;
}

代码示例来源:origin: prestodb/presto

@Override
public boolean equals(Object other)
{
  if (other == this) {
    return true;
  }
  if (!(other instanceof ResourceGroupSpec)) {
    return false;
  }
  ResourceGroupSpec that = (ResourceGroupSpec) other;
  return (name.equals(that.name) &&
      softMemoryLimit.equals(that.softMemoryLimit) &&
      maxQueued == that.maxQueued &&
      softConcurrencyLimit.equals(that.softConcurrencyLimit) &&
      hardConcurrencyLimit == that.hardConcurrencyLimit &&
      schedulingPolicy.equals(that.schedulingPolicy) &&
      schedulingWeight.equals(that.schedulingWeight) &&
      subGroups.equals(that.subGroups) &&
      jmxExport.equals(that.jmxExport) &&
      softCpuLimit.equals(that.softCpuLimit) &&
      hardCpuLimit.equals(that.hardCpuLimit));
}

代码示例来源:origin: prestodb/presto

private static <T> boolean hasLocalOptimization(List<LocalProperty<T>> desiredLayout, List<Optional<LocalProperty<T>>> matchResult)
{
  checkArgument(desiredLayout.size() == matchResult.size());
  if (matchResult.isEmpty()) {
    return false;
  }
  // Optimizations can be applied if the first LocalProperty has been modified in the match in any way
  return !matchResult.get(0).equals(Optional.of(desiredLayout.get(0)));
}

代码示例来源:origin: prestodb/presto

@Override
public boolean equals(Object other)
{
  if (other == this) {
    return true;
  }
  if (!(other instanceof SelectorSpec)) {
    return false;
  }
  SelectorSpec that = (SelectorSpec) other;
  return (group.equals(that.group) &&
      userRegex.map(Pattern::pattern).equals(that.userRegex.map(Pattern::pattern)) &&
      userRegex.map(Pattern::flags).equals(that.userRegex.map(Pattern::flags)) &&
      sourceRegex.map(Pattern::pattern).equals(that.sourceRegex.map(Pattern::pattern))) &&
      sourceRegex.map(Pattern::flags).equals(that.sourceRegex.map(Pattern::flags)) &&
      queryType.equals(that.queryType) &&
      clientTags.equals(that.clientTags);
}

代码示例来源:origin: prestodb/presto

private StreamProperties(
    StreamDistribution distribution,
    Optional<? extends Iterable<Symbol>> partitioningColumns,
    boolean ordered,
    ActualProperties otherActualProperties)
{
  this.distribution = requireNonNull(distribution, "distribution is null");
  this.partitioningColumns = requireNonNull(partitioningColumns, "partitioningProperties is null")
      .map(ImmutableList::copyOf);
  checkArgument(distribution != SINGLE || this.partitioningColumns.equals(Optional.of(ImmutableList.of())),
      "Single stream must be partitioned on empty set");
  checkArgument(distribution == SINGLE || !this.partitioningColumns.equals(Optional.of(ImmutableList.of())),
      "Multiple streams must not be partitioned on empty set");
  this.ordered = ordered;
  checkArgument(!ordered || distribution == SINGLE, "Ordered must be a single stream");
  this.otherActualProperties = otherActualProperties;
}

代码示例来源:origin: line/armeria

@Override
public boolean equals(Object o) {
  if (this == o) {
    return true;
  }
  if (o == null || getClass() != o.getClass()) {
    return false;
  }
  final DefaultPathMapping that = (DefaultPathMapping) o;
  return skeleton.equals(that.skeleton) &&
      Arrays.equals(paramNameArray, that.paramNameArray);
}

代码示例来源:origin: prestodb/presto

@Override
public boolean equals(Object o)
{
  if (this == o) {
    return true;
  }
  if (o == null || getClass() != o.getClass()) {
    return false;
  }
  ThriftTableLayoutHandle other = (ThriftTableLayoutHandle) o;
  return schemaName.equals(other.schemaName)
      && tableName.equals(other.tableName)
      && columns.equals(other.columns)
      && constraint.equals(other.constraint);
}

代码示例来源:origin: prestodb/presto

public Scope process(Node node, Optional<Scope> scope)
{
  Scope returnScope = super.process(node, scope);
  checkState(returnScope.getOuterQueryParent().equals(outerQueryScope), "result scope should have outer query scope equal with parameter outer query scope");
  if (scope.isPresent()) {
    checkState(hasScopeAsLocalParent(returnScope, scope.get()), "return scope should have context scope as one of ancestors");
  }
  return returnScope;
}

代码示例来源:origin: prestodb/presto

@Override
public boolean equals(Object o)
{
  if (this == o) {
    return true;
  }
  if (o == null || getClass() != o.getClass()) {
    return false;
  }
  Use use = (Use) o;
  if (!catalog.equals(use.catalog)) {
    return false;
  }
  if (!schema.equals(use.schema)) {
    return false;
  }
  return true;
}

代码示例来源:origin: apache/flink

@Override
public boolean equals(Object o) {
  if (this == o) {
    return true;
  }
  if (o == null || getClass() != o.getClass()) {
    return false;
  }
  State<?, ?> state = (State<?, ?>) o;
  if (pendingTransaction != null ? !pendingTransaction.equals(state.pendingTransaction) : state.pendingTransaction != null) {
    return false;
  }
  if (pendingCommitTransactions != null ? !pendingCommitTransactions.equals(state.pendingCommitTransactions) : state.pendingCommitTransactions != null) {
    return false;
  }
  return context != null ? context.equals(state.context) : state.context == null;
}

代码示例来源:origin: google/google-java-format

/** Skips over extra semi-colons at the top-level, or in a class member declaration lists. */
private void dropEmptyDeclarations() {
 if (builder.peekToken().equals(Optional.of(";"))) {
  while (builder.peekToken().equals(Optional.of(";"))) {
   markForPartialFormat();
   token(";");
  }
 }
}

代码示例来源:origin: prestodb/presto

@Override
public Optional<PartitioningHandle> getCommonPartitioning(Session session, PartitioningHandle left, PartitioningHandle right)
{
  Optional<ConnectorId> leftConnectorId = left.getConnectorId();
  Optional<ConnectorId> rightConnectorId = right.getConnectorId();
  if (!leftConnectorId.isPresent() || !rightConnectorId.isPresent() || !leftConnectorId.equals(rightConnectorId)) {
    return Optional.empty();
  }
  if (!left.getTransactionHandle().equals(right.getTransactionHandle())) {
    return Optional.empty();
  }
  ConnectorId connectorId = leftConnectorId.get();
  CatalogMetadata catalogMetadata = getCatalogMetadata(session, connectorId);
  ConnectorMetadata metadata = catalogMetadata.getMetadataFor(connectorId);
  Optional<ConnectorPartitioningHandle> commonHandle = metadata.getCommonPartitioningHandle(session.toConnectorSession(connectorId), left.getConnectorHandle(), right.getConnectorHandle());
  return commonHandle.map(handle -> new PartitioningHandle(Optional.of(connectorId), left.getTransactionHandle(), handle));
}

代码示例来源:origin: prestodb/presto

private TypeCompatibility typeCompatibilityForRow(RowType firstType, RowType secondType)
{
  List<Field> firstFields = firstType.getFields();
  List<Field> secondFields = secondType.getFields();
  if (firstFields.size() != secondFields.size()) {
    return TypeCompatibility.incompatible();
  }
  ImmutableList.Builder<RowType.Field> fields = ImmutableList.builder();
  boolean coercible = true;
  for (int i = 0; i < firstFields.size(); i++) {
    Type firstFieldType = firstFields.get(i).getType();
    Type secondFieldType = secondFields.get(i).getType();
    TypeCompatibility typeCompatibility = compatibility(firstFieldType, secondFieldType);
    if (!typeCompatibility.isCompatible()) {
      return TypeCompatibility.incompatible();
    }
    Type commonParameterType = typeCompatibility.getCommonSuperType();
    Optional<String> firstParameterName = firstFields.get(i).getName();
    Optional<String> secondParameterName = secondFields.get(i).getName();
    Optional<String> commonName = firstParameterName.equals(secondParameterName) ? firstParameterName : Optional.empty();
    // ignore parameter name for coercible
    coercible &= typeCompatibility.isCoercible();
    fields.add(new RowType.Field(commonName, commonParameterType));
  }
  return TypeCompatibility.compatible(RowType.from(fields.build()), coercible);
}

代码示例来源:origin: prestodb/presto

@Override
public MatchResult detailMatches(PlanNode node, StatsProvider stats, Session session, Metadata metadata, SymbolAliases symbolAliases)
{
  checkState(shapeMatches(node), "Plan testing framework error: shapeMatches returned false in detailMatches in %s", this.getClass().getName());
  MarkDistinctNode markDistinctNode = (MarkDistinctNode) node;
  if (!markDistinctNode.getHashSymbol().equals(hashSymbol.map(alias -> alias.toSymbol(symbolAliases)))) {
    return NO_MATCH;
  }
  if (!ImmutableSet.copyOf(markDistinctNode.getDistinctSymbols())
      .equals(distinctSymbols.stream().map(alias -> alias.toSymbol(symbolAliases)).collect(toImmutableSet()))) {
    return NO_MATCH;
  }
  return match(markerSymbol.toString(), markDistinctNode.getMarkerSymbol().toSymbolReference());
}

代码示例来源:origin: prestodb/presto

@Override
public MatchResult detailMatches(PlanNode node, StatsProvider stats, Session session, Metadata metadata, SymbolAliases symbolAliases)
{
  checkState(shapeMatches(node), "Plan testing framework error: shapeMatches returned false in detailMatches in %s", this.getClass().getName());
  SpatialJoinNode joinNode = (SpatialJoinNode) node;
  if (!new ExpressionVerifier(symbolAliases).process(joinNode.getFilter(), filter)) {
    return NO_MATCH;
  }
  if (!joinNode.getKdbTree().equals(kdbTree)) {
    return NO_MATCH;
  }
  return match();
}

代码示例来源:origin: prestodb/presto

@Override
public MatchResult detailMatches(PlanNode node, StatsProvider stats, Session session, Metadata metadata, SymbolAliases symbolAliases)
{
  checkState(shapeMatches(node), "Plan testing framework error: shapeMatches returned false in detailMatches in %s", this.getClass().getName());
  SemiJoinNode semiJoinNode = (SemiJoinNode) node;
  if (!(symbolAliases.get(sourceSymbolAlias).equals(semiJoinNode.getSourceJoinSymbol().toSymbolReference()) &&
      symbolAliases.get(filteringSymbolAlias).equals(semiJoinNode.getFilteringSourceJoinSymbol().toSymbolReference()))) {
    return NO_MATCH;
  }
  if (distributionType.isPresent() && !distributionType.equals(semiJoinNode.getDistributionType())) {
    return NO_MATCH;
  }
  return match(outputAlias, semiJoinNode.getSemiJoinOutput().toSymbolReference());
}

代码示例来源:origin: prestodb/presto

@Override
  public Result apply(JoinNode joinNode, Captures captures, Context context)
  {
    Optional<Expression> filter = joinNode.getFilter().map(x -> rewriter.rewrite(x, context));
    if (!joinNode.getFilter().equals(filter)) {
      return Result.ofPlanNode(new JoinNode(
          joinNode.getId(),
          joinNode.getType(),
          joinNode.getLeft(),
          joinNode.getRight(),
          joinNode.getCriteria(),
          joinNode.getOutputSymbols(),
          filter,
          joinNode.getLeftHashSymbol(),
          joinNode.getRightHashSymbol(),
          joinNode.getDistributionType()));
    }
    return Result.empty();
  }
}

相关文章