@Nullable @VisibleForTesting public <P extends TransitiveInfoProvider> P getProvider(Class<P> providerClass) { AnalysisUtils.checkProvider(providerClass); return providerClass.cast(providers.get(providerClass)); }
/** Add a specific provider with a given value. */ public RuleConfiguredTargetBuilder addProvider( Class<? extends TransitiveInfoProvider> key, TransitiveInfoProvider value) { Preconditions.checkNotNull(key); Preconditions.checkNotNull(value); AnalysisUtils.checkProvider(key); providers.put(key, value); return this; }
@Nullable @Override public <P extends TransitiveInfoProvider> P getProvider(Class<P> provider) { AnalysisUtils.checkProvider(provider); if (provider.isAssignableFrom(getClass())) { return provider.cast(this); } else { return null; } }
/** Adds a provider to the aspect. */ public Builder addProvider( Class<? extends TransitiveInfoProvider> key, TransitiveInfoProvider value) { Preconditions.checkNotNull(key); Preconditions.checkNotNull(value); AnalysisUtils.checkProvider(key); Preconditions.checkState(!providers.containsKey(key)); Preconditions.checkArgument( !SkylarkProviders.class.equals(key), "Do not provide SkylarkProviders directly"); providers.put(key, value); return this; }