/** Add a collection of tags to the set. */ ArrayTagSet addAll(Iterable<Tag> ts) { if (ts instanceof Collection) { Collection<Tag> data = (Collection<Tag>) ts; if (data.isEmpty()) { return this; } else { Tag[] newTags = new Tag[data.size()]; int i = 0; for (Tag t : data) { newTags[i] = BasicTag.convert(t); ++i; } return addAll(newTags); } } else { List<Tag> data = new ArrayList<>(); for (Tag t : ts) { data.add(t); } return addAll(data); } }
@Override public String key() { return tag1.key(); }
/** Add a collection of tags to the set. */ ArrayTagSet addAll(Iterable<Tag> ts) { if (ts instanceof Collection) { Collection<Tag> data = (Collection<Tag>) ts; if (data.isEmpty()) { return this; } else { Tag[] newTags = new Tag[data.size()]; int i = 0; for (Tag t : data) { newTags[i] = BasicTag.convert(t); ++i; } return addAll(newTags); } } else { List<Tag> data = new ArrayList<>(); for (Tag t : ts) { data.add(t); } return addAll(data); } }
private static Timer getTimer(String name, String...additionalTags) { String key = className + "." + name + "." + Joiner.on(",").join(additionalTags); return monitors.computeIfAbsent(key, k -> { List<Tag> tagList = getTags(additionalTags); tagList.add(new BasicTag("unit", TimeUnit.MILLISECONDS.name())); return registry.timer(name, tagList); }); }
/** Create an immutable instance of a tag. */ static Tag of(String key, String value) { return new BasicTag(key, value); } }
/** Create an immutable instance of a tag. */ static Tag of(String key, String value) { return new BasicTag(key, value); } }
/** * Construct a new instance that will always return a Tag with the specified value. * * @param key * the non-null key for the tag * @param value * the non-null value for the tag */ public ConstantTagFactory(String key, String value) { this(new BasicTag(key, value)); }
/** Create a new tag with the specified value and this key. */ public Tag tag(String value) { return new BasicTag(key, value); } }
/** Create a new tag with the specified value and this key. */ public Tag tag(String value) { return new BasicTag(key, value); } }
@Override public Tag next() { if (i >= length) { throw new NoSuchElementException("next called after end of iterator"); } final String k = tags[i++]; final String v = tags[i++]; return new BasicTag(k, v); } };
/** Add additional tag values. */ public T withTags(String... tags) { for (int i = 0; i < tags.length; i += 2) { extraTags.add(new BasicTag(tags[i], tags[i + 1])); } return (T) this; }
/** Add an additional tag value. */ public T withTag(String k, String v) { extraTags.add(new BasicTag(k, v)); return (T) this; }
@Override public Tag next() { if (i >= length) { throw new NoSuchElementException("next called after end of iterator"); } final String k = tags[i++]; final String v = tags[i++]; return new BasicTag(k, v); } };
@Override public Tag createTag() { final String v = value.get(); return (v == null) ? null : new BasicTag(name, v); } };
/** Add an additional tag value. */ public T withTag(String k, String v) { extraTags.add(new BasicTag(k, v)); return (T) this; }