MutableSpan implements Cloneable { static void remove(Object[] input, int i) { int j = i + 2; for (; j < input.length; i += 2, j += 2) { if (input[j] == null) break; input[i] = input[j]; input[i + 1] = input[j + 1]; } input[i] = input[i + 1] = null; } MutableSpan();  MutableSpan(TraceContext context, @Nullable MutableSpan defaults);  MutableSpan(MutableSpan toCopy); @Deprecated boolean isEmpty(); String traceId(); void traceId(String traceId); @Nullable String localRootId(); void localRootId(String localRootId); @Nullable String parentId(); void parentId(@Nullable String parentId); String id(); void id(String id); @Nullable String name(); void name(@Nullable String name); long startTimestamp(); void startTimestamp(long startTimestamp); long finishTimestamp(); void finishTimestamp(long finishTimestamp); Kind kind(); void kind(@Nullable Kind kind); @Nullable String localServiceName(); void localServiceName(@Nullable String localServiceName); @Nullable String localIp(); boolean localIp(@Nullable String localIp); int localPort(); void localPort(int localPort); @Nullable String remoteServiceName(); void remoteServiceName(@Nullable String remoteServiceName); @Nullable String remoteIp(); void remoteIp(@Nullable String remoteIp); int remotePort(); void remotePort(int remotePort); boolean remoteIpAndPort(@Nullable String remoteIp, int remotePort); Throwable error(); void error(@Nullable Throwable error); boolean debug(); void setDebug(); void unsetDebug(); boolean shared(); void setShared(); void unsetShared(); int annotationCount(); long annotationTimestampAt(int i); String annotationValueAt(int i); Collection<Map.Entry<Long, String>> annotations(); void forEachAnnotation(AnnotationConsumer<T> annotationConsumer, T target); void forEachAnnotation(AnnotationUpdater annotationUpdater); boolean containsAnnotation(String value); void annotate(long timestamp, String value); int tagCount(); String tagKeyAt(int i); String tagValueAt(int i); Map<String, String> tags(); @Nullable String tag(String key); @Nullable String removeTag(String key); void forEachTag(TagConsumer<T> tagConsumer, T target); void forEachTag(TagUpdater tagUpdater); void tag(String key, String value); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object o);  }
@Test public void equalsAndHashCode() { for (Supplier<MutableSpan> constructor : PERMUTATIONS) { MutableSpan span = constructor.get(); assertEqualWithSameHashCode(span, span); assertThat(span).usingRecursiveComparison().isEqualTo(span); MutableSpan sameFields = constructor.get(); assertEqualWithSameHashCode(sameFields, span); assertThat(sameFields).usingRecursiveComparison().isEqualTo(span); MutableSpan copy = new MutableSpan(span); assertEqualWithSameHashCode(copy, span); assertThat(copy).usingRecursiveComparison().isEqualTo(span); List<Supplier<MutableSpan>> exceptMe = new ArrayList<>(PERMUTATIONS); exceptMe.remove(constructor); for (Supplier<MutableSpan> otherConstructor : exceptMe) { MutableSpan other = otherConstructor.get(); assertThat(span).isNotSameAs(other); assertNeitherEqualNorShareHashCode(span, other); assertThat(Objects.deepEquals(span, other)).isFalse(); } } }
@Test public void remove() { { Object[] array = new Object[] {1, 2, 3, 4, 5, 6}; MutableSpan.remove(array, 0); assertThat(array).containsExactly(3, 4, 5, 6, null, null); } { Object[] array = new Object[] {1, 2, 3, 4, 5, 6}; MutableSpan.remove(array, 2); assertThat(array).containsExactly(1, 2, 5, 6, null, null); } { Object[] array = new Object[] {1, 2, 3, 4, 5, 6}; MutableSpan.remove(array, 4); assertThat(array).containsExactly(1, 2, 3, 4, null, null); } }