Skip to content

Commit 26cab22

Browse files
committed
Adding public create methods to TagMap.Entry
Methods are intended to be used to create TagMap.Entry objects for repeatedly used values Overloads are provided for all the supported types to be easier for developers not familiar with TagMap internals. Internally, TagMap still uses the more explicit new<X>Entry methods.
1 parent 9d43d47 commit 26cab22

File tree

1 file changed

+24
-0
lines changed
  • internal-api/src/main/java/datadog/trace/api

1 file changed

+24
-0
lines changed

internal-api/src/main/java/datadog/trace/api/TagMap.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,30 @@ final class Entry extends EntryChange implements Map.Entry<String, Object>, Entr
368368
* These objects might be primitive box objects.
369369
*/
370370
static final byte ANY = 0;
371+
372+
public static final Entry create(String tag, Object value) {
373+
return TagMap.Entry.newAnyEntry(tag, value);
374+
}
375+
376+
public static final Entry create(String tag, CharSequence value) {
377+
return TagMap.Entry.newObjectEntry(tag, value);
378+
}
379+
380+
public static final Entry create(String tag, int value) {
381+
return TagMap.Entry.newIntEntry(tag, value);
382+
}
383+
384+
public static final Entry create(String tag, long value) {
385+
return TagMap.Entry.newLongEntry(tag, value);
386+
}
387+
388+
public static final Entry create(String tag, float value) {
389+
return TagMap.Entry.newFloatEntry(tag, value);
390+
}
391+
392+
public static final Entry create(String tag, double value) {
393+
return TagMap.Entry.newDoubleEntry(tag, value);
394+
}
371395

372396
static Entry newAnyEntry(Map.Entry<? extends String, ? extends Object> entry) {
373397
return newAnyEntry(entry.getKey(), entry.getValue());

0 commit comments

Comments
 (0)