com.nike.wingtips.Span.equals()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(185)

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

Span.equals介绍

暂无

代码示例

代码示例来源:origin: Nike-Inc/wingtips

/**
 * @return true if the two given stacks contain the same spans in the same order, false otherwise.
 */
protected boolean containsSameSpansInSameOrder(Deque<Span> stack, Deque<Span> other) {
  if (stack == other)
    return true;
  if (stack == null || other == null)
    return false;
  if (stack.size() != other.size())
    return false;
  Iterator<Span> stackIterator = stack.iterator();
  Iterator<Span> otherIterator = other.iterator();
  while (stackIterator.hasNext()) {
    Span t1 = stackIterator.next();
    Span t2 = otherIterator.next();
    if (t1 != t2) {
      // Not the same instance, and at least one is non-null.
      if (t1 == null || t2 == null)
        return false;
      if (!t1.equals(t2))
        return false;
    }
  }
  return true;
}

代码示例来源:origin: Nike-Inc/wingtips

if (span.equals(getCurrentSpan())) {
  if (currentSpanStack != null && currentSpanStack.contains(span)) {
    if (span.equals(currentSpanStack.peekLast())) {

代码示例来源:origin: Nike-Inc/wingtips

@Test
public void equals_returns_false_and_hashCode_different_if_other_is_not_a_Span() {
  // given
  Span span = createFilledOutSpan(true);
  String notASpan = "notASpan";
  // expect
  //noinspection EqualsBetweenInconvertibleTypes
  assertThat(span.equals(notASpan)).isFalse();
  assertThat(span.hashCode()).isNotEqualTo(notASpan.hashCode());
}

代码示例来源:origin: Nike-Inc/wingtips

@Test
public void equals_returns_true_and_hashCode_same_if_same_instance() {
  // given
  Span fullSpan = createFilledOutSpan(true);
  // expect
  //noinspection EqualsWithItself
  assertThat(fullSpan.equals(fullSpan)).isTrue();
  assertThat(fullSpan.hashCode()).isEqualTo(fullSpan.hashCode());
}

代码示例来源:origin: Nike-Inc/wingtips

@Test
public void equals_returns_true_and_hashCode_same_if_all_fields_are_equal() {
  // given
  Span fullSpan1 = createFilledOutSpan(true);
  Span fullSpan2 = createFilledOutSpan(true);
  // expect
  assertThat(fullSpan1.equals(fullSpan2)).isTrue();
  assertThat(fullSpan1.hashCode()).isEqualTo(fullSpan2.hashCode());
}

代码示例来源:origin: Nike-Inc/wingtips

@Test
public void equals_returns_false_and_hashCode_different_if_parentSpanId_is_different() {
  // given
  Span fullSpan1 = createFilledOutSpan(true);
  Span fullSpan2 = createFilledOutSpan(true);
  List<String> badDataList = Arrays.asList(fullSpan1.getParentSpanId() + "_nope", null);
  for (String badData : badDataList) {
    Whitebox.setInternalState(fullSpan2, "parentSpanId", badData);
    // expect
    assertThat(fullSpan1.equals(fullSpan2)).isFalse();
    assertThat(fullSpan2.equals(fullSpan1)).isFalse();
    assertThat(fullSpan1.hashCode()).isNotEqualTo(fullSpan2.hashCode());
  }
}

代码示例来源:origin: Nike-Inc/wingtips

@Test
public void equals_returns_false_and_hashCode_different_if_tags_are_different() {
  // given
  Span fullSpan1 = createFilledOutSpan(true);
  Span fullSpan2 = createFilledOutSpan(true);
  fullSpan1.putTag("key-" + UUID.randomUUID().toString(), UUID.randomUUID().toString());
  // expect
  assertThat(fullSpan1.equals(fullSpan2)).isFalse();
  assertThat(fullSpan1.hashCode()).isNotEqualTo(fullSpan2.hashCode());
}

代码示例来源:origin: Nike-Inc/wingtips

@Test
public void equals_returns_false_and_hashCode_different_if_durationNanos_is_different() {
  // given
  Span fullSpan1 = createFilledOutSpan(true);
  Span fullSpan2 = createFilledOutSpan(true);
  List<Long> badDataList = Arrays.asList(fullSpan1.getDurationNanos() + 1, null);
  for (Long badData : badDataList) {
    Whitebox.setInternalState(fullSpan2, "durationNanos", badData);
    // expect
    assertThat(fullSpan1.equals(fullSpan2)).isFalse();
    assertThat(fullSpan2.equals(fullSpan1)).isFalse();
    assertThat(fullSpan1.hashCode()).isNotEqualTo(fullSpan2.hashCode());
  }
}

代码示例来源:origin: Nike-Inc/wingtips

@Test
public void equals_returns_false_and_hashCode_different_if_userId_is_different() {
  // given
  Span fullSpan1 = createFilledOutSpan(true);
  Span fullSpan2 = createFilledOutSpan(true);
  List<String> badDataList = Arrays.asList(fullSpan1.getUserId() + "_nope", null);
  for (String badData : badDataList) {
    Whitebox.setInternalState(fullSpan2, "userId", badData);
    // expect
    assertThat(fullSpan1.equals(fullSpan2)).isFalse();
    assertThat(fullSpan2.equals(fullSpan1)).isFalse();
    assertThat(fullSpan1.hashCode()).isNotEqualTo(fullSpan2.hashCode());
  }
}

代码示例来源:origin: Nike-Inc/wingtips

@Test
public void equals_returns_false_and_hashCode_different_if_spanPurpose_is_different() {
  // given
  Span fullSpan1 = createFilledOutSpan(true);
  Span fullSpan2 = createFilledOutSpan(true);
  List<SpanPurpose> badDataList = Arrays.asList(SpanPurpose.CLIENT, SpanPurpose.UNKNOWN, null);
  for (SpanPurpose badData : badDataList) {
    assertThat(fullSpan1.getSpanPurpose()).isNotEqualTo(badData);
    Whitebox.setInternalState(fullSpan2, "spanPurpose", badData);
    // expect
    assertThat(fullSpan1.equals(fullSpan2)).isFalse();
    assertThat(fullSpan2.equals(fullSpan1)).isFalse();
    assertThat(fullSpan1.hashCode()).isNotEqualTo(fullSpan2.hashCode());
  }
}

代码示例来源:origin: Nike-Inc/wingtips

@Test
public void equals_returns_false_and_hashCode_different_if_spanStartTimeEpochMicros_is_different() {
  // given
  Span fullSpan1 = createFilledOutSpan(true);
  Span fullSpan2 = createFilledOutSpan(true);
  Whitebox.setInternalState(fullSpan2, "spanStartTimeEpochMicros", fullSpan1.getSpanStartTimeEpochMicros() + 1);
  // expect
  assertThat(fullSpan1.equals(fullSpan2)).isFalse();
  assertThat(fullSpan1.hashCode()).isNotEqualTo(fullSpan2.hashCode());
}

代码示例来源:origin: Nike-Inc/wingtips

@Test
public void equals_returns_false_and_hashCode_different_if_annotations_are_different() {
  // given
  Span fullSpan1 = createFilledOutSpan(true);
  Span fullSpan2 = createFilledOutSpan(true);
  fullSpan1.addTimestampedAnnotation(TimestampedAnnotation.forCurrentTime("foo"));
  // expect
  assertThat(fullSpan1.equals(fullSpan2)).isFalse();
  assertThat(fullSpan1.hashCode()).isNotEqualTo(fullSpan2.hashCode());
}

代码示例来源:origin: Nike-Inc/wingtips

@Test
public void equals_returns_false_and_hashCode_different_if_spanName_is_different() {
  // given
  Span fullSpan1 = createFilledOutSpan(true);
  Span fullSpan2 = createFilledOutSpan(true);
  Whitebox.setInternalState(fullSpan2, "spanName", fullSpan1.getSpanName() + "_nope");
  // expect
  assertThat(fullSpan1.equals(fullSpan2)).isFalse();
  assertThat(fullSpan1.hashCode()).isNotEqualTo(fullSpan2.hashCode());
}

代码示例来源:origin: Nike-Inc/wingtips

@Test
public void equals_returns_false_and_hashCode_different_if_sampleable_is_different() {
  // given
  Span fullSpan1 = createFilledOutSpan(true);
  Span fullSpan2 = createFilledOutSpan(true);
  Whitebox.setInternalState(fullSpan2, "sampleable", !fullSpan1.isSampleable());
  // expect
  assertThat(fullSpan1.equals(fullSpan2)).isFalse();
  assertThat(fullSpan1.hashCode()).isNotEqualTo(fullSpan2.hashCode());
}

代码示例来源:origin: Nike-Inc/wingtips

@Test
public void equals_returns_false_and_hashCode_different_if_spanId_is_different() {
  // given
  Span fullSpan1 = createFilledOutSpan(true);
  Span fullSpan2 = createFilledOutSpan(true);
  Whitebox.setInternalState(fullSpan2, "spanId", fullSpan1.getSpanId() + "_nope");
  // expect
  assertThat(fullSpan1.equals(fullSpan2)).isFalse();
  assertThat(fullSpan1.hashCode()).isNotEqualTo(fullSpan2.hashCode());
}

代码示例来源:origin: Nike-Inc/wingtips

@Test
public void equals_returns_false_and_hashCode_different_if_traceId_is_different() {
  // given
  Span fullSpan1 = createFilledOutSpan(true);
  Span fullSpan2 = createFilledOutSpan(true);
  Whitebox.setInternalState(fullSpan2, "traceId", fullSpan1.getTraceId() + "_nope");
  // expect
  assertThat(fullSpan1.equals(fullSpan2)).isFalse();
  assertThat(fullSpan1.hashCode()).isNotEqualTo(fullSpan2.hashCode());
}

相关文章