public static int sampled(boolean sampled, int flags) {
    if (sampled) {
      flags |= FLAG_SAMPLED | FLAG_SAMPLED_SET;
    } else {
      flags |= FLAG_SAMPLED_SET;
      flags &= ~FLAG_SAMPLED;
    }
    return flags;
  }
@Test void set_sampled_false() {
    assertThat(sampled(false, FLAG_SAMPLED_SET | FLAG_SAMPLED))
      .isEqualTo(FLAG_SAMPLED_SET);
  }