Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions internal-api/src/main/java/datadog/trace/util/Hashtable.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,16 @@ protected Entry(K1 key1, K2 key2) {
this.key2 = key2;
}

/** The first key part this entry was created with. */
public K1 key1() {
return this.key1;
}

/** The second key part this entry was created with. */
public K2 key2() {
return this.key2;
}

public boolean matches(K1 key1, K2 key2) {
return Objects.equals(this.key1, key1) && Objects.equals(this.key2, key2);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ void entryMatchesFalseWhenKey2Differs() {
assertFalse(entry.matches("a", 2));
}

@Test
void keyAccessorsExposeConstructionKeys() {
PairEntry entry = new PairEntry("a", 1, 100);
assertEquals("a", entry.key1());
assertEquals(1, entry.key2());
}

@Test
void entryHashIsConsistentForSameKeys() {
long h1 = Hashtable.D2.Entry.hash("x", 42);
Expand Down
Loading