BaggageField { @Nullable public static BaggageField getByName(@Nullable TraceContext context, String name) { if (context == null) return null; return ExtraBaggageContext.getFieldByName(context, validateName(name)); } BaggageField(String name, BaggageContext context); static BaggageField create(String name); @Deprecated static List<BaggageField> getAll(@Nullable TraceContext context); @Deprecated static List<BaggageField> getAll(TraceContextOrSamplingFlags extracted); @Deprecated @Nullable static List<BaggageField> getAll(); static Map<String, String> getAllValues(@Nullable TraceContext context); static Map<String, String> getAllValues(TraceContextOrSamplingFlags extracted); @Nullable static Map<String, String> getAllValues(); @Nullable static BaggageField getByName(@Nullable TraceContext context, String name); @Nullable static BaggageField getByName(TraceContextOrSamplingFlags extracted,
      String name); @Nullable static BaggageField getByName(String name); final String name(); @Nullable String getValue(@Nullable TraceContext context); @Nullable String getValue(); @Nullable String getValue(TraceContextOrSamplingFlags extracted); boolean updateValue(@Nullable TraceContext context, @Nullable String value); boolean updateValue(TraceContextOrSamplingFlags extracted, @Nullable String value); boolean updateValue(String value); @Override String toString(); @Override final boolean equals(Object o); @Override final int hashCode();  }
@Test public void getByName() { assertThat(BaggageField.getByName(emptyContext, REQUEST_ID.name())) .isSameAs(REQUEST_ID); try (Tracing tracing = Tracing.newBuilder().build(); Scope ws = tracing.currentTraceContext().newScope(emptyContext)) { assertThat(BaggageField.getByName(REQUEST_ID.name())) .isSameAs(REQUEST_ID); } }
@Test public void getByName_context_null() { assertThat(BaggageField.getByName((TraceContext) null, "foo")) .isNull(); }
@Test public void getByName_invalid() { assertThatThrownBy(() -> BaggageField.getByName(context, "")) .isInstanceOf(IllegalArgumentException.class); assertThatThrownBy(() -> BaggageField.getByName(context, " ")) .isInstanceOf(IllegalArgumentException.class); }