Push an unchecked cast until its really safe

This commit is contained in:
Nik Everett 2016-01-18 09:55:56 -05:00
parent 9e08a0d024
commit 01f37226ab
1 changed files with 4 additions and 4 deletions

View File

@ -78,16 +78,16 @@ public abstract class ValuesSourceAggregatorFactory<VS extends ValuesSource> ext
boolean collectsFromSingleBucket, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData)
throws IOException;
@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // Safe because we check the types with isAssignableFrom
private void resolveValuesSourceConfigFromAncestors(String aggName, AggregatorFactory parent, Class<VS> requiredValuesSourceType) {
ValuesSourceConfig<VS> config;
ValuesSourceConfig<?> config;
while (parent != null) {
if (parent instanceof ValuesSourceAggregatorFactory) {
config = ((ValuesSourceAggregatorFactory<VS>) parent).config;
config = ((ValuesSourceAggregatorFactory<?>) parent).config;
if (config != null && config.valid()) {
if (requiredValuesSourceType == null || requiredValuesSourceType.isAssignableFrom(config.valueSourceType)) {
ValueFormat format = config.format;
this.config = config;
this.config = (ValuesSourceConfig<VS>) config;
// if the user explicitly defined a format pattern, we'll do our best to keep it even when we inherit the
// value source form one of the ancestor aggregations
if (this.config.formatPattern != null && format != null && format instanceof ValueFormat.Patternable) {