DeclarativeSampler implements SamplerFunction<M> { @Override public @Nullable Boolean trySample(@Nullable M method) { if (method == null) return null; Sampler sampler = methodToSamplers.get(method); if (sampler == NULL_SENTINEL) return null; if (sampler != null) return sampler.isSampled(0L); sampler = samplerOfMethod(method); if (sampler == null) { methodToSamplers.put(method, NULL_SENTINEL); return null; } Sampler previousSampler = methodToSamplers.putIfAbsent(method, sampler); if (previousSampler != null) sampler = previousSampler; return sampler.isSampled(0L); } DeclarativeSampler(); static DeclarativeSampler<M> createWithProbability(
    ProbabilityOfMethod<M> probabilityOfMethod); static DeclarativeSampler<M> createWithRate(RateOfMethod<M> rateOfMethod); @Override @Nullable Boolean trySample(@Nullable M method); static DeclarativeSampler<M> create(RateForMethod<M> rateForMethod); @Deprecated Sampler toSampler(M method); @Deprecated Sampler toSampler(M method, Sampler fallback); @Deprecated SamplingFlags sample(@Nullable M method);  }
@Test public void nullOnNull() { assertThat(declarativeSampler.trySample(null)) .isNull(); }