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

x33g5p2x  于2022-01-16 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(210)

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

Collection.equals介绍

[英]Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.
[中]将参数与接收方进行比较,如果它们使用特定于类的比较表示相同对象,则返回true。

代码示例

代码示例来源:origin: bumptech/glide

@Override
public boolean equals(Object o) {
 if (o instanceof MultiTransformation) {
  MultiTransformation<?> other = (MultiTransformation<?>) o;
  return transformations.equals(other.transformations);
 }
 return false;
}

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

@Override
public boolean equals(Object obj) {
  if (obj == null) {
    return false;
  }
  if (obj instanceof FieldSet) {
    return this.collection.equals(((FieldSet) obj).collection);
  } else {
    return false;
  }
}

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

@Override
public boolean equals(Object obj) {
  if (obj instanceof State) {
    @SuppressWarnings("unchecked")
    State<T> other = (State<T>) obj;
    return name.equals(other.name) &&
      stateType == other.stateType &&
      stateTransitions.equals(other.stateTransitions);
  } else {
    return false;
  }
}

代码示例来源:origin: google/guava

@Override
public boolean equals(@Nullable Object obj) {
 if (obj instanceof InPredicate) {
  InPredicate<?> that = (InPredicate<?>) obj;
  return target.equals(that.target);
 }
 return false;
}

代码示例来源:origin: google/guava

public void testEquals_notACollection() {
  // noinspection EqualsBetweenInconvertibleTypes
  assertFalse(
    "A Collection should never equal an object that is not a Collection.",
    collection.equals("huh?"));
 }
}

代码示例来源:origin: google/guava

public void testEquals_null() {
 // noinspection ObjectEqualsNull
 assertFalse("An object should not be equal to null.", collection.equals(null));
}

代码示例来源:origin: google/guava

@SuppressWarnings("SelfEquals")
public void testEquals_self() {
 assertTrue("An Object should be equal to itself.", collection.equals(collection));
}

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

@Override
public boolean equals(Object o) {
  if (this == o) return true;
  if (o == null || getClass() != o.getClass()) return false;
  ConsumerGroupDescription that = (ConsumerGroupDescription) o;
  return isSimpleConsumerGroup == that.isSimpleConsumerGroup &&
    groupId.equals(that.groupId) &&
    members.equals(that.members) &&
    partitionAssignor.equals(that.partitionAssignor) &&
    state.equals(that.state);
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public boolean equals(@Nullable Object other) {
  if (this == other) {
    return true;
  }
  if (other == null || getClass() != other.getClass()) {
    return false;
  }
  return getContent().equals(((AbstractRequestCondition<?>) other).getContent());
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public boolean equals(@Nullable Object other) {
  if (this == other) {
    return true;
  }
  if (other == null || getClass() != other.getClass()) {
    return false;
  }
  return getContent().equals(((AbstractRequestCondition<?>) other).getContent());
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public boolean equals(@Nullable Object other) {
  if (this == other) {
    return true;
  }
  if (other == null || getClass() != other.getClass()) {
    return false;
  }
  return getContent().equals(((AbstractMessageCondition<?>) other).getContent());
}

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

@Override
public boolean equals(@NullableDecl Object obj) {
 if (obj instanceof InPredicate) {
  InPredicate<?> that = (InPredicate<?>) obj;
  return target.equals(that.target);
 }
 return false;
}

代码示例来源:origin: stanfordnlp/CoreNLP

@Override
public boolean equals(Object o) {
 if (o == this) {
  return true;
 }
 if (!(o instanceof SemanticGraph)) {
  return false;
 }
 SemanticGraph g = (SemanticGraph) o;
 return graph.equals(g.graph) && roots.equals(g.roots);
}

代码示例来源:origin: google/j2objc

@Override
public boolean equals(@NullableDecl Object obj) {
 if (obj instanceof InPredicate) {
  InPredicate<?> that = (InPredicate<?>) obj;
  return target.equals(that.target);
 }
 return false;
}

代码示例来源:origin: stanfordnlp/CoreNLP

/**
 * Returns whether the given Datum contains the same features as this Datum.
 * Doesn't check the labels, should we change this?
 */
@SuppressWarnings("unchecked")
@Override
public boolean equals(Object o) {
 if (!(o instanceof Datum)) {
  return (false);
 }
 Datum<LabelType, FeatureType> d = (Datum<LabelType, FeatureType>) o;
 return features.equals(d.asFeatures());
}

代码示例来源:origin: google/guava

public void testEquals_immutableList() {
 Collection<String> c = ImmutableList.of("a", "b", "c");
 assertTrue(c.equals(ImmutableList.of("a", "b", "c")));
 assertFalse(c.equals(ImmutableList.of("a", "c", "b")));
 assertFalse(c.equals(ImmutableList.of("a", "b")));
 assertFalse(c.equals(ImmutableList.of("a", "b", "c", "d")));
}

代码示例来源:origin: neo4j/neo4j

private boolean propertyValuesEqual( Object expected, Object readValue )
{
  if ( expected.getClass().isArray() )
  {
    return arrayAsCollection( expected ).equals( arrayAsCollection( readValue ) );
  }
  return expected.equals( readValue );
}

代码示例来源:origin: apache/incubator-shardingsphere

private boolean isSameShardingValue(final ListShardingValue shardingValue1, final ListShardingValue shardingValue2) {
  return isSameLogicTable(shardingValue1, shardingValue2)
      && shardingValue1.getColumnName().equals(shardingValue2.getColumnName()) && shardingValue1.getValues().equals(shardingValue2.getValues());
}

代码示例来源:origin: google/guava

public void testEquals_sameType() {
 Collection<String> c = of("a", "b", "c");
 assertTrue(c.equals(of("a", "b", "c")));
 assertFalse(c.equals(of("a", "b", "d")));
}

代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin

@Override
public boolean isModified() {
 return !getUserDefinedUrls().equals(myLibrariesService.getLibraryRootUrls()) ||
     myLibrariesService instanceof GoApplicationLibrariesService &&
     ((GoApplicationLibrariesService)myLibrariesService).isUseGoPathFromSystemEnvironment() !=
     myUseEnvGoPathCheckBox.isSelected();
}

相关文章